refactor: Rename ownerMachine to groupId in Command (#3010)
* refactor: Rename ownerMachine to groupId in Command Commands don't need to be part of a state machine. * Fix formatting
This commit is contained in:
@ -57,7 +57,7 @@ export type CommandBarMachineEvent =
|
||||
}
|
||||
| {
|
||||
type: 'Find and select command'
|
||||
data: { name: string; ownerMachine: string }
|
||||
data: { name: string; groupId: string }
|
||||
}
|
||||
| {
|
||||
type: 'Change current argument'
|
||||
@ -120,9 +120,7 @@ export const commandBarMachine = createMachine(
|
||||
context.commands.filter(
|
||||
(c) =>
|
||||
!event.data.commands.some(
|
||||
(c2) =>
|
||||
c2.name === c.name &&
|
||||
c2.ownerMachine === c.ownerMachine
|
||||
(c2) => c2.name === c.name && c2.groupId === c.groupId
|
||||
)
|
||||
),
|
||||
}),
|
||||
@ -393,9 +391,7 @@ export const commandBarMachine = createMachine(
|
||||
selectedCommand: (c, e) => {
|
||||
if (e.type !== 'Find and select command') return c.selectedCommand
|
||||
const found = c.commands.find(
|
||||
(cmd) =>
|
||||
cmd.name === e.data.name &&
|
||||
cmd.ownerMachine === e.data.ownerMachine
|
||||
(cmd) => cmd.name === e.data.name && cmd.groupId === e.data.groupId
|
||||
)
|
||||
|
||||
return !!found ? found : c.selectedCommand
|
||||
@ -514,7 +510,7 @@ export const commandBarMachine = createMachine(
|
||||
)
|
||||
|
||||
function sortCommands(a: Command, b: Command) {
|
||||
if (b.ownerMachine === 'auth') return -1
|
||||
if (a.ownerMachine === 'auth') return 1
|
||||
if (b.groupId === 'auth') return -1
|
||||
if (a.groupId === 'auth') return 1
|
||||
return a.name.localeCompare(b.name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user