Skip to content

Commit 3e0450c

Browse files
author
FalkWolsky
committed
Showing Support Product Page
1 parent d5e1c64 commit 3e0450c

File tree

6 files changed

+26
-41
lines changed

6 files changed

+26
-41
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export enum SubscriptionProducts {
441441
GITREPOS = 'git-repos',
442442
}
443443

444-
export const checkSubscriptions = () => {
444+
export const CheckSubscriptions = () => {
445445
const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);
446446
const [subscriptionDataLoaded, setSubscriptionDataLoaded] = useState<boolean>(false);
447447
const [subscriptionDataError, setSubscriptionDataError] = useState<boolean>(false);

client/packages/lowcoder/src/app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
ORG_AUTH_LOGIN_URL,
2222
ORG_AUTH_REGISTER_URL,
2323
QUERY_LIBRARY_URL,
24-
SETTING,
24+
SETTING_URL,
2525
TRASH_URL,
2626
USER_AUTH_URL,
2727
ADMIN_APP_URL,
@@ -324,7 +324,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
324324
FOLDERS_URL,
325325
FOLDER_URL,
326326
TRASH_URL,
327-
SETTING,
327+
SETTING_URL,
328328
MARKETPLACE_URL,
329329
ADMIN_APP_URL
330330
]}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const USER_PROFILE_URL = "/user/profile";
99
export const NEWS_URL = "/news";
1010
export const ORG_HOME_URL = "/org/home";
1111
export const COMPONENT_DOC_URL = "/components";
12-
export const SETTING = "/setting";
13-
export const SUPPORT = `/support`;
12+
export const SETTING_URL = "/setting";
13+
export const SUPPORT_URL = `/support`;
1414
export const PERMISSION_SETTING = "/setting/permission";
1515
export const ORGANIZATION_SETTING = "/setting/organization";
1616
export const SUBSCRIPTION_SETTING = "/setting/subscription";

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

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import {
88
MARKETPLACE_URL,
99
MODULE_APPLICATIONS_URL,
1010
QUERY_LIBRARY_URL,
11-
SETTING,
12-
SUPPORT,
11+
SETTING_URL,
12+
SUPPORT_URL,
1313
TRASH_URL,
14-
// ADMIN_APP_URL,
1514
NEWS_URL,
1615
ORG_HOME_URL,
1716
} from "constants/routesURL";
@@ -47,7 +46,6 @@ import { Layout } from "../../components/layout/Layout";
4746
import { HomeView } from "./HomeView";
4847
import { UserProfileView } from "./UserProfileView";
4948
import { NewsView } from "./NewsView";
50-
// import { ApiDocView } from "./ApiDocView";
5149
import { OrgView } from "./OrgView";
5250
import styled, { css } from "styled-components";
5351
import history from "../../util/history";
@@ -66,10 +64,11 @@ import Setting from "pages/setting";
6664
import { TypographyText } from "../../components/TypographyText";
6765
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
6866
import { isEE } from "util/envUtils";
69-
import { checkSubscriptions, SubscriptionProducts } from "@lowcoder-ee/api/subscriptionApi";
67+
import { CheckSubscriptions, SubscriptionProducts, Subscription } from "@lowcoder-ee/api/subscriptionApi";
7068

7169
// adding App Editor, so we can show Apps inside the Admin Area
7270
import AppEditor from "../editor/AppEditor";
71+
import { set } from "lodash";
7372

