forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Refactor Omnichannel EditCustomField UI (RocketChat#30786)
- Loading branch information
1 parent
a9bc9ca
commit 740d9b2
Showing
19 changed files
with
439 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 5 additions & 22 deletions
27
apps/meteor/client/views/omnichannel/customFields/CustomFieldsForm.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import { action } from '@storybook/addon-actions'; | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import NewCustomFieldsForm from './NewCustomFieldsForm'; | ||
import EditCustomFields from './EditCustomFields'; | ||
|
||
export default { | ||
title: 'Omnichannel/NewCustomFieldsForm', | ||
component: NewCustomFieldsForm, | ||
title: 'Omnichannel/CustomFields', | ||
component: EditCustomFields, | ||
decorators: [ | ||
(fn) => ( | ||
<Box maxWidth='x600' alignSelf='center' w='full' m={24}> | ||
{fn()} | ||
</Box> | ||
), | ||
], | ||
} as ComponentMeta<typeof NewCustomFieldsForm>; | ||
} as ComponentMeta<typeof EditCustomFields>; | ||
|
||
export const Default: ComponentStory<typeof NewCustomFieldsForm> = (args) => <NewCustomFieldsForm {...args} />; | ||
export const Default: ComponentStory<typeof EditCustomFields> = (args) => <EditCustomFields {...args} />; | ||
Default.storyName = 'CustomFieldsForm'; | ||
Default.args = { | ||
values: { | ||
field: '', | ||
label: '', | ||
scope: 'visitor', | ||
visibility: true, | ||
regexp: '', | ||
}, | ||
handlers: { | ||
handleField: action('handleField'), | ||
handleLabel: action('handleLabel'), | ||
handleScope: action('handleScope'), | ||
handleVisibility: action('handleVisibility'), | ||
handleRegexp: action('handleRegexp'), | ||
}, | ||
}; |
19 changes: 11 additions & 8 deletions
19
apps/meteor/client/views/omnichannel/customFields/CustomFieldsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 3 additions & 19 deletions
22
apps/meteor/client/views/omnichannel/customFields/CustomFieldsRoute.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,17 @@ | ||
import { useRouteParameter, usePermission } from '@rocket.chat/ui-contexts'; | ||
import React, { useRef, useCallback } from 'react'; | ||
import { usePermission } from '@rocket.chat/ui-contexts'; | ||
import React from 'react'; | ||
|
||
import NotAuthorizedPage from '../../notAuthorized/NotAuthorizedPage'; | ||
import CustomFieldsPage from './CustomFieldsPage'; | ||
import EditCustomFieldsPage from './EditCustomFieldsPageContainer'; | ||
import NewCustomFieldsPage from './NewCustomFieldsPage'; | ||
|
||
const CustomFieldsRoute = () => { | ||
const reload = useRef(() => null); | ||
const canViewCustomFields = usePermission('view-livechat-customfields'); | ||
const context = useRouteParameter('context'); | ||
|
||
const handleReload = useCallback(() => { | ||
reload.current(); | ||
}, [reload]); | ||
|
||
if (!canViewCustomFields) { | ||
return <NotAuthorizedPage />; | ||
} | ||
|
||
if (context === 'new') { | ||
return <NewCustomFieldsPage reload={handleReload} />; | ||
} | ||
|
||
if (context === 'edit') { | ||
return <EditCustomFieldsPage reload={handleReload} />; | ||
} | ||
|
||
return <CustomFieldsPage reload={reload} />; | ||
return <CustomFieldsPage />; | ||
}; | ||
|
||
export default CustomFieldsRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.