-
Notifications
You must be signed in to change notification settings - Fork 3
Hide Notification, hide files upload & mail config by organization type, app token #334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,8 @@ import { SettingsExperiencePage } from '~/pages/settings/account/ExperiencePage' | |
| import { getPluginsSettingsRoutes } from '@/app/hooks/usePluginsRouter'; | ||
| import { Skeleton } from 'erxes-ui'; | ||
| import { SettingsPageEffect } from '@/settings/components/SettingsPageEffect'; | ||
| import { currentOrganizationState } from 'ui-modules'; | ||
| import { useAtomValue } from 'jotai'; | ||
|
|
||
| const SettingsProfile = lazy(() => | ||
| import('~/pages/settings/account/ProfilePage').then((module) => ({ | ||
|
|
@@ -104,6 +106,8 @@ const PropertiesSettins = lazy(() => | |
| ); | ||
|
|
||
| export function SettingsRoutes() { | ||
| const currentOrganization = useAtomValue(currentOrganizationState); | ||
| const isOs = currentOrganization?.type === 'os'; | ||
| return ( | ||
| <Suspense fallback={<Skeleton />}> | ||
| <Routes> | ||
|
|
@@ -112,10 +116,10 @@ export function SettingsRoutes() { | |
| element={<Navigate to={`${SettingsPath.Profile}`} replace />} | ||
| /> | ||
| <Route path={SettingsPath.Profile} element={<SettingsProfile />} /> | ||
| <Route | ||
| {/* <Route | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove stale commented-out routes (e.g. Notification, Experience, General) if they are no longer needed to keep the code clean. |
||
| path={SettingsPath.Notification} | ||
| element={<NotificationSettingsRoutes />} | ||
| /> | ||
| /> */} | ||
| <Route | ||
| path={SettingsPath.ChangePassword} | ||
| element={<SettingsChangePassword />} | ||
|
|
@@ -124,14 +128,18 @@ export function SettingsRoutes() { | |
| path={SettingsPath.Experience} | ||
| element={<SettingsExperiencePage />} | ||
| /> */} | ||
| <Route | ||
| path={SettingsWorkspacePath.FileUpload} | ||
| element={<SettingsFileUpload />} | ||
| /> | ||
| <Route | ||
| path={SettingsWorkspacePath.MailConfig} | ||
| element={<SettingsMailConfig />} | ||
| /> | ||
| {isOs && ( | ||
| <Route | ||
| path={SettingsWorkspacePath.FileUpload} | ||
| element={<SettingsFileUpload />} | ||
| /> | ||
| )} | ||
| {isOs && ( | ||
| <Route | ||
| path={SettingsWorkspacePath.MailConfig} | ||
| element={<SettingsMailConfig />} | ||
| /> | ||
| )} | ||
| {/* <Route | ||
| path={SettingsWorkspacePath.General} | ||
| element={<GeneralSettings />} | ||
|
|
@@ -161,7 +169,10 @@ export function SettingsRoutes() { | |
| path={SettingsWorkspacePath.AutomationsCatchAll} | ||
| element={<AutomationSettingsRoutes />} | ||
| /> | ||
| <Route path={SettingsWorkspacePath.Apps} element={<AppsSettings />} /> | ||
| <Route | ||
| path={SettingsWorkspacePath.AppsCatchAll} | ||
| element={<AppsSettings />} | ||
| /> | ||
| <Route | ||
| path={SettingsWorkspacePath.Properties} | ||
| element={<PropertiesSettins />} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,26 @@ | ||
| import { AppsHeader } from '@/settings/apps/components/AppsHeader'; | ||
| import { appsSettingsColumns } from '@/settings/apps/components/table/AppsSettingsColumns'; | ||
| import { useAppsTokens } from '@/settings/apps/hooks/useAppsTokens'; | ||
| import { IApp } from '@/settings/apps/types'; | ||
| import { RecordTable } from 'erxes-ui'; | ||
|
|
||
| export const AppsSettings = () => { | ||
| const { apps, loading } = useAppsTokens(); | ||
| return ( | ||
| <> | ||
| <AppsHeader /> | ||
| </> | ||
| <section className="max-w-xl w-full mx-auto"> | ||
| <legend className="font-semibold text-lg pt-4 pb-6">Apps settings</legend> | ||
|
|
||
| <RecordTable.Provider | ||
| columns={appsSettingsColumns} | ||
| data={apps as IApp[]} | ||
| > | ||
| <RecordTable className='w-full'> | ||
| <RecordTable.Header /> | ||
| <RecordTable.Body> | ||
| <RecordTable.RowList /> | ||
| {loading && <RecordTable.RowSkeleton rows={30} />} | ||
| </RecordTable.Body> | ||
| </RecordTable> | ||
| </RecordTable.Provider> | ||
| </section> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,157 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useAddAppToken } from '@/settings/apps/hooks/useAddAppToken'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useCreateAppForm } from '@/settings/apps/hooks/useCreateAppForm'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { TCreateAppForm } from '@/settings/apps/types'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { SettingsWorkspacePath } from '@/types/paths/SettingsPath'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { IconChevronLeft, IconPlus } from '@tabler/icons-react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Button, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DatePicker, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Form, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Input, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spinner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Switch, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from 'erxes-ui'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useNavigate } from 'react-router'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { SelectUsersGroup } from 'ui-modules'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const CreateToken = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const navigate = useNavigate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { methods } = useCreateAppForm(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { control, handleSubmit, reset, watch } = methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { appsAdd, loading } = useAddAppToken(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [noExpire, allowAllPermission] = watch([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'noExpire', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'allowAllPermission', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const onSubmit = (data: TCreateAppForm) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| appsAdd({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables: data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onCompleted: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast({ title: 'Created a token' }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| navigate(SettingsWorkspacePath.Apps); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reset(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onError: (error) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast({ title: error.message, variant: 'destructive' }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+30
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Normalize payload before mutation (trim, gate fields, ISO date) Prevents sending empty userGroupId or expireDate when toggles disable them; avoids backend reject. Apply: const onSubmit = (data: TCreateAppForm) => {
- appsAdd({
- variables: data,
+ const variables = {
+ ...data,
+ name: data.name.trim(),
+ userGroupId: data.allowAllPermission
+ ? undefined
+ : data.userGroupId?.trim() || undefined,
+ expireDate: data.noExpire
+ ? undefined
+ : data.expireDate?.toISOString(),
+ };
+ appsAdd({
+ variables,
onCompleted: () => {
toast({ title: 'Created a token' });
navigate(SettingsWorkspacePath.Apps);
reset();
},
onError: (error) =>
toast({ title: error.message, variant: 'destructive' }),
});
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form {...methods}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <form | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSubmit={handleSubmit(onSubmit)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="max-w-lg w-full mx-auto flex flex-col space-y-4" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <fieldset className="grid grid-cols-2 gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <legend className="font-semibold text-lg pt-4 pb-6 flex items-center gap-x-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant={'ghost'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size={'icon'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => navigate(-1)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <IconChevronLeft /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| New token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </legend> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| control={control} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render={({ field }) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Item className="col-span-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Label>Name</Form.Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Control> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Input {...field} placeholder="Name" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Form.Control> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Message /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Form.Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="grid grid-cols-2 col-span-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| control={control} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name="allowAllPermission" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| render={({ field }) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Item className="flex flex-wrap"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Label className="w-full">Allow all</Form.Label> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Control> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Switch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checked={field.value} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onCheckedChange={field.onChange} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Form.Control> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Form.Message /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Form.Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {(allowAllPermission && null) || ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {(allowAllPermission && null) || ( | |
| {!allowAllPermission && ( |
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a simpler conditional rendering, e.g. {!noExpire && ( ... )} instead of {(noExpire && null) || ( ... )}, for better clarity.
| {(noExpire && null) || ( | |
| {!noExpire && ( |
Uh oh!
There was an error while loading. Please reload this page.