mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-30 20:27:55 +00:00 
			
		
		
		
	Remove "When no records are selected" actions on record page ⌘O (#8575)
Closes #8566 - Introduce the concept of scope for an ActionMenuEntry, scope is either `global` or `record-selection`
This commit is contained in:
		| @@ -30,6 +30,7 @@ export const WorkflowRunActionEffect = () => { | |||||||
|       addActionMenuEntry({ |       addActionMenuEntry({ | ||||||
|         type: 'workflow-run', |         type: 'workflow-run', | ||||||
|         key: `workflow-run-${activeWorkflowVersion.id}`, |         key: `workflow-run-${activeWorkflowVersion.id}`, | ||||||
|  |         scope: 'global', | ||||||
|         label: capitalize(activeWorkflowVersion.workflow.name), |         label: capitalize(activeWorkflowVersion.workflow.name), | ||||||
|         position: index, |         position: index, | ||||||
|         Icon: IconSettingsAutomation, |         Icon: IconSettingsAutomation, | ||||||
|   | |||||||
| @@ -106,6 +106,7 @@ export const DeleteRecordsActionEffect = ({ | |||||||
|     if (canDelete) { |     if (canDelete) { | ||||||
|       addActionMenuEntry({ |       addActionMenuEntry({ | ||||||
|         type: 'standard', |         type: 'standard', | ||||||
|  |         scope: 'record-selection', | ||||||
|         key: 'delete', |         key: 'delete', | ||||||
|         label: 'Delete', |         label: 'Delete', | ||||||
|         position, |         position, | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ export const ExportRecordsActionEffect = ({ | |||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     addActionMenuEntry({ |     addActionMenuEntry({ | ||||||
|       type: 'standard', |       type: 'standard', | ||||||
|  |       scope: 'record-selection', | ||||||
|       key: 'export', |       key: 'export', | ||||||
|       position, |       position, | ||||||
|       label: displayedExportProgress( |       label: displayedExportProgress( | ||||||
|   | |||||||
| @@ -51,6 +51,7 @@ export const ManageFavoritesActionEffect = ({ | |||||||
|  |  | ||||||
|     addActionMenuEntry({ |     addActionMenuEntry({ | ||||||
|       type: 'standard', |       type: 'standard', | ||||||
|  |       scope: 'record-selection', | ||||||
|       key: 'manage-favorites', |       key: 'manage-favorites', | ||||||
|       label: isFavorite ? 'Remove from favorites' : 'Add to favorites', |       label: isFavorite ? 'Remove from favorites' : 'Add to favorites', | ||||||
|       position, |       position, | ||||||
|   | |||||||
| @@ -57,6 +57,7 @@ export const WorkflowRunRecordActionEffect = ({ | |||||||
|       addActionMenuEntry({ |       addActionMenuEntry({ | ||||||
|         type: 'workflow-run', |         type: 'workflow-run', | ||||||
|         key: `workflow-run-${activeWorkflowVersion.id}`, |         key: `workflow-run-${activeWorkflowVersion.id}`, | ||||||
|  |         scope: 'record-selection', | ||||||
|         label: capitalize(activeWorkflowVersion.workflow.name), |         label: capitalize(activeWorkflowVersion.workflow.name), | ||||||
|         position: index, |         position: index, | ||||||
|         Icon: IconSettingsAutomation, |         Icon: IconSettingsAutomation, | ||||||
|   | |||||||
| @@ -65,19 +65,23 @@ export const RightDrawerActionMenuDropdown = () => { | |||||||
|       }} |       }} | ||||||
|       dropdownComponents={ |       dropdownComponents={ | ||||||
|         <DropdownMenuItemsContainer> |         <DropdownMenuItemsContainer> | ||||||
|           {actionMenuEntries.map((item, index) => ( |           {actionMenuEntries | ||||||
|  |             .filter( | ||||||
|  |               (actionMenuEntry) => actionMenuEntry.scope === 'record-selection', | ||||||
|  |             ) | ||||||
|  |             .map((actionMenuEntry, index) => ( | ||||||
|               <MenuItem |               <MenuItem | ||||||
|                 key={index} |                 key={index} | ||||||
|               LeftIcon={item.Icon} |                 LeftIcon={actionMenuEntry.Icon} | ||||||
|                 onClick={() => { |                 onClick={() => { | ||||||
|                   closeDropdown( |                   closeDropdown( | ||||||
|                     getRightDrawerActionMenuDropdownIdFromActionMenuId( |                     getRightDrawerActionMenuDropdownIdFromActionMenuId( | ||||||
|                       actionMenuId, |                       actionMenuId, | ||||||
|                     ), |                     ), | ||||||
|                   ); |                   ); | ||||||
|                 item.onClick?.(); |                   actionMenuEntry.onClick?.(); | ||||||
|                 }} |                 }} | ||||||
|               text={item.label} |                 text={actionMenuEntry.label} | ||||||
|               /> |               /> | ||||||
|             ))} |             ))} | ||||||
|         </DropdownMenuItemsContainer> |         </DropdownMenuItemsContainer> | ||||||
|   | |||||||
| @@ -48,6 +48,7 @@ const meta: Meta<typeof RecordIndexActionMenuBar> = { | |||||||
|  |  | ||||||
|             map.set('delete', { |             map.set('delete', { | ||||||
|               isPinned: true, |               isPinned: true, | ||||||
|  |               scope: 'record-selection', | ||||||
|               type: 'standard', |               type: 'standard', | ||||||
|               key: 'delete', |               key: 'delete', | ||||||
|               label: 'Delete', |               label: 'Delete', | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ export const Default: Story = { | |||||||
|   args: { |   args: { | ||||||
|     entry: { |     entry: { | ||||||
|       type: 'standard', |       type: 'standard', | ||||||
|  |       scope: 'record-selection', | ||||||
|       key: 'delete', |       key: 'delete', | ||||||
|       label: 'Delete', |       label: 'Delete', | ||||||
|       position: 0, |       position: 0, | ||||||
| @@ -35,6 +36,7 @@ export const WithDangerAccent: Story = { | |||||||
|   args: { |   args: { | ||||||
|     entry: { |     entry: { | ||||||
|       type: 'standard', |       type: 'standard', | ||||||
|  |       scope: 'record-selection', | ||||||
|       key: 'delete', |       key: 'delete', | ||||||
|       label: 'Delete', |       label: 'Delete', | ||||||
|       position: 0, |       position: 0, | ||||||
| @@ -49,6 +51,7 @@ export const WithInteraction: Story = { | |||||||
|   args: { |   args: { | ||||||
|     entry: { |     entry: { | ||||||
|       type: 'standard', |       type: 'standard', | ||||||
|  |       scope: 'record-selection', | ||||||
|       key: 'markAsDone', |       key: 'markAsDone', | ||||||
|       label: 'Mark as done', |       label: 'Mark as done', | ||||||
|       position: 0, |       position: 0, | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('delete', { |           map.set('delete', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'delete', |             key: 'delete', | ||||||
|             label: 'Delete', |             label: 'Delete', | ||||||
|             position: 0, |             position: 0, | ||||||
| @@ -51,6 +52,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('markAsDone', { |           map.set('markAsDone', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'markAsDone', |             key: 'markAsDone', | ||||||
|             label: 'Mark as done', |             label: 'Mark as done', | ||||||
|             position: 1, |             position: 1, | ||||||
| @@ -60,6 +62,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('addToFavorites', { |           map.set('addToFavorites', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'addToFavorites', |             key: 'addToFavorites', | ||||||
|             label: 'Add to favorites', |             label: 'Add to favorites', | ||||||
|             position: 2, |             position: 2, | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('addToFavorites', { |           map.set('addToFavorites', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'addToFavorites', |             key: 'addToFavorites', | ||||||
|             label: 'Add to favorites', |             label: 'Add to favorites', | ||||||
|             position: 0, |             position: 0, | ||||||
| @@ -64,6 +65,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('export', { |           map.set('export', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'export', |             key: 'export', | ||||||
|             label: 'Export', |             label: 'Export', | ||||||
|             position: 1, |             position: 1, | ||||||
| @@ -73,6 +75,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = { | |||||||
|  |  | ||||||
|           map.set('delete', { |           map.set('delete', { | ||||||
|             type: 'standard', |             type: 'standard', | ||||||
|  |             scope: 'record-selection', | ||||||
|             key: 'delete', |             key: 'delete', | ||||||
|             label: 'Delete', |             label: 'Delete', | ||||||
|             position: 2, |             position: 2, | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ import { IconComponent, MenuItemAccent } from 'twenty-ui'; | |||||||
|  |  | ||||||
| export type ActionMenuEntry = { | export type ActionMenuEntry = { | ||||||
|   type: 'standard' | 'workflow-run'; |   type: 'standard' | 'workflow-run'; | ||||||
|  |   scope: 'global' | 'record-selection'; | ||||||
|   key: string; |   key: string; | ||||||
|   label: string; |   label: string; | ||||||
|   position: number; |   position: number; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Raphaël Bosi
					Raphaël Bosi