-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
8414 add records selection context inside the command menu #8610
Merged
charlesBochet
merged 17 commits into
main
from
8414-add-records-selection-context-inside-the-command-menu
Nov 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0d54ca4
extract the top bar in a new component
bosiraphael 2a0f5fb
create context chip for command menu
bosiraphael efdb661
Add seleted records avatars
bosiraphael cc460d5
refactoring, bug fixes and create CommandMenuCommandsEffect
bosiraphael 4ca34a8
reorder records in chips
bosiraphael e5b9fb2
fix background color
bosiraphael 1e3032a
fixes
bosiraphael e6195c4
fix hotkey scopes
bosiraphael e1415b6
Merge branch 'main' into 8414-add-records-selection-context-inside-th…
bosiraphael 8c05830
show objectRecordIdentifier name when only one record is selected
bosiraphael 1ba43bb
improve command menu actions ordering
bosiraphael b73c806
fix stories
bosiraphael 1b2302e
fix tests
bosiraphael 4053c56
fix text color in dark mode
bosiraphael 6be2b15
fix command menu height and chip sizing
bosiraphael 32fb2da
use standard object icon if available in chip
bosiraphael 281e5ec
fix delete records
bosiraphael 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
refactoring, bug fixes and create CommandMenuCommandsEffect
- Loading branch information
commit cc460d51fe56eed1d27a74d771b16dadfd7e4419
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
29 changes: 29 additions & 0 deletions
29
packages/twenty-front/src/modules/command-menu/components/CommandMenuCommandsEffect.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,29 @@ | ||
import { actionMenuEntriesComponentSelector } from '@/action-menu/states/actionMenuEntriesComponentSelector'; | ||
import { commandMenuCommandsState } from '@/command-menu/states/commandMenuCommandsState'; | ||
import { computeCommandMenuCommands } from '@/command-menu/utils/computeCommandMenuCommands'; | ||
import { mainContextStoreComponentInstanceIdState } from '@/context-store/states/mainContextStoreComponentInstanceId'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { useEffect } from 'react'; | ||
import { useRecoilValue, useSetRecoilState } from 'recoil'; | ||
import { isDefined } from 'twenty-ui'; | ||
|
||
export const CommandMenuCommandsEffect = () => { | ||
const mainContextStoreComponentInstanceId = useRecoilValue( | ||
mainContextStoreComponentInstanceIdState, | ||
); | ||
|
||
const actionMenuEntries = useRecoilComponentValueV2( | ||
actionMenuEntriesComponentSelector, | ||
mainContextStoreComponentInstanceId, | ||
); | ||
|
||
const setCommands = useSetRecoilState(commandMenuCommandsState); | ||
|
||
useEffect(() => { | ||
if (isDefined(mainContextStoreComponentInstanceId)) { | ||
setCommands(computeCommandMenuCommands(actionMenuEntries)); | ||
} | ||
}, [mainContextStoreComponentInstanceId, actionMenuEntries, setCommands]); | ||
|
||
return null; | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
packages/twenty-front/src/modules/command-menu/utils/computeCommandMenuCommands.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ActionMenuEntry } from '@/action-menu/types/ActionMenuEntry'; | ||
import { COMMAND_MENU_COMMANDS } from '@/command-menu/constants/CommandMenuCommands'; | ||
import { CommandType } from '@/command-menu/types/Command'; | ||
|
||
export const computeCommandMenuCommands = ( | ||
actionMenuEntries: ActionMenuEntry[], | ||
) => { | ||
const commands = Object.values(COMMAND_MENU_COMMANDS); | ||
|
||
const actionCommands = actionMenuEntries | ||
?.filter((actionMenuEntry) => actionMenuEntry.type === 'standard') | ||
?.map((actionMenuEntry) => ({ | ||
id: actionMenuEntry.key, | ||
label: actionMenuEntry.label, | ||
Icon: actionMenuEntry.Icon, | ||
onCommandClick: actionMenuEntry.onClick, | ||
type: CommandType.StandardAction, | ||
})); | ||
|
||
const workflowRunCommands = actionMenuEntries | ||
?.filter((actionMenuEntry) => actionMenuEntry.type === 'workflow-run') | ||
?.map((actionMenuEntry) => ({ | ||
id: actionMenuEntry.key, | ||
label: actionMenuEntry.label, | ||
Icon: actionMenuEntry.Icon, | ||
onCommandClick: actionMenuEntry.onClick, | ||
type: CommandType.WorkflowRun, | ||
})); | ||
|
||
return [...commands, ...actionCommands, ...workflowRunCommands]; | ||
}; |
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
6 changes: 2 additions & 4 deletions
6
...ages/twenty-front/src/modules/context-store/states/mainContextStoreComponentInstanceId.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { createState } from 'twenty-ui'; | ||
|
||
export const mainContextStoreComponentInstanceIdState = createState< | ||
string | null | ||
>({ | ||
export const mainContextStoreComponentInstanceIdState = createState<string>({ | ||
key: 'mainContextStoreComponentInstanceIdState', | ||
defaultValue: null, | ||
defaultValue: 'app', | ||
}); |
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
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.
make a constant