7473
const TabLabel = styled.div`
7574
font-weight: 500;
@@ -237,32 +236,22 @@ export default function ApplicationHome() {
237236
const allFoldersCount = allFolders.length;
238237
const orgHomeId = "root";
239238
const isSelfHost = window.location.host !== 'app.lowcoder.cloud';
240-
241-
const subscriptions = useSelector(state => state.subscriptions.subscriptions);
242-
const subscriptionDataLoaded = useSelector(state => !state.subscriptions.loading);
243-
const subscriptionDataError = useSelector(state => state.subscriptions.error);
239+
const [supportSubscription, setSupportSubscription] = useState(true);
244240

245241
// const handleFolderCreate = useCreateFolder();
246-
247-
const isOrgAdmin = org?.createdBy == user.id ? true : false;
248-
249-
// Fetch subscriptions once on component mount
250-
useEffect(() => {
251-
dispatch(checkSubscriptions());
252-
}, [dispatch]);
253242

254-
// Calculate support subscription status
255-
const supportSubscription = useMemo(() => {
256-
return subscriptions.some((sub: { product: SubscriptionProducts; }) => sub.product === SubscriptionProducts.SUPPORT);
257-
}, [subscriptions]);
243+
// we also want to check the subscription
244+
/* const { subscriptions: subscriptionData, subscriptionDataLoaded, subscriptionDataError } = dispatch(CheckSubscriptions());
258245
259-
// Early return if data is still loading or there was an error
260-
if (fetchingUser || !subscriptionDataLoaded || subscriptionDataError) {
261-
return <ProductLoading />;
262-
}
246+
if (subscriptionDataLoaded && !subscriptionDataError) {
247+
setSupportSubscription(subscriptionData.some(sub => sub.product === SubscriptionProducts.SUPPORT));
248+
} */
249+
250+
const isOrgAdmin = org?.createdBy == user.id ? true : false;
263251

264252
useEffect(() => {
265253
dispatch(fetchHomeData({}));
254+
266255
}, [user.currentOrgId]);
267256

268257
useEffect(() => {
@@ -296,10 +285,6 @@ export default function ApplicationHome() {
296285
return <ProductLoading />;
297286
}
298287

299-
if (fetchingUser || !isPreloadCompleted || !subscriptionDataLoaded || subscriptionDataError) {
300-
return <ProductLoading />;
301-
}
302-
303288
return (
304289
<DivStyled>
305290
<Layout
@@ -392,10 +377,10 @@ export default function ApplicationHome() {
392377
supportSubscription ? {
393378
items: [
394379
{
395-
text: <TabLabel>{trans("home.trash")}</TabLabel>,
396-
routePath: TRASH_URL,
380+
text: <TabLabel>{trans("home.support")}</TabLabel>,
381+
routePath: SUPPORT_URL,
397382
routeComp: TrashView,
398-
icon: ({ selected, ...otherProps }) => selected ? <RecyclerIcon {...otherProps} width={"24px"}/> : <RecyclerIcon {...otherProps} width={"24px"}/>,
383+
icon: ({ selected, ...otherProps }) => selected ? <SupportIcon {...otherProps} width={"24px"}/> : <SupportIcon {...otherProps} width={"24px"}/>,
399384
},
400385
],
401386
} : { items: [] },
@@ -404,7 +389,7 @@ export default function ApplicationHome() {
404389
items: [
405390
{
406391
text: <TabLabel>{trans("settings.title")}</TabLabel>,
407-
routePath: SETTING,
392+
routePath: SETTING_URL,
408393
routePathExact: false,
409394
routeComp: Setting,
410395
icon: ({ selected, ...otherProps }) => selected ? <HomeSettingIcon {...otherProps} width={"24px"}/> : <HomeSettingIcon {...otherProps} width={"24px"}/>,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BASE_URL, SETTING } from "constants/routesURL";
1+
import { BASE_URL, SETTING_URL } from "constants/routesURL";
22
import { useSelector } from "react-redux";
33
import { getUser } from "redux/selectors/usersSelectors";
44
import { currentOrgAdminOrDev } from "util/permissionUtils";
@@ -15,7 +15,7 @@ export function Setting() {
1515

1616
return (
1717
<Switch>
18-
<Route path={[`${SETTING}/:setting`, SETTING]} component={SettingHome} />
18+
<Route path={[`${SETTING_URL}/:setting`, SETTING_URL]} component={SettingHome} />
1919
</Switch>
2020
);
2121
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Route, Switch } from "react-router";
22
import PermissionList from "./permissionList";
33
import PermissionDetail from "./permissionDetail";
4-
import { PERMISSION_SETTING, PERMISSION_SETTING_DETAIL, SETTING } from "constants/routesURL";
4+
import { PERMISSION_SETTING, PERMISSION_SETTING_DETAIL, SETTING_URL } from "constants/routesURL";
55

66
export default () => {
77
return (
88
<Switch>
9-
<Route path={[SETTING, PERMISSION_SETTING]} component={PermissionList} exact />
9+
<Route path={[SETTING_URL, PERMISSION_SETTING]} component={PermissionList} exact />
1010
<Route path={PERMISSION_SETTING_DETAIL} component={PermissionDetail} />
1111
</Switch>
1212
);

0 commit comments

Comments
 (0)