From 89b2ed389e417d3d312f589a53ee79f28b57eb83 Mon Sep 17 00:00:00 2001 From: "Bari, Haider" Date: Fri, 22 Nov 2024 14:44:08 +0000 Subject: [PATCH] shorten one of the examples Signed-off-by: Bari, Haider --- .../writing-custom-actions.md | 54 +------------------ 1 file changed, 1 insertion(+), 53 deletions(-) diff --git a/docs/features/software-templates/writing-custom-actions.md b/docs/features/software-templates/writing-custom-actions.md index 51e9968435..7e6746f566 100644 --- a/docs/features/software-templates/writing-custom-actions.md +++ b/docs/features/software-templates/writing-custom-actions.md @@ -145,20 +145,6 @@ Prefer to use `camelCase` over `snake_case` or `kebab-case` for these actions if A TemplateExample is a predefined structure that can be used to create custom actions in your software templates. It serves as a blueprint for users to understand how to use a specific action and its fields as well as to ensure consistency and standardization across different custom actions. -#### How to Use a TemplateExample - -1. Identify the custom action you want to create. -2. Refer to the TemplateExample to understand the required structure and components. -3. Fill in the necessary details in the template, such as action name, parameters, and logic. -4. Integrate the completed template into your software template to enable the custom action. - -#### Benefits - -- Serves as templates for users to understand how to configure and use the actions. -- Ensures consistency in custom actions. -- Simplifies the creation process by providing a clear structure. -- Helps in maintaining standardization across different templates. - #### Define a TemplateExample and add to your Custom Action ```ts title="With JSON Schema" @@ -183,47 +169,9 @@ export const examples: TemplateExample[] = [ }, ]; ``` - Add the example to the `createTemplateAction` under the object property `examples`: -```ts title="With JSON Schema" -import { examples } from './acmeExample.examples'; - -export const createNewFileAction = () => { - return createTemplateAction<{ contents: string; filename: string }>({ - id: 'acme:file:create', - description: 'Create an Acme file.', - examples, - schema: { - input: { - required: ['contents', 'filename'], - type: 'object', - properties: { - contents: { - type: 'string', - title: 'Contents', - description: 'The contents of the file', - }, - filename: { - type: 'string', - title: 'Filename', - description: 'The filename of the file that will be created', - }, - }, - }, - }, - async handler(ctx) { - const { signal } = ctx; - await writeFile( - resolveSafeChildPath(ctx.workspacePath, ctx.input.filename), - ctx.input.contents, - { signal }, - _ => {}, - ); - }, - }); -}; -``` +`return createTemplateAction<{ contents: string; filename: string }>({id: 'acme:file:create', description: 'Create an Acme file', examples, ...};` ### The context object