RobinSkill Custom Components
What is a Custom Component
Robin's library components and layout editor lets users point-and-click to build designs for the Robin application. In some scenarios, users might want a custom design for the Robin application that is not part of the standard layout editor. In such scenarios, users can implement a custom component using robin-custom-component-template. The custom component enables control to create a complex UI design for the Robin application.
The custom component has access to all fields/data of the current task in context while the standard library components work with individual fields in the task.
Automation Hero advises trying to implement UIs using Robin's standard library components as they are robust and are implemented to work different types of data. All library components come with features like read-only, data-type support, and data-validation. Automation Hero will continue to build more components to the standard library and will be adding more features to existing components. Library components provide the guarantee that the Robin application is always compatible with future versions of Hero Platform_. Custom components may require updating the component's implementation.
- You have access to the Hero Platform_ application and can create Robin Skills.
- You are familiar with the structure of Robin Skills and all data fields in each skill.
- You have access to robin-custom-component-template. (Access required, speak to your customer service representative or email firstname.lastname@example.org)
How to Build a Custom Component
- Fork/clone the repository.
- Set up a Robin Skill layout structure in `src/mock/layout.json` to match with the Robin Skill in Hero Platform_.
- Set up mock data to represent individual skill items to be processed in`src/mock/tuples.json`
- Implement your custom component in `src/components` folder. You can use
`npm start`to verify your component with mock data in development mode.
- Register your component using
`registerComponent`inside `src/index.tsx` file
`npm run build`to bundle and package the component to a deliverable artifact.
- The artifact then can be imported in the Robin Skill wizard in Hero Platform_
Set Up `layout.json`
Before starting to implement a custom component, you need to edit `src/mock/layout.json` to match with the Robin Skill layout created in Hero Platform_. If you do not have access to Hero Platform_ or your Robin Skill does not use any library components, you can configure `layout.json` as follows:
This is will make your Robin application show only `<your-component-tag>` on the skill details page.
`<your-component-tag>` should match with the name in `package.json`.
Once the layout is set up, you need to set up the data structure for your skill. This is called `tupleDefinition`. Define the fields that will be available in the Robin Skill under `tupleDefinition.fieldDefinitions`.You can configure `columnStart`, `columnEnd`, `rowStart` and `rowEnd` according to how big your component should be displayed in the Robin application. The minimum values for `columnStart` and `columnEnd` are 1 and the maximum value is 4. There is no maximum limit on `rowStart' and `rowEnd`.
Here is an example:
There will be additional details other than `name` for each field which do not need to be configured. The assumption is that you know the data type of each field in the `fieldDefinitions`.
Set Up `tuples.json`
After the layout and tuple definition have been set up, you will need to set up some mock data that can be displayed when starting to implement your component.
Assuming above the configured `fieldDefinitions`, you can create mock data like so:
Implementing the Custom Component
- Create a new file under the `src/component` folder for your component.
- Make your component class extend `BaseCustomComponent`. You can see the props you will receive from Robin.
- Every field change inside your component should trigger the `props.onChange` event.
Checkout `src/BaseCustomComponent` and `src/TestComponent'.
Do no update the `src/BaseCustomComponent` file. This interface defines input and events for your component.
- Once you begin implementing your component, verify your code changes in the browser with the
`npm start`command. This starts the webpack-server on `` and live-reloads your changes. Your component will be rendered using the mock data in `src/mock/tuples.json`.
Registering Custom Component
Once the component has been implemented, register your component to the Robin application. You can do so in the `src/index.tsx` file.
Replace `registerComponent(TestComponent)` on line 15 with your component name.
Before bundling your component into a production-ready artifact. Change the name of the component and version in `package.json`. The name in `package.json` is used in Hero Platform_'s layout editor.
Create a production-ready bundle for your component by running the
`npm run build` command. This command generates a zip file under the `dist/` folder to upload to Hero Platform_.
If an error is found after running a custom component, an error message is displayed on the Robin task details pages for that Robin skill.
A skill with a non functioning custom component does not allow access to work on tasks for that skill. Other Robin skills are unaffected.