Skip to content

Commit 15cc8a3

Browse files
author
FalkWolsky
committed
Moving Context to make sure Subscription is initialized at Admin Portal
1 parent 3868a94 commit 15cc8a3

File tree

4 files changed

+147
-147
lines changed

4 files changed

+147
-147
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class SubscriptionApi extends Api {
6565
response = await axiosInstance.request(requestConfig);
6666
} catch (error) {
6767
if (axios.isCancel(error)) {
68-
console.warn("Request cancelled due to timeout:", error.message);
6968
// Retry once after timeout cancellation
7069
try {
7170
// Reset the cancel token and retry
@@ -81,11 +80,11 @@ class SubscriptionApi extends Api {
8180

8281
clearTimeout(retryTimeoutId);
8382
} catch (retryError) {
84-
console.error("Retry failed:", retryError);
83+
console.warn("Error at Secure Flow Request. Retry failed:", retryError);
8584
throw retryError;
8685
}
8786
} else {
88-
console.error("Error at Secure Flow Request:", error);
87+
console.warn("Error at Secure Flow Request:", error);
8988
throw error;
9089
}
9190
} finally {

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

Lines changed: 136 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import AppEditor from "../editor/AppEditor";
7474
import { set } from "lodash";
7575
import { fetchDeploymentIdAction } from "@lowcoder-ee/redux/reduxActions/configActions";
7676
import { getDeploymentId } from "@lowcoder-ee/redux/selectors/configSelectors";
77+
import { SubscriptionContextProvider } from '@lowcoder-ee/util/context/SubscriptionContext';
7778

7879
const TabLabel = styled.div`
7980
font-weight: 500;
@@ -223,145 +224,147 @@ export default function ApplicationHome() {
223224

224225
return (
225226
<DivStyled>
226-
<Layout
227-
sections={[
228-
{
229-
items: [
230-
{
231-
text: <TabLabel>{trans("home.profile")}</TabLabel>,
232-
routePath: USER_PROFILE_URL,
233-
routeComp: UserProfileView,
234-
icon: ({ selected, ...otherProps }) => selected ? <UserIcon {...otherProps} width={"24px"}/> : <UserIcon {...otherProps} width={"24px"}/>,
235-
},
236-
{
237-
text: <TabLabel>{trans("home.news")}</TabLabel>,
238-
routePath: NEWS_URL,
239-
routeComp: NewsView,
240-
icon: ({ selected, ...otherProps }) => selected ? <NewsIcon {...otherProps} width={"24px"}/> : <NewsIcon {...otherProps} width={"24px"}/>,
241-
visible: ({ user }) => user.orgDev,
242-
style: { color: "red" },
243-
},
244-
{
245-
text: <TabLabel>{trans("home.orgHome")}</TabLabel>,
246-
routePath: ORG_HOME_URL,
247-
routePathExact: false,
248-
routeComp: OrgView,
249-
icon: ({ selected, ...otherProps }) => selected ? <WorkspacesIcon {...otherProps} width={"24px"}/> : <WorkspacesIcon {...otherProps} width={"24px"}/>,
250-
visible: ({ user }) => !user.orgDev,
251-
},
252-
{
253-
text: <TabLabel>{trans("home.marketplace")}</TabLabel>,
254-
routePath: MARKETPLACE_URL,
255-
routePathExact: false,
256-
routeComp: MarketplaceView,
257-
icon: ({ selected, ...otherProps }) => selected ? <MarketplaceIcon {...otherProps} width={"24px"}/> : <MarketplaceIcon {...otherProps} width={"24px"}/>,
258-
},
259-
]
260-
},
227+
<SubscriptionContextProvider>
228+
<Layout
229+
sections={[
230+
{
231+
items: [
232+
{
233+
text: <TabLabel>{trans("home.profile")}</TabLabel>,
234+
routePath: USER_PROFILE_URL,
235+
routeComp: UserProfileView,
236+
icon: ({ selected, ...otherProps }) => selected ? <UserIcon {...otherProps} width={"24px"}/> : <UserIcon {...otherProps} width={"24px"}/>,
237+
},
238+
{
239+
text: <TabLabel>{trans("home.news")}</TabLabel>,
240+
routePath: NEWS_URL,
241+
routeComp: NewsView,
242+
icon: ({ selected, ...otherProps }) => selected ? <NewsIcon {...otherProps} width={"24px"}/> : <NewsIcon {...otherProps} width={"24px"}/>,
243+
visible: ({ user }) => user.orgDev,
244+
style: { color: "red" },
245+
},
246+
{
247+
text: <TabLabel>{trans("home.orgHome")}</TabLabel>,
248+
routePath: ORG_HOME_URL,
249+
routePathExact: false,
250+
routeComp: OrgView,
251+
icon: ({ selected, ...otherProps }) => selected ? <WorkspacesIcon {...otherProps} width={"24px"}/> : <WorkspacesIcon {...otherProps} width={"24px"}/>,
252+
visible: ({ user }) => !user.orgDev,
253+
},
254+
{
255+
text: <TabLabel>{trans("home.marketplace")}</TabLabel>,
256+
routePath: MARKETPLACE_URL,
257+
routePathExact: false,
258+
routeComp: MarketplaceView,
259+
icon: ({ selected, ...otherProps }) => selected ? <MarketplaceIcon {...otherProps} width={"24px"}/> : <MarketplaceIcon {...otherProps} width={"24px"}/>,
260+
},
261+
]
262+
},
261263

262-
{
263-
items: [
264-
{
265-
text: <MoreFoldersWrapper>{trans("home.allFolders")}</MoreFoldersWrapper>,
266-
routePath: FOLDERS_URL,
267-
routeComp: RootFolderListView,
268-
icon: ({ selected, ...otherProps }) => selected ? <FolderIcon {...otherProps} width={"24px"}/> : <FolderIcon {...otherProps} width={"24px"}/>,
269-
},
270-
{
271-
text: <TabLabel>{trans("home.allApplications")}</TabLabel>,
272-
routePath: ALL_APPLICATIONS_URL,
273-
routeComp: HomeView,
274-
icon: ({ selected, ...otherProps }) => selected ? <AppsIcon {...otherProps} width={"24px"}/> : <AppsIcon {...otherProps} width={"24px"}/>,
275-
},
276-
],
277-
},
278-
279-
{
280-
items: [
281-
282-
{
283-
text: <TabLabel>{trans("home.queryLibrary")}</TabLabel>,
284-
routePath: QUERY_LIBRARY_URL,
285-
routeComp: QueryLibraryEditor,
286-
icon: ({ selected, ...otherProps }) => selected ? <HomeQueryLibraryIcon {...otherProps} width={"24px"}/> : <HomeQueryLibraryIcon {...otherProps} width={"24px"}/>,
287-
visible: ({ user }) => user.orgDev,
288-
},
289-
{
290-
text: <TabLabel>{trans("home.datasource")}</TabLabel>,
291-
routePath: DATASOURCE_URL,
292-
routePathExact: false,
293-
routeComp: DatasourceHome,
294-
icon: ({ selected, ...otherProps }) => selected ? <HomeDataSourceIcon {...otherProps} width={"24px"}/> : <HomeDataSourceIcon {...otherProps} width={"24px"}/>,
295-
visible: ({ user }) => user.orgDev,
296-
onSelected: (_, currentPath) => currentPath.split("/")[1] === "datasource",
297-
},
298-
],
299-
},
300-
isEE() ? {
301-
items: [
302-
{
303-
text: <TabLabel>{trans("settings.AppUsage")}</TabLabel>,
304-
routePath: "/ee/6600ae8724a23f365ba2ed4c/admin",
305-
routePathExact: false,
306-
routeComp: AppEditor,
307-
icon: ({ selected, ...otherProps }) => selected ? ( <EnterpriseIcon {...otherProps} width={"24px"}/> ) : ( <EnterpriseIcon {...otherProps} width={"24px"}/> ),
308-
visible: ({ user }) => user.orgDev,
309-
},
310-
],
311-
} : { items: [] },
264+
{
265+
items: [
266+
{
267+
text: <MoreFoldersWrapper>{trans("home.allFolders")}</MoreFoldersWrapper>,
268+
routePath: FOLDERS_URL,
269+
routeComp: RootFolderListView,
270+
icon: ({ selected, ...otherProps }) => selected ? <FolderIcon {...otherProps} width={"24px"}/> : <FolderIcon {...otherProps} width={"24px"}/>,
271+
},
272+
{
273+
text: <TabLabel>{trans("home.allApplications")}</TabLabel>,
274+
routePath: ALL_APPLICATIONS_URL,
275+
routeComp: HomeView,
276+
icon: ({ selected, ...otherProps }) => selected ? <AppsIcon {...otherProps} width={"24px"}/> : <AppsIcon {...otherProps} width={"24px"}/>,
277+
},
278+
],
279+
},
280+
281+
{
282+
items: [
283+
284+
{
285+
text: <TabLabel>{trans("home.queryLibrary")}</TabLabel>,
286+
routePath: QUERY_LIBRARY_URL,
287+
routeComp: QueryLibraryEditor,
288+
icon: ({ selected, ...otherProps }) => selected ? <HomeQueryLibraryIcon {...otherProps} width={"24px"}/> : <HomeQueryLibraryIcon {...otherProps} width={"24px"}/>,
289+
visible: ({ user }) => user.orgDev,
290+
},
291+
{
292+
text: <TabLabel>{trans("home.datasource")}</TabLabel>,
293+
routePath: DATASOURCE_URL,
294+
routePathExact: false,
295+
routeComp: DatasourceHome,
296+
icon: ({ selected, ...otherProps }) => selected ? <HomeDataSourceIcon {...otherProps} width={"24px"}/> : <HomeDataSourceIcon {...otherProps} width={"24px"}/>,
297+
visible: ({ user }) => user.orgDev,
298+
onSelected: (_, currentPath) => currentPath.split("/")[1] === "datasource",
299+
},
300+
],
301+
},
302+
isEE() ? {
303+
items: [
304+
{
305+
text: <TabLabel>{trans("settings.AppUsage")}</TabLabel>,
306+
routePath: "/ee/6600ae8724a23f365ba2ed4c/admin",
307+
routePathExact: false,
308+
routeComp: AppEditor,
309+
icon: ({ selected, ...otherProps }) => selected ? ( <EnterpriseIcon {...otherProps} width={"24px"}/> ) : ( <EnterpriseIcon {...otherProps} width={"24px"}/> ),
310+
visible: ({ user }) => user.orgDev,
311+
},
312+
],
313+
} : { items: [] },
312314

313-
supportSubscription ? {
314-
items: [
315-
{
316-
text: <TabLabel>{trans("home.support")}</TabLabel>,
317-
routePath: SUPPORT_URL,
318-
routeComp: Support,
319-
routePathExact: false,
320-
icon: ({ selected, ...otherProps }) => selected ? <SupportIcon {...otherProps} width={"24px"}/> : <SupportIcon {...otherProps} width={"24px"}/>,
321-
},
322-
],
323-
} : { items: [] },
315+
supportSubscription ? {
316+
items: [
317+
{
318+
text: <TabLabel>{trans("home.support")}</TabLabel>,
319+
routePath: SUPPORT_URL,
320+
routeComp: Support,
321+
routePathExact: false,
322+
icon: ({ selected, ...otherProps }) => selected ? <SupportIcon {...otherProps} width={"24px"}/> : <SupportIcon {...otherProps} width={"24px"}/>,
323+
},
324+
],
325+
} : { items: [] },
324326

325-
{
326-
items: [
327-
{
328-
text: <TabLabel>{trans("settings.title")}</TabLabel>,
329-
routePath: SETTING_URL,
330-
routePathExact: false,
331-
routeComp: Setting,
332-
icon: ({ selected, ...otherProps }) => selected ? <HomeSettingIcon {...otherProps} width={"24px"}/> : <HomeSettingIcon {...otherProps} width={"24px"}/>,
333-
visible: ({ user }) => user.orgDev,
334-
onSelected: (_, currentPath) => currentPath.split("/")[1] === "setting",
335-
}
336-
]
337-
},
327+
{
328+
items: [
329+
{
330+
text: <TabLabel>{trans("settings.title")}</TabLabel>,
331+
routePath: SETTING_URL,
332+
routePathExact: false,
333+
routeComp: Setting,
334+
icon: ({ selected, ...otherProps }) => selected ? <HomeSettingIcon {...otherProps} width={"24px"}/> : <HomeSettingIcon {...otherProps} width={"24px"}/>,
335+
visible: ({ user }) => user.orgDev,
336+
onSelected: (_, currentPath) => currentPath.split("/")[1] === "setting",
337+
}
338+
]
339+
},
338340

339-
{
340-
items: [
341-
{
342-
text: <TabLabel>{trans("home.trash")}</TabLabel>,
343-
routePath: TRASH_URL,
344-
routeComp: TrashView,
345-
icon: ({ selected, ...otherProps }) => selected ? <RecyclerIcon {...otherProps} width={"24px"}/> : <RecyclerIcon {...otherProps} width={"24px"}/>,
346-
visible: ({ user }) => user.orgDev,
347-
},
348-
],
349-
},
341+
{
342+
items: [
343+
{
344+
text: <TabLabel>{trans("home.trash")}</TabLabel>,
345+
routePath: TRASH_URL,
346+
routeComp: TrashView,
347+
icon: ({ selected, ...otherProps }) => selected ? <RecyclerIcon {...otherProps} width={"24px"}/> : <RecyclerIcon {...otherProps} width={"24px"}/>,
348+
visible: ({ user }) => user.orgDev,
349+
},
350+
],
351+
},
350352

351-
// this we need to show the Folders view in the Admin Area
352-
{
353-
items: [
354-
{
355-
text: "",
356-
routePath: FOLDER_URL,
357-
routeComp: FolderView,
358-
visible: () => false,
359-
}
360-
]
361-
}
353+
// this we need to show the Folders view in the Admin Area
354+
{
355+
items: [
356+
{
357+
text: "",
358+
routePath: FOLDER_URL,
359+
routeComp: FolderView,
360+
visible: () => false,
361+
}
362+
]
363+
}
362364

363-
]}
364-
/>
365+
]}
366+
/>
367+
</SubscriptionContextProvider>
365368
</DivStyled>
366369
);
367370
}

client/packages/lowcoder/src/pages/setting/subscriptions/index.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import { SubscriptionContextProvider } from '@lowcoder-ee/util/context/Subscript
1111

1212
export const Subscription = () => {
1313
return (
14-
<SubscriptionContextProvider>
15-
<Switch>
16-
<Route path={SUBSCRIPTION_DETAIL} component={SubscriptionDetail} exact />
17-
<Route path={SUBSCRIPTION_INFO} component={SubscriptionInfo} exact />
18-
<Route path={SUBSCRIPTION_SUCCESS} component={SubscriptionSuccess} exact />
19-
<Route path={SUBSCRIPTION_CANCEL} component={SubscriptionCancel} exact />
20-
<Route path={SUBSCRIPTION_ERROR} component={SubscriptionError} exact />
21-
<Route path={SUBSCRIPTION_SETTING} component={SubscriptionSetting} exact />
22-
</Switch>
23-
</SubscriptionContextProvider>
14+
<Switch>
15+
<Route path={SUBSCRIPTION_DETAIL} component={SubscriptionDetail} exact />
16+
<Route path={SUBSCRIPTION_INFO} component={SubscriptionInfo} exact />
17+
<Route path={SUBSCRIPTION_SUCCESS} component={SubscriptionSuccess} exact />
18+
<Route path={SUBSCRIPTION_CANCEL} component={SubscriptionCancel} exact />
19+
<Route path={SUBSCRIPTION_ERROR} component={SubscriptionError} exact />
20+
<Route path={SUBSCRIPTION_SETTING} component={SubscriptionSetting} exact />
21+
</Switch>
2422
);
2523
};

client/packages/lowcoder/src/util/context/SubscriptionContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const SubscriptionContextProvider = (props: {
121121
if (Boolean(deploymentId) && !customer) {
122122
initializeCustomer();
123123
}
124-
}, [deploymentId, customer]);
124+
}, [deploymentId]);
125125

126126
useEffect(() => {
127127
const prepareCheckout = async () => {

0 commit comments

Comments
 (0)