bd03073b6d
## Description
- Adds support for declaring command menu items directly within
`defineFrontComponent` via an optional command config property
- Introduces a new `CommandMenuItemManifest` type in twenty-shared and
wires it through the manifest build pipeline
## Example Of usage
```tsx
import { defineFrontComponent } from "twenty-sdk";
const TestAction = () => {
return <div>Test Action</div>;
};
export default defineFrontComponent({
universalIdentifier: "6c289461-0007-4a62-a99f-69e5c11a4ce7",
name: "test-action",
description: "Test Action",
component: TestAction,
command: {
universalIdentifier: "c07df864-495f-46f3-9f5b-9d3ce2589e9b",
label: "Run My Action",
icon: "IconBolt",
isPinned: false,
},
});
```
## Video QA
https://github.com/user-attachments/assets/f910fc6a-44a9-45d1-87c5-f0ce64bb3878
37 lines
935 B
TypeScript
37 lines
935 B
TypeScript
import { createValidationResult } from '@/sdk';
|
|
import type { DefineEntity } from '@/sdk/common/types/define-entity.type';
|
|
import { type FrontComponentConfig } from '@/sdk/front-component-config';
|
|
|
|
export const defineFrontComponent: DefineEntity<FrontComponentConfig> = (
|
|
config,
|
|
) => {
|
|
const errors = [];
|
|
|
|
if (!config.universalIdentifier) {
|
|
errors.push('Front component must have a universalIdentifier');
|
|
}
|
|
|
|
if (!config.component) {
|
|
errors.push('Front component must have a component');
|
|
}
|
|
|
|
if (typeof config.component !== 'function') {
|
|
errors.push('Front component component must be a React component');
|
|
}
|
|
|
|
if (config.command) {
|
|
if (!config.command.universalIdentifier) {
|
|
errors.push('Command must have a universalIdentifier');
|
|
}
|
|
|
|
if (!config.command.label) {
|
|
errors.push('Command must have a label');
|
|
}
|
|
}
|
|
|
|
return createValidationResult({
|
|
config,
|
|
errors,
|
|
});
|
|
};
|