@scayle/add-on-utils
v2.1.0
Published
> A small set of utilities that can be helpful for building cloud panel add-ons
Downloads
362
Keywords
Readme
@scayle/add-on-utils
A small set of utilities that can be helpful for building cloud panel add-ons
Install
npm i --save @scayle/add-on-utils
Functions
config
The config
function can be used in the manifest file to add type-checking to the exports.
import { config } from "@scayle/add-on-utils";
export default config(function(registerApplication, registerRoutes) {
/* ... */
});
mockCustomProps
The mockCustomProps
function creates a dummy version of the add-on custom props.
If you’re using Jest and Vue test utils, you can install it in your setup script like so:
const { config } = require('@vue/test-utils');
const { AddOnPropsPlugin, mockCustomProps } = require('@scayle/add-on-utils');
config.global.plugins = [[AddOnPropsPlugin, {customProps: mockCustomProps()}]];
Other
AddOnPropsPlugin
The package also contains a Vue plugin, AddOnPropsPlugin which creates a global $addOn
object with all the add-on custom props.
It can be combined with mockCustomProps
for unit tests or standalone apps, or used with single-spa-vue to expose the actual add-on custom props.
const vueLifecycles = singleSpaVue({
/* ...*/
handleInstance(instance, props) {
instance.use(AddOnPropsPlugin, { customProps: props });
},
});
export const { bootstrap, mount, unmount } = vueLifecycles;