@admin-layout/gluestack-ui-mobile 9.0.2-alpha.4 → 9.0.4-alpha.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/lib/components/AuthWrapper.d.ts +4 -1
- package/lib/components/AuthWrapper.js +6 -5
- package/lib/components/AuthWrapper.js.map +1 -1
- package/lib/components/Layout/components/Drawer.js +9 -9
- package/lib/components/Layout/components/Drawer.js.map +1 -1
- package/lib/components/Layout/components/Header.js +28 -15
- package/lib/components/Layout/components/Header.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js +14 -6
- package/lib/components/Layout/components/SettingDrawer/LayoutButton.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.d.ts +1 -1
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js +55 -15
- package/lib/components/Layout/components/SettingDrawer/SettingDrawer.js.map +1 -1
- package/lib/components/Layout/components/SettingDrawer/ThemeColorButton.js +1 -1
- package/lib/components/NavigationComponent.js +11 -2
- package/lib/components/NavigationComponent.js.map +1 -1
- package/lib/components/WithConfiguration.d.ts +18 -0
- package/lib/components/WithConfiguration.js +42 -0
- package/lib/components/WithConfiguration.js.map +1 -0
- package/lib/components/WithPermission.d.ts +31 -0
- package/lib/components/WithPermission.js +53 -0
- package/lib/components/WithPermission.js.map +1 -0
- package/lib/components/WithPolicy.d.ts +13 -0
- package/lib/components/WithPolicy.js +18 -0
- package/lib/components/WithPolicy.js.map +1 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/index.js +5 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/usePermissionAutoFetch.d.ts +75 -0
- package/lib/components/usePermissionAutoFetch.js +63 -0
- package/lib/components/usePermissionAutoFetch.js.map +1 -0
- package/lib/components/useSetting.d.ts +25 -0
- package/lib/components/useSetting.js +87 -0
- package/lib/components/useSetting.js.map +1 -0
- package/lib/components/with-interactions-lifecycle-managed.d.ts +3 -3
- package/lib/components/with-interactions-lifecycle-managed.js +23 -15
- package/lib/components/with-interactions-lifecycle-managed.js.map +1 -1
- package/lib/containers/layout/BasicLayout.d.ts +3 -3
- package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +393 -88
- package/lib/containers/layout/DrawerConfig.d.ts +266 -60
- package/lib/containers/layout/module.js +2 -2
- package/lib/containers/layout/module.js.map +1 -1
- package/lib/redux/settings.d.ts +8 -8
- package/lib/utils/ThemeColor.js +11 -1
- package/lib/utils/ThemeColor.js.map +1 -1
- package/lib/utils/generateMobileNavigations.d.ts +4 -10
- package/lib/utils/generateMobileNavigations.js +720 -310
- package/lib/utils/generateMobileNavigations.js.map +1 -1
- package/package.json +7 -7
- package/src/components/AuthWrapper.tsx +30 -17
- package/src/components/Layout/components/Drawer.tsx +19 -20
- package/src/components/Layout/components/Header.tsx +154 -93
- package/src/components/Layout/components/SettingDrawer/LayoutButton.tsx +27 -13
- package/src/components/Layout/components/SettingDrawer/SettingDrawer.tsx +151 -48
- package/src/components/Layout/components/SettingDrawer/ThemeColorButton.tsx +2 -2
- package/src/components/NavigationComponent.tsx +9 -2
- package/src/components/WithConfiguration.tsx +74 -0
- package/src/components/WithPermission.tsx +81 -0
- package/src/components/WithPolicy.tsx +32 -0
- package/src/components/index.ts +6 -1
- package/src/components/usePermissionAutoFetch.tsx +78 -0
- package/src/components/useSetting.tsx +137 -0
- package/src/components/with-interactions-lifecycle-managed.tsx +62 -26
- package/src/containers/layout/module.ts +2 -2
- package/src/utils/ThemeColor.ts +11 -1
- package/src/utils/generateMobileNavigations.ts +780 -290
- package/lib/components/Layout/components/util.d.ts +0 -1
- package/lib/components/Layout/components/util.js +0 -15
- package/lib/components/Layout/components/util.js.map +0 -1
- package/src/components/Layout/components/util.ts +0 -14
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Spinner, Box, Text, Heading } from '@gluestack-ui/themed';
|
|
3
|
+
import { IPermissionType, IPreDefinedPermissions, IVisibility } from '@adminide-stack/core';
|
|
4
|
+
import { useSetting, usePermissionAutoFetch } from '@adminide-stack/platform-client';
|
|
5
|
+
import { get } from 'lodash-es';
|
|
6
|
+
import { URI } from '@vscode-alt/monaco-editor/esm/vs/base/common/uri';
|
|
7
|
+
|
|
8
|
+
export interface IWithConfigurationProps {
|
|
9
|
+
children?: React.ReactElement;
|
|
10
|
+
configKey: string;
|
|
11
|
+
permissionKeys?: IPreDefinedPermissions[];
|
|
12
|
+
permissionTypes?: IPermissionType[];
|
|
13
|
+
resourceName?: string;
|
|
14
|
+
settingsUri?: URI;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const WithConfiguration = (props: IWithConfigurationProps) => {
|
|
18
|
+
const { configKey, children, permissionKeys, resourceName, permissionTypes } = props;
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
data,
|
|
22
|
+
loading: settingsLoading,
|
|
23
|
+
updateConfiguration: _,
|
|
24
|
+
} = useSetting({
|
|
25
|
+
configKey,
|
|
26
|
+
overrides: { resource: props.settingsUri },
|
|
27
|
+
});
|
|
28
|
+
// const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
29
|
+
const { permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
30
|
+
|
|
31
|
+
const isPrivate = React.useMemo(
|
|
32
|
+
() => IVisibility.Private === data?.resolveConfiguration,
|
|
33
|
+
[data?.resolveConfiguration],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const hasPermission = React.useMemo(() => {
|
|
37
|
+
if (isPrivate && permissions && Array.isArray(permissionKeys)) {
|
|
38
|
+
return permissionKeys.some((key) => permissionTypes.includes(get(permissions?.resolveConfiguration, key)));
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}, [isPrivate, permissions]);
|
|
42
|
+
|
|
43
|
+
const isLoading = React.useMemo(() => permissionLoading || settingsLoading, [permissionLoading, settingsLoading]);
|
|
44
|
+
|
|
45
|
+
if (isLoading) {
|
|
46
|
+
return <Spinner color={'#ff5a00'} />;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// if public or has permission
|
|
50
|
+
if (!isPrivate || hasPermission) {
|
|
51
|
+
return children;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!hasPermission) {
|
|
55
|
+
return (
|
|
56
|
+
<Box>
|
|
57
|
+
<Heading>Missing Permission</Heading>
|
|
58
|
+
<Text>{`You don't have the required permission to access ${resourceName || 'this resource'} `}</Text>
|
|
59
|
+
</Box>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return (
|
|
63
|
+
<Box>
|
|
64
|
+
<Heading>{`Private ${resourceName || 'Resource'}`}</Heading>
|
|
65
|
+
<Text>{`You are trying to access private ${resourceName || 'resource'}.`}</Text>
|
|
66
|
+
</Box>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
WithConfiguration.defaultProps = {
|
|
71
|
+
permissionTypes: [IPermissionType.Allow],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const WithConfigurationContainer = (props: IWithConfigurationProps) => <WithConfiguration {...props} />;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Spinner, Box, Text, Heading } from '@gluestack-ui/themed';
|
|
3
|
+
import { IPermissionType, IPreDefinedPermissions } from '@adminide-stack/core';
|
|
4
|
+
import { get } from 'lodash-es';
|
|
5
|
+
import { usePermissionAutoFetch } from '@adminide-stack/platform-client';
|
|
6
|
+
|
|
7
|
+
export enum WithPermissionBehaviour {
|
|
8
|
+
hide,
|
|
9
|
+
showUnAuthorized,
|
|
10
|
+
showAlternative,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IWithPermissionProps {
|
|
14
|
+
children?: React.ReactElement;
|
|
15
|
+
permissionKeys: IPreDefinedPermissions[];
|
|
16
|
+
permissionTypes?: IPermissionType[];
|
|
17
|
+
behaviour?: WithPermissionBehaviour;
|
|
18
|
+
message?: string;
|
|
19
|
+
alternative?: React.ReactElement;
|
|
20
|
+
render?: React.FunctionComponent<{ hasPermission: boolean }>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const WithPermission = ({
|
|
24
|
+
permissionKeys,
|
|
25
|
+
children,
|
|
26
|
+
permissionTypes = [IPermissionType.Allow],
|
|
27
|
+
behaviour = WithPermissionBehaviour.hide,
|
|
28
|
+
message = "You don't have permission to access this resource, contact owner",
|
|
29
|
+
alternative,
|
|
30
|
+
render,
|
|
31
|
+
}: IWithPermissionProps) => {
|
|
32
|
+
// const { data: permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
33
|
+
const { permissions, loading: permissionLoading } = usePermissionAutoFetch();
|
|
34
|
+
const hasPermission = React.useMemo(() => {
|
|
35
|
+
return permissionKeys.some((key) => permissionTypes.includes(get(permissions?.resolveConfiguration, key)));
|
|
36
|
+
}, [permissions, permissionTypes, permissionKeys]);
|
|
37
|
+
|
|
38
|
+
console.log('hasPermission', hasPermission);
|
|
39
|
+
console.log('permissions', JSON.stringify(permissions));
|
|
40
|
+
|
|
41
|
+
if (permissionLoading) {
|
|
42
|
+
return <Spinner />;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof render === 'function') {
|
|
46
|
+
return render({ hasPermission });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (hasPermission) {
|
|
50
|
+
return children;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (behaviour === WithPermissionBehaviour.showAlternative) {
|
|
54
|
+
return alternative;
|
|
55
|
+
}
|
|
56
|
+
if (behaviour === WithPermissionBehaviour.showUnAuthorized) {
|
|
57
|
+
if (permissionLoading) {
|
|
58
|
+
return <Spinner />;
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<Box>
|
|
62
|
+
<Heading>Missing Permission</Heading>
|
|
63
|
+
<Text>{message}</Text>
|
|
64
|
+
</Box>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
WithPermission.defaultProps = {
|
|
71
|
+
permissionTypes: [IPermissionType.Allow],
|
|
72
|
+
behaviour: WithPermissionBehaviour.hide,
|
|
73
|
+
message: "You don't have permission to access this resource, contact owner",
|
|
74
|
+
disabledProps: {
|
|
75
|
+
disabled: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const WithPermissionContainer = React.memo((props: IWithPermissionProps) => <WithPermission {...props} />);
|
|
80
|
+
export default WithPermissionContainer;
|
|
81
|
+
// export const WithPermissionContainer = (props: IWithPermissionProps) => <WithPermission {...props} />;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { Spinner } from '@gluestack-ui/themed';
|
|
4
|
+
import { logger } from '@cdm-logger/client';
|
|
5
|
+
import { useSetting } from '@adminide-stack/platform-client';
|
|
6
|
+
|
|
7
|
+
interface IProps {
|
|
8
|
+
policyKey: string;
|
|
9
|
+
Child: React.FC<{ value: unknown }>;
|
|
10
|
+
childProps?: Record<string, any>;
|
|
11
|
+
showLoading?: boolean;
|
|
12
|
+
skeletonProps?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const WithPolicy = (props: IProps): ReactElement => {
|
|
16
|
+
const { policyKey, showLoading, Child, skeletonProps = {}, childProps = {} } = props;
|
|
17
|
+
const {
|
|
18
|
+
data: policy,
|
|
19
|
+
loading,
|
|
20
|
+
error,
|
|
21
|
+
} = useSetting({
|
|
22
|
+
configKey: policyKey,
|
|
23
|
+
});
|
|
24
|
+
if (error) {
|
|
25
|
+
logger.error(error, `WithPolicy.name`);
|
|
26
|
+
}
|
|
27
|
+
if (showLoading && loading) {
|
|
28
|
+
return <Spinner color={'#ff5a00'} />;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return <Child {...childProps} value={policy?.resolveConfiguration} />;
|
|
32
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -7,4 +7,9 @@ export * from './ErrorBounday';
|
|
|
7
7
|
export * from './NavigationComponent';
|
|
8
8
|
export * from './ToastAlert';
|
|
9
9
|
export * from './with-interactions-managed';
|
|
10
|
-
export * from './AuthWrapper'
|
|
10
|
+
export * from './AuthWrapper';
|
|
11
|
+
export * from './WithPermission';
|
|
12
|
+
export * from './WithConfiguration';
|
|
13
|
+
export * from './WithPolicy';
|
|
14
|
+
export * from './usePermissionAutoFetch';
|
|
15
|
+
export * from './useSetting';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IResourceAuthority,
|
|
3
|
+
IConfigFragmentName,
|
|
4
|
+
useGetContextDataQuery,
|
|
5
|
+
generateUserUri,
|
|
6
|
+
IContext,
|
|
7
|
+
} from '@adminide-stack/core';
|
|
8
|
+
import { useSetting } from './useSetting';
|
|
9
|
+
|
|
10
|
+
interface userPermissionAutoFetchProps {
|
|
11
|
+
configKey?: string;
|
|
12
|
+
}
|
|
13
|
+
export const usePermissionAutoFetch = (options?: userPermissionAutoFetchProps) => {
|
|
14
|
+
const { data, loading } = useGetContextDataQuery();
|
|
15
|
+
const { teamUri, orgUri, userId } = (data?.getContextData as IContext) || {};
|
|
16
|
+
|
|
17
|
+
// Determine resource based on teamUri, orgUri, or fallback to userId
|
|
18
|
+
let resource = teamUri || orgUri || (userId ? generateUserUri({ _id: userId }) : generateUserUri({ _id: 'guest' }));
|
|
19
|
+
|
|
20
|
+
const { loading: settingLoading, ...remaining } = useSetting({
|
|
21
|
+
configKey: options?.configKey || '',
|
|
22
|
+
overrides: {
|
|
23
|
+
resource: resource,
|
|
24
|
+
},
|
|
25
|
+
options: {
|
|
26
|
+
forceExist: false,
|
|
27
|
+
authority: IResourceAuthority.Defaultpermissions,
|
|
28
|
+
fragment: IConfigFragmentName.Roles,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return { ...remaining, loading: loading || settingLoading };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// import React from 'react';
|
|
36
|
+
// import { IResourceAuthority, IConfigFragmentName } from '@adminide-stack/core';
|
|
37
|
+
// import { useGetTeamContextQuery } from '@adminide-stack/platform-client';
|
|
38
|
+
// import { generateOrgUri } from '@adminide-stack/core/lib/utils/generate-uri.js';
|
|
39
|
+
// import { useSelector } from 'react-redux';
|
|
40
|
+
// import { navigationRef } from '@common-stack/client-react';
|
|
41
|
+
// import { useSetting } from './useSetting';
|
|
42
|
+
|
|
43
|
+
// interface userPermissionAutoFetchProps {
|
|
44
|
+
// configKey?: string;
|
|
45
|
+
// }
|
|
46
|
+
// export const usePermissionAutoFetch = (options?: userPermissionAutoFetchProps) => {
|
|
47
|
+
// const [orgName, setOrgName] = React.useState<any>(null);
|
|
48
|
+
// const [orgUri, setOrgUri] = React.useState<any>(null);
|
|
49
|
+
// const platformState = useSelector((state) => (state as any).platform);
|
|
50
|
+
// const currentRoute: any = navigationRef.isReady() ? navigationRef?.getCurrentRoute() : null;
|
|
51
|
+
// const { data, loading } = useGetTeamContextQuery();
|
|
52
|
+
// const teamData = React.useMemo(() => data?.getTeamContext, [data]);
|
|
53
|
+
// React.useEffect(() => {
|
|
54
|
+
// if (currentRoute?.params?.orgName || platformState?.orgName) {
|
|
55
|
+
// const org = currentRoute?.params?.orgName || platformState?.orgName;
|
|
56
|
+
// if (org !== orgName) {
|
|
57
|
+
// setOrgName(org);
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
// if (orgName) {
|
|
61
|
+
// const orgUri = generateOrgUri(orgName, IConfigFragmentName.Settings);
|
|
62
|
+
// setOrgUri(orgUri);
|
|
63
|
+
// }
|
|
64
|
+
// }, [currentRoute, platformState, orgName]);
|
|
65
|
+
|
|
66
|
+
// const { loading: settingLoading, ...remaining } = useSetting({
|
|
67
|
+
// configKey: options?.configKey || '',
|
|
68
|
+
// overrides: {
|
|
69
|
+
// resource: teamData?.teamUri ?? orgUri,
|
|
70
|
+
// },
|
|
71
|
+
// options: {
|
|
72
|
+
// forceExist: false,
|
|
73
|
+
// authority: IResourceAuthority.Defaultpermissions,
|
|
74
|
+
// fragment: IConfigFragmentName.Roles,
|
|
75
|
+
// },
|
|
76
|
+
// });
|
|
77
|
+
// return { ...remaining, loading: loading || settingLoading };
|
|
78
|
+
// };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
IResolveConfigurationQuery,
|
|
4
|
+
IResolveConfigurationQueryVariables,
|
|
5
|
+
IPreferencesInput,
|
|
6
|
+
IPreferencesOpenOptionsInput,
|
|
7
|
+
IUpdateConfigurationMutation,
|
|
8
|
+
IConfigurationOverridesInput,
|
|
9
|
+
ConfigurationTarget,
|
|
10
|
+
} from '@adminide-stack/core';
|
|
11
|
+
import { QueryResult } from '@apollo/client/react';
|
|
12
|
+
import { omitBy, isNil } from 'lodash-es';
|
|
13
|
+
import { ExecutionResult } from 'graphql';
|
|
14
|
+
import {
|
|
15
|
+
useResolveConfigurationQuery,
|
|
16
|
+
useOpenPreferencesSettingsQuery,
|
|
17
|
+
useUpdateConfigurationMutation,
|
|
18
|
+
} from '@adminide-stack/platform-client';
|
|
19
|
+
|
|
20
|
+
export interface ISettingsVariable {
|
|
21
|
+
overrides?: IConfigurationOverridesInput;
|
|
22
|
+
configKey: string;
|
|
23
|
+
options?: IPreferencesOpenOptionsInput;
|
|
24
|
+
skip?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface IResponse extends QueryResult<IResolveConfigurationQuery, IResolveConfigurationQueryVariables> {
|
|
28
|
+
preferencesInput?: IPreferencesInput;
|
|
29
|
+
updateConfiguration?: ({
|
|
30
|
+
updateKey,
|
|
31
|
+
value,
|
|
32
|
+
updateOverrides,
|
|
33
|
+
target,
|
|
34
|
+
}: {
|
|
35
|
+
updateKey?: string;
|
|
36
|
+
value: string | boolean | number;
|
|
37
|
+
updateOverrides?: IConfigurationOverridesInput;
|
|
38
|
+
target?: ConfigurationTarget;
|
|
39
|
+
}) => Promise<ExecutionResult<IUpdateConfigurationMutation>>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Provides configuration for Organization and OrganizationResources. By default, it provides Organization configuration.
|
|
44
|
+
* If you need `resource` level configuration then, you need to provide resource URI in `overrides`.
|
|
45
|
+
* @param baseOptions
|
|
46
|
+
*/
|
|
47
|
+
export const useSetting = (settingsVariable: ISettingsVariable): IResponse => {
|
|
48
|
+
const { overrides, configKey, options, skip = false } = settingsVariable;
|
|
49
|
+
const targetResource = overrides?.resource ?? null;
|
|
50
|
+
let prefLoaded = false;
|
|
51
|
+
const {
|
|
52
|
+
data: prefData,
|
|
53
|
+
error: prefError,
|
|
54
|
+
loading: perfLoading,
|
|
55
|
+
refetch: refetchPrefData,
|
|
56
|
+
} = useOpenPreferencesSettingsQuery({
|
|
57
|
+
variables: { resource: targetResource, options },
|
|
58
|
+
fetchPolicy: 'cache-first', // to make `{always: true}` to work
|
|
59
|
+
skip: prefLoaded,
|
|
60
|
+
});
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
refetchPrefData({ resource: targetResource, options });
|
|
63
|
+
}, [targetResource]);
|
|
64
|
+
prefLoaded = perfLoading || skip;
|
|
65
|
+
const [updateConfigurationMutation] = useUpdateConfigurationMutation();
|
|
66
|
+
const modifiedOverrides = {
|
|
67
|
+
...overrides,
|
|
68
|
+
resource: targetResource ? prefData?.openPreferencesSettings?.editableSettingsInput ?? null : null,
|
|
69
|
+
};
|
|
70
|
+
const defaultOverrides = omitBy(modifiedOverrides, isNil);
|
|
71
|
+
let {
|
|
72
|
+
data: settingsData,
|
|
73
|
+
error: settingError,
|
|
74
|
+
loading: settingLoading,
|
|
75
|
+
...remaining
|
|
76
|
+
} = useResolveConfigurationQuery({
|
|
77
|
+
variables: {
|
|
78
|
+
input: prefData?.openPreferencesSettings ?? null,
|
|
79
|
+
key: configKey,
|
|
80
|
+
overrides: defaultOverrides,
|
|
81
|
+
},
|
|
82
|
+
fetchPolicy: 'cache-and-network', // to make `{always: true}` to work
|
|
83
|
+
skip: prefLoaded || !!prefError || !prefData?.openPreferencesSettings?.editableSettingsInput,
|
|
84
|
+
});
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
remaining?.refetch({
|
|
87
|
+
input: prefData?.openPreferencesSettings ?? null,
|
|
88
|
+
key: configKey,
|
|
89
|
+
overrides: defaultOverrides,
|
|
90
|
+
});
|
|
91
|
+
}, [prefData]);
|
|
92
|
+
|
|
93
|
+
let loading = true;
|
|
94
|
+
if (!settingLoading && !prefLoaded) {
|
|
95
|
+
loading = false;
|
|
96
|
+
}
|
|
97
|
+
const error = settingError || prefError;
|
|
98
|
+
if (error) {
|
|
99
|
+
return {
|
|
100
|
+
error,
|
|
101
|
+
data: undefined,
|
|
102
|
+
loading: false,
|
|
103
|
+
...remaining,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (loading) {
|
|
107
|
+
return {
|
|
108
|
+
error,
|
|
109
|
+
data: undefined,
|
|
110
|
+
loading,
|
|
111
|
+
...remaining,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const updateConfiguration = ({ value, updateKey, updateOverrides, target }) => {
|
|
116
|
+
return updateConfigurationMutation({
|
|
117
|
+
variables: {
|
|
118
|
+
key: updateKey || configKey,
|
|
119
|
+
value,
|
|
120
|
+
target,
|
|
121
|
+
overrides: updateOverrides || defaultOverrides,
|
|
122
|
+
input: prefData?.openPreferencesSettings,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
data: settingsData,
|
|
129
|
+
loading,
|
|
130
|
+
error,
|
|
131
|
+
...remaining,
|
|
132
|
+
preferencesInput: {
|
|
133
|
+
...prefData?.openPreferencesSettings,
|
|
134
|
+
},
|
|
135
|
+
updateConfiguration,
|
|
136
|
+
} as any;
|
|
137
|
+
};
|
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
import React
|
|
2
|
-
// import { Transition, Transitioning } from 'react-native-reanimated';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { Lifecycle } from '../containers/layout/Lifecycle';
|
|
4
3
|
import { LifecyclePhase } from '@workbench-stack/core';
|
|
5
|
-
import Animated
|
|
4
|
+
import Animated from 'react-native-reanimated';
|
|
6
5
|
import { useAfterInteractions } from '../hooks/use-after-interactions';
|
|
7
|
-
import {
|
|
8
|
-
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
6
|
+
import { Spinner, Center } from '@gluestack-ui/themed';
|
|
9
7
|
import { Platform } from 'react-native';
|
|
8
|
+
import { WithPermissionContainer } from './WithPermission';
|
|
9
|
+
import { isUserAuthenticated } from '@adminide-stack/user-auth0-client';
|
|
10
10
|
|
|
11
11
|
const LoadingComponent = () => (
|
|
12
|
-
// <SafeAreaView flex={1}>
|
|
13
12
|
<Center flex={1} justifyContent={'center'} alignItems={'center'}>
|
|
14
13
|
{<Spinner color={'$blue500'} />}
|
|
15
14
|
</Center>
|
|
16
|
-
// </SafeAreaView>
|
|
17
15
|
);
|
|
18
16
|
|
|
19
|
-
const
|
|
17
|
+
const LifecycleComponent = ({ children }: { children?: any }) => {
|
|
18
|
+
const { authenticated } = isUserAuthenticated();
|
|
19
|
+
if (authenticated) {
|
|
20
|
+
return (
|
|
21
|
+
<Lifecycle renderWhenPhase={LifecyclePhase.Restored} loadingRenderer={LoadingComponent}>
|
|
22
|
+
{children}
|
|
23
|
+
</Lifecycle>
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
return <>{children}</>;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const IntractionComponent = ({ children, interationTime }: { children?: any; interationTime: number }) => {
|
|
20
31
|
const { interactionsComplete, opacity, setInteractionsTimeOut } = useAfterInteractions();
|
|
21
32
|
React.useEffect(() => {
|
|
22
33
|
if (interationTime) setInteractionsTimeOut(interationTime);
|
|
23
34
|
}, [interationTime]);
|
|
24
|
-
console.log('interactionsComplete', interactionsComplete);
|
|
25
35
|
return (
|
|
26
36
|
<>
|
|
27
37
|
{interactionsComplete ? (
|
|
@@ -41,18 +51,15 @@ const IntractionComponent = ({ children, interationTime }) => {
|
|
|
41
51
|
);
|
|
42
52
|
};
|
|
43
53
|
|
|
44
|
-
const IntractionWithLifeCycleComponent = ({ children, interationTime }) => {
|
|
54
|
+
const IntractionWithLifeCycleComponent = ({ children, interationTime }: { children?: any; interationTime: number }) => {
|
|
45
55
|
const { interactionsComplete, opacity, setInteractionsTimeOut } = useAfterInteractions();
|
|
46
56
|
React.useEffect(() => {
|
|
47
57
|
if (interationTime) setInteractionsTimeOut(interationTime);
|
|
48
58
|
}, [interationTime]);
|
|
49
|
-
console.log('interactionsComplete', interactionsComplete);
|
|
50
59
|
return (
|
|
51
60
|
<>
|
|
52
61
|
{interactionsComplete ? (
|
|
53
|
-
<
|
|
54
|
-
{children}
|
|
55
|
-
</Lifecycle>
|
|
62
|
+
<LifecycleComponent>{children}</LifecycleComponent>
|
|
56
63
|
) : (
|
|
57
64
|
<Animated.View
|
|
58
65
|
style={{
|
|
@@ -68,38 +75,67 @@ const IntractionWithLifeCycleComponent = ({ children, interationTime }) => {
|
|
|
68
75
|
);
|
|
69
76
|
};
|
|
70
77
|
|
|
71
|
-
export function withInteractionsManaged(component: any, interationTime?: number) {
|
|
78
|
+
export function withInteractionsManaged(component: any, interationTime?: number, permissionKeys = null) {
|
|
72
79
|
return (
|
|
73
80
|
<>
|
|
74
81
|
{Platform.OS === 'ios' ? (
|
|
75
|
-
|
|
82
|
+
<>
|
|
83
|
+
<>{component}</>
|
|
84
|
+
{/* {permissionKeys ? (
|
|
85
|
+
<WithPermissionContainer permissionKeys={permissionKeys}>{component}</WithPermissionContainer>
|
|
86
|
+
) : (
|
|
87
|
+
<>{component}</>
|
|
88
|
+
)} */}
|
|
89
|
+
</>
|
|
76
90
|
) : (
|
|
77
|
-
<IntractionComponent interationTime={interationTime}>
|
|
91
|
+
<IntractionComponent interationTime={interationTime}>
|
|
92
|
+
<>{component}</>
|
|
93
|
+
{/* {permissionKeys ? (
|
|
94
|
+
<WithPermissionContainer permissionKeys={permissionKeys}>{component}</WithPermissionContainer>
|
|
95
|
+
) : (
|
|
96
|
+
<>{component}</>
|
|
97
|
+
)} */}
|
|
98
|
+
</IntractionComponent>
|
|
78
99
|
)}
|
|
79
100
|
</>
|
|
80
101
|
);
|
|
81
102
|
}
|
|
82
103
|
|
|
83
|
-
export function withLifeCycleInteractionsManaged(component: any, interationTime?: number) {
|
|
104
|
+
export function withLifeCycleInteractionsManaged(component: any, interationTime?: number, permissionKeys = null) {
|
|
84
105
|
return (
|
|
85
106
|
<>
|
|
86
107
|
{Platform.OS === 'ios' ? (
|
|
87
|
-
<
|
|
88
|
-
{component}
|
|
89
|
-
|
|
108
|
+
<LifecycleComponent>
|
|
109
|
+
<>{component}</>
|
|
110
|
+
{/* {permissionKeys ? (
|
|
111
|
+
<WithPermissionContainer permissionKeys={permissionKeys}>{component}</WithPermissionContainer>
|
|
112
|
+
) : (
|
|
113
|
+
<>{component}</>
|
|
114
|
+
)} */}
|
|
115
|
+
</LifecycleComponent>
|
|
90
116
|
) : (
|
|
91
117
|
<IntractionWithLifeCycleComponent interationTime={interationTime}>
|
|
92
|
-
{component}
|
|
118
|
+
<>{component}</>
|
|
119
|
+
{/* {permissionKeys ? (
|
|
120
|
+
<WithPermissionContainer permissionKeys={permissionKeys}>{component}</WithPermissionContainer>
|
|
121
|
+
) : (
|
|
122
|
+
<>{component}</>
|
|
123
|
+
)} */}
|
|
93
124
|
</IntractionWithLifeCycleComponent>
|
|
94
125
|
)}
|
|
95
126
|
</>
|
|
96
127
|
);
|
|
97
128
|
}
|
|
98
129
|
|
|
99
|
-
export function withLifeCycleManaged(component: any) {
|
|
130
|
+
export function withLifeCycleManaged(component: any, permissionKeys = null) {
|
|
100
131
|
return (
|
|
101
|
-
<
|
|
102
|
-
{component}
|
|
103
|
-
|
|
132
|
+
<LifecycleComponent>
|
|
133
|
+
<>{component}</>
|
|
134
|
+
{/* {permissionKeys ? (
|
|
135
|
+
<WithPermissionContainer permissionKeys={permissionKeys}>{component}</WithPermissionContainer>
|
|
136
|
+
) : (
|
|
137
|
+
<>{component}</>
|
|
138
|
+
)} */}
|
|
139
|
+
</LifecycleComponent>
|
|
104
140
|
);
|
|
105
141
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
2
|
import { Feature } from '@common-stack/client-react';
|
|
3
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
+
// import { createStackNavigator } from '@react-navigation/stack';
|
|
4
4
|
import { ProLayout, AppFeatures, AppLayout } from './ProLayout';
|
|
5
5
|
|
|
6
6
|
export { ProLayout, AppFeatures, AppLayout };
|
|
@@ -8,7 +8,7 @@ export { ProLayout, AppFeatures, AppLayout };
|
|
|
8
8
|
const layoutConfig = {
|
|
9
9
|
['/']: {
|
|
10
10
|
exact: false,
|
|
11
|
-
container: createStackNavigator(),
|
|
11
|
+
// container: createStackNavigator(),
|
|
12
12
|
name: 'MainStack',
|
|
13
13
|
props: {
|
|
14
14
|
initialRouteName: 'MainStack.MainBottomTab',
|
package/src/utils/ThemeColor.ts
CHANGED
|
@@ -6,4 +6,14 @@ export const COLOR = {
|
|
|
6
6
|
GREYISH_BLACK: '#1f1f1f',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const THEMECOLOR = [
|
|
9
|
+
export const THEMECOLOR = [
|
|
10
|
+
'#4a154b',
|
|
11
|
+
'#601e69',
|
|
12
|
+
'#1d1c1d',
|
|
13
|
+
'#36c5ef',
|
|
14
|
+
'#2db57c',
|
|
15
|
+
'#e01d5a',
|
|
16
|
+
'#ecb12f',
|
|
17
|
+
'#616061',
|
|
18
|
+
'#dcd9d4',
|
|
19
|
+
];
|