Skip to content

Commit e1ca7dc

Browse files
added deployment_id actions
1 parent 21cff58 commit e1ca7dc

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

client/packages/lowcoder/src/api/configApi.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class ConfigApi extends Api {
1717
}
1818
return Api.get(authConfigURL);
1919
}
20+
21+
static fetchDeploymentId(): AxiosPromise<ConfigResponse> {
22+
return Api.get(`${ConfigApi.configURL}/deploymentId`);
23+
}
2024
}
2125

2226
export default ConfigApi;

client/packages/lowcoder/src/api/subscriptionApi.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ export const searchCustomersSubscriptions = async (Customer: LowcoderSearchCusto
213213
if (result?.data?.data?.length > 0) {
214214
return result?.data?.data;
215215
}
216-
else if (result.data.success == "false" && result.data.reason == "customerNotFound") {
216+
else if (result.data.success == "false" && (
217+
result.data.reason == "customerNotFound"
218+
|| result.data.reason === "userSubscriptionNotFound"
219+
)) {
217220
return [];
218221
}
219222
else if (result.data.success == "false" && result.data.reason == "userSubscriptionNotFound") {

client/packages/lowcoder/src/constants/reduxActionConstants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ export const ReduxActionTypes = {
153153
FETCH_SYS_CONFIG_INIT: "FETCH_SYS_CONFIG_INIT",
154154
FETCH_SYS_CONFIG_SUCCESS: "FETCH_SYS_CONFIG_SUCCESS",
155155
SET_EDITOR_EXTERNAL_STATE: "SET_EDITOR_EXTERNAL_STATE",
156+
FETCH_DEPLOYMENT_ID_INIT: "FETCH_DEPLOYMENT_ID_INIT",
157+
FETCH_DEPLOYMENT_ID_SUCCESS: "FETCH_DEPLOYMENT_ID_SUCCESS",
156158

157159
/* audit log */
158160
FETCH_AUDIT_EVENT: "FETCH_AUDIT_EVENT",

client/packages/lowcoder/src/pages/ApplicationV2/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ export default function ApplicationHome() {
169169
const isOrgAdmin = org?.createdBy == user.id ? true : false;
170170

171171
useEffect(() => {
172-
dispatch(fetchHomeData({}));
173-
dispatch(fetchSubscriptionsAction());
172+
if (user.currentOrgId) {
173+
dispatch(fetchHomeData({}));
174+
dispatch(fetchSubscriptionsAction());
175+
}
174176
}, [user.currentOrgId]);
175177

176178
const supportSubscription = subscriptions.some(sub => sub.product === SubscriptionProducts.SUPPORT);

client/packages/lowcoder/src/redux/reduxActions/configActions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ export const setEditorExternalStateAction = (state: Partial<ExternalEditorContex
2020
payload: state,
2121
};
2222
};
23+
24+
export const fetchDeploymentIdAction = () => {
25+
return {
26+
type: ReduxActionTypes.FETCH_DEPLOYMENT_ID_INIT,
27+
};
28+
};

client/packages/lowcoder/src/redux/sagas/configSagas.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@ export function* fetchConfigSaga(action: ReduxAction<FetchConfigActionPayload>)
3232
}
3333
}
3434

35+
export function* fetchDeploymentIdSaga(action: ReduxAction<undefined>) {
36+
try {
37+
const response: AxiosResponse<ConfigResponse> = yield call(
38+
ConfigApi.fetchDeploymentId,
39+
);
40+
const isValidResponse: boolean = validateResponse(response);
41+
if (isValidResponse) {
42+
yield put({
43+
type: ReduxActionTypes.FETCH_DEPLOYMENT_ID_SUCCESS,
44+
payload: response.data,
45+
});
46+
}
47+
} catch (error) {
48+
log.error("fail to fetch deployment_id:", error);
49+
yield put({
50+
type: ReduxActionErrorTypes.FETCH_SYS_CONFIG_ERROR,
51+
});
52+
}
53+
}
54+
3555
export default function* configSagas() {
3656
yield all([takeLatest(ReduxActionTypes.FETCH_SYS_CONFIG_INIT, fetchConfigSaga)]);
57+
yield all([takeLatest(ReduxActionTypes.FETCH_DEPLOYMENT_ID_INIT, fetchDeploymentIdSaga)]);
3758
}

0 commit comments

Comments
 (0)