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:
Raphaël Bosi 2024-11-20 14:33:16 +01:00 committed by GitHub
parent c133129eb0
commit 24c0b0f873
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 35 additions and 15 deletions

View File

@ -30,6 +30,7 @@ export const WorkflowRunActionEffect = () => {
addActionMenuEntry({
type: 'workflow-run',
key: `workflow-run-${activeWorkflowVersion.id}`,
scope: 'global',
label: capitalize(activeWorkflowVersion.workflow.name),
position: index,
Icon: IconSettingsAutomation,

View File

@ -106,6 +106,7 @@ export const DeleteRecordsActionEffect = ({
if (canDelete) {
addActionMenuEntry({
type: 'standard',
scope: 'record-selection',
key: 'delete',
label: 'Delete',
position,

View File

@ -32,6 +32,7 @@ export const ExportRecordsActionEffect = ({
useEffect(() => {
addActionMenuEntry({
type: 'standard',
scope: 'record-selection',
key: 'export',
position,
label: displayedExportProgress(

View File

@ -51,6 +51,7 @@ export const ManageFavoritesActionEffect = ({
addActionMenuEntry({
type: 'standard',
scope: 'record-selection',
key: 'manage-favorites',
label: isFavorite ? 'Remove from favorites' : 'Add to favorites',
position,

View File

@ -57,6 +57,7 @@ export const WorkflowRunRecordActionEffect = ({
addActionMenuEntry({
type: 'workflow-run',
key: `workflow-run-${activeWorkflowVersion.id}`,
scope: 'record-selection',
label: capitalize(activeWorkflowVersion.workflow.name),
position: index,
Icon: IconSettingsAutomation,

View File

@ -65,19 +65,23 @@ export const RightDrawerActionMenuDropdown = () => {
}}
dropdownComponents={
<DropdownMenuItemsContainer>
{actionMenuEntries.map((item, index) => (
{actionMenuEntries
.filter(
(actionMenuEntry) => actionMenuEntry.scope === 'record-selection',
)
.map((actionMenuEntry, index) => (
<MenuItem
key={index}
LeftIcon={item.Icon}
LeftIcon={actionMenuEntry.Icon}
onClick={() => {
closeDropdown(
getRightDrawerActionMenuDropdownIdFromActionMenuId(
actionMenuId,
),
);
item.onClick?.();
actionMenuEntry.onClick?.();
}}
text={item.label}
text={actionMenuEntry.label}
/>
))}
</DropdownMenuItemsContainer>

View File

@ -48,6 +48,7 @@ const meta: Meta<typeof RecordIndexActionMenuBar> = {
map.set('delete', {
isPinned: true,
scope: 'record-selection',
type: 'standard',
key: 'delete',
label: 'Delete',

View File

@ -22,6 +22,7 @@ export const Default: Story = {
args: {
entry: {
type: 'standard',
scope: 'record-selection',
key: 'delete',
label: 'Delete',
position: 0,
@ -35,6 +36,7 @@ export const WithDangerAccent: Story = {
args: {
entry: {
type: 'standard',
scope: 'record-selection',
key: 'delete',
label: 'Delete',
position: 0,
@ -49,6 +51,7 @@ export const WithInteraction: Story = {
args: {
entry: {
type: 'standard',
scope: 'record-selection',
key: 'markAsDone',
label: 'Mark as done',
position: 0,

View File

@ -42,6 +42,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = {
map.set('delete', {
type: 'standard',
scope: 'record-selection',
key: 'delete',
label: 'Delete',
position: 0,
@ -51,6 +52,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = {
map.set('markAsDone', {
type: 'standard',
scope: 'record-selection',
key: 'markAsDone',
label: 'Mark as done',
position: 1,
@ -60,6 +62,7 @@ const meta: Meta<typeof RecordIndexActionMenuDropdown> = {
map.set('addToFavorites', {
type: 'standard',
scope: 'record-selection',
key: 'addToFavorites',
label: 'Add to favorites',
position: 2,

View File

@ -55,6 +55,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = {
map.set('addToFavorites', {
type: 'standard',
scope: 'record-selection',
key: 'addToFavorites',
label: 'Add to favorites',
position: 0,
@ -64,6 +65,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = {
map.set('export', {
type: 'standard',
scope: 'record-selection',
key: 'export',
label: 'Export',
position: 1,
@ -73,6 +75,7 @@ const meta: Meta<typeof RightDrawerActionMenuDropdown> = {
map.set('delete', {
type: 'standard',
scope: 'record-selection',
key: 'delete',
label: 'Delete',
position: 2,

View File

@ -3,6 +3,7 @@ import { IconComponent, MenuItemAccent } from 'twenty-ui';
export type ActionMenuEntry = {
type: 'standard' | 'workflow-run';
scope: 'global' | 'record-selection';
key: string;
label: string;
position: number;