-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[WIP]: Blocklist V2 #9435
Closed
Closed
[WIP]: Blocklist V2 #9435
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7c60e09
feat(frontend): update the UI for the blocklistV2
pacyL2K19 c5b191f
feat(backend): update the datamodel for the blocklist, connect the UI…
pacyL2K19 bddde74
update review feedback
pacyL2K19 5bb57c6
minor updates
pacyL2K19 166f7ca
chore: refactor the blocklist component folder
pacyL2K19 f763348
chore: add stories to the new components
pacyL2K19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/twenty-front/src/modules/accounts/types/BlocklistItem.ts
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
56 changes: 0 additions & 56 deletions
56
...wenty-front/src/modules/settings/accounts/components/SettingsAccountsBlocklistSection.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...les/settings/accounts/components/__stories__/SettingsAccountsBlocklistSection.stories.tsx
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...s/accounts/components/blocklist/__stories__/SettingAccountsBlocklistContainer.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import { mockedBlocklist } from '@/settings/accounts/components/blocklist/__stories__/mockedBlocklist'; | ||
import { SettingsAccountsBlocklistContactRow } from '@/settings/accounts/components/blocklist/components/SettingAccountsBlocklistContactRow'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
|
||
export default { | ||
title: 'Settings/Accounts/BlocklistContactRow', | ||
component: SettingsAccountsBlocklistContactRow, | ||
argTypes: { | ||
item: { | ||
control: 'object', | ||
description: 'Blocklist item data to display', | ||
}, | ||
}, | ||
} as Meta<typeof SettingsAccountsBlocklistContactRow>; | ||
|
||
const Template: StoryFn<typeof SettingsAccountsBlocklistContactRow> = ( | ||
args, | ||
) => <SettingsAccountsBlocklistContactRow {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
item: undefined, | ||
}; | ||
|
||
export const WithItem = Template.bind({}); | ||
WithItem.args = { | ||
item: mockedBlocklist[0], | ||
}; | ||
|
||
export const UpdatingItem = Template.bind({}); | ||
UpdatingItem.args = { | ||
item: mockedBlocklist[2], | ||
}; |
86 changes: 86 additions & 0 deletions
86
...ts/components/blocklist/__stories__/SettingAccountsBlocklistDropdownComponent.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Decorator, Meta, StoryObj } from '@storybook/react'; | ||
import { expect, fn, userEvent, within } from '@storybook/test'; | ||
|
||
import { SettingsAccountsBlocklistDropdownComponent } from '@/settings/accounts/components/blocklist/components/SettingAccountsBlocklistDropdownComponent'; | ||
import { BLOCKLIST_SCOPE_DROPDOWN_ITEMS } from '@/settings/accounts/constants/BlocklistScopeDropdownItems'; | ||
|
||
const handleMultiSelectChangeJestFn = fn(); | ||
const setDropdownSearchTextJestFn = fn(); | ||
|
||
const ClearMocksDecorator: Decorator = (Story, context) => { | ||
if (context.parameters.clearMocks === true) { | ||
handleMultiSelectChangeJestFn.mockClear(); | ||
setDropdownSearchTextJestFn.mockClear(); | ||
} | ||
return <Story />; | ||
}; | ||
|
||
const meta: Meta<typeof SettingsAccountsBlocklistDropdownComponent> = { | ||
title: | ||
'Modules/Settings/Accounts/Blocklist/SettingsAccountsBlocklistDropdownComponent', | ||
component: SettingsAccountsBlocklistDropdownComponent, | ||
decorators: [ClearMocksDecorator], | ||
args: { | ||
handleMultiSelectChange: handleMultiSelectChangeJestFn, | ||
setDropdownSearchText: setDropdownSearchTextJestFn, | ||
dropdownSearchText: '', | ||
selectedBlocklistScopes: [], | ||
}, | ||
argTypes: { | ||
handleMultiSelectChange: { control: false }, | ||
setDropdownSearchText: { control: false }, | ||
}, | ||
parameters: { | ||
clearMocks: true, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof SettingsAccountsBlocklistDropdownComponent>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const SearchAndSelect: Story = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
expect(handleMultiSelectChangeJestFn).toHaveBeenCalledTimes(0); | ||
expect(setDropdownSearchTextJestFn).toHaveBeenCalledTimes(0); | ||
|
||
const searchInput = canvas.getByPlaceholderText('Search'); | ||
await userEvent.type(searchInput, 'domain'); | ||
expect(setDropdownSearchTextJestFn).toHaveBeenCalledWith('domain'); | ||
|
||
const firstItem = canvas.getByText(BLOCKLIST_SCOPE_DROPDOWN_ITEMS[0].label); | ||
await userEvent.click(firstItem); | ||
expect(handleMultiSelectChangeJestFn).toHaveBeenCalledWith( | ||
BLOCKLIST_SCOPE_DROPDOWN_ITEMS[0].id, | ||
); | ||
}, | ||
}; | ||
|
||
export const SelectMultipleItems: Story = { | ||
args: { | ||
selectedBlocklistScopes: [BLOCKLIST_SCOPE_DROPDOWN_ITEMS[0].id], | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
expect(handleMultiSelectChangeJestFn).toHaveBeenCalledTimes(0); | ||
|
||
const secondItem = canvas.getByText( | ||
BLOCKLIST_SCOPE_DROPDOWN_ITEMS[1].label, | ||
); | ||
await userEvent.click(secondItem); | ||
expect(handleMultiSelectChangeJestFn).toHaveBeenCalledWith( | ||
BLOCKLIST_SCOPE_DROPDOWN_ITEMS[1].id, | ||
); | ||
|
||
const thirdItem = canvas.getByText(BLOCKLIST_SCOPE_DROPDOWN_ITEMS[2].label); | ||
await userEvent.click(thirdItem); | ||
expect(handleMultiSelectChangeJestFn).toHaveBeenCalledWith( | ||
BLOCKLIST_SCOPE_DROPDOWN_ITEMS[2].id, | ||
); | ||
}, | ||
}; |
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
77 changes: 77 additions & 0 deletions
77
...gs/accounts/components/blocklist/__stories__/SettingsAccountsBlocklistSection.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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; | ||
import { mockedBlocklist } from '@/settings/accounts/components/blocklist/__stories__/mockedBlocklist'; | ||
import { SettingsAccountsBlocklistSection } from '@/settings/accounts/components/blocklist/components/SettingsAccountsBlocklistSection'; | ||
import { Decorator, Meta, StoryObj } from '@storybook/react'; | ||
import { expect, within } from '@storybook/test'; | ||
import { ComponentDecorator } from 'twenty-ui'; | ||
|
||
jest.mock('@/object-record/hooks/useFindManyRecords', () => ({ | ||
useFindManyRecords: jest.fn(), | ||
})); | ||
|
||
const mockUseFindManyRecords = useFindManyRecords as jest.Mock; | ||
|
||
const ClearMocksDecorator: Decorator = (Story, context) => { | ||
if (Boolean(context.parameters.clearMocks) === true) { | ||
mockUseFindManyRecords.mockClear(); | ||
} | ||
return <Story />; | ||
}; | ||
|
||
const meta: Meta<typeof SettingsAccountsBlocklistSection> = { | ||
title: 'Modules/Settings/Accounts/Blocklist/SettingsAccountsBlocklistSection', | ||
component: SettingsAccountsBlocklistSection, | ||
decorators: [ComponentDecorator, ClearMocksDecorator], | ||
parameters: { | ||
clearMocks: true, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof SettingsAccountsBlocklistSection>; | ||
|
||
export const Default: Story = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
const title = canvas.getByText('Blocklist'); | ||
expect(title).toBeInTheDocument(); | ||
|
||
const description = canvas.getByText( | ||
'Exclude the following people and domains from my email sync', | ||
); | ||
expect(description).toBeInTheDocument(); | ||
}, | ||
}; | ||
|
||
export const WithBlocklistItems: Story = { | ||
parameters: { | ||
clearMocks: false, | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
mockUseFindManyRecords.mockReturnValue({ records: mockedBlocklist }); | ||
|
||
mockedBlocklist.forEach((item) => { | ||
const blocklistItem = canvas.getByText(item.handle); | ||
expect(blocklistItem).toBeInTheDocument(); | ||
}); | ||
}, | ||
}; | ||
|
||
export const EmptyBlocklist: Story = { | ||
parameters: { | ||
clearMocks: false, | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
|
||
mockUseFindManyRecords.mockReturnValue({ records: [] }); | ||
|
||
mockedBlocklist.forEach((item) => { | ||
const blocklistItem = canvas.queryByText(item.handle); | ||
expect(blocklistItem).not.toBeInTheDocument(); | ||
}); | ||
}, | ||
}; |
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
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
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,6 +1,7 @@ | ||
import { DateTime } from 'luxon'; | ||
|
||
import { BlocklistItem } from '@/accounts/types/BlocklistItem'; | ||
import { BlocklistItemScope } from '@/settings/accounts/types/BlocklistItemScope'; | ||
|
||
export const mockedBlocklist: BlocklistItem[] = [ | ||
{ | ||
|
@@ -22,13 +23,19 @@ export const mockedBlocklist: BlocklistItem[] = [ | |
handle: '[email protected]', | ||
workspaceMemberId: '1', | ||
createdAt: DateTime.now().minus({ days: 3 }).toISO() ?? '', | ||
scopes: [BlocklistItemScope.CC], | ||
__typename: 'BlocklistItem', | ||
}, | ||
{ | ||
id: '4', | ||
handle: '@twenty.com', | ||
workspaceMemberId: '1', | ||
createdAt: DateTime.now().minus({ days: 4 }).toISO() ?? '', | ||
scopes: [ | ||
BlocklistItemScope.BCC, | ||
BlocklistItemScope.CC, | ||
BlocklistItemScope.FROM_TO, | ||
], | ||
__typename: 'BlocklistItem', | ||
}, | ||
]; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
style: Import from @/accounts/types instead of @/settings/accounts/types to maintain consistent import paths with the rest of the codebase