Hide the Fillet command from the command palette (#4550)
* Add the ability to hide a command based on its availability status * Hide the Fillet command from the command bar unless in dev mode
This commit is contained in:
@ -279,6 +279,7 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
|||||||
Fillet: {
|
Fillet: {
|
||||||
description: 'Fillet edge',
|
description: 'Fillet edge',
|
||||||
icon: 'fillet',
|
icon: 'fillet',
|
||||||
|
status: 'development',
|
||||||
needsReview: true,
|
needsReview: true,
|
||||||
args: {
|
args: {
|
||||||
selection: {
|
selection: {
|
||||||
|
@ -96,6 +96,7 @@ export type CommandConfig<
|
|||||||
'name' | 'groupId' | 'onSubmit' | 'onCancel' | 'args' | 'needsReview'
|
'name' | 'groupId' | 'onSubmit' | 'onCancel' | 'args' | 'needsReview'
|
||||||
> & {
|
> & {
|
||||||
needsReview?: true
|
needsReview?: true
|
||||||
|
status?: 'active' | 'development' | 'inactive'
|
||||||
args?: {
|
args?: {
|
||||||
[ArgName in keyof CommandSchema]: CommandArgumentConfig<
|
[ArgName in keyof CommandSchema]: CommandArgumentConfig<
|
||||||
CommandSchema[ArgName],
|
CommandSchema[ArgName],
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
StateMachineCommandSetConfig,
|
StateMachineCommandSetConfig,
|
||||||
StateMachineCommandSetSchema,
|
StateMachineCommandSetSchema,
|
||||||
} from './commandTypes'
|
} from './commandTypes'
|
||||||
|
import { DEV } from 'env'
|
||||||
|
|
||||||
interface CreateMachineCommandProps<
|
interface CreateMachineCommandProps<
|
||||||
T extends AnyStateMachine,
|
T extends AnyStateMachine,
|
||||||
@ -48,6 +49,7 @@ export function createMachineCommand<
|
|||||||
const commandConfig = commandBarConfig && commandBarConfig[type]
|
const commandConfig = commandBarConfig && commandBarConfig[type]
|
||||||
|
|
||||||
// There may be no command config for this event type,
|
// There may be no command config for this event type,
|
||||||
|
// or the command may be inactive or hidden,
|
||||||
// or there may be multiple commands to create.
|
// or there may be multiple commands to create.
|
||||||
if (!commandConfig) {
|
if (!commandConfig) {
|
||||||
return null
|
return null
|
||||||
@ -72,13 +74,17 @@ export function createMachineCommand<
|
|||||||
.filter((c) => c !== null) as Command<T, typeof type, S[typeof type]>[]
|
.filter((c) => c !== null) as Command<T, typeof type, S[typeof type]>[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide commands based on platform by returning `null`
|
// Hide commands based on platform or development status by returning `null`
|
||||||
// so the consumer can filter them out
|
// so the consumer can filter them out
|
||||||
if ('hide' in commandConfig) {
|
if ('hide' in commandConfig) {
|
||||||
const { hide } = commandConfig
|
const { hide } = commandConfig
|
||||||
if (hide === 'both') return null
|
if (hide === 'both') return null
|
||||||
else if (hide === 'desktop' && isDesktop()) return null
|
else if (hide === 'desktop' && isDesktop()) return null
|
||||||
else if (hide === 'web' && !isDesktop()) return null
|
else if (hide === 'web' && !isDesktop()) return null
|
||||||
|
} else if ('status' in commandConfig) {
|
||||||
|
const { status } = commandConfig
|
||||||
|
if (status === 'inactive') return null
|
||||||
|
if (status === 'development' && !DEV) return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const icon = ('icon' in commandConfig && commandConfig.icon) || undefined
|
const icon = ('icon' in commandConfig && commandConfig.icon) || undefined
|
||||||
|
Reference in New Issue
Block a user