Skip to main content

Nuxt Plugins

Location​

The definitions of plugins reside in shell/plugins. Plugins added to shell/initialize/index.js will be initialized at the start of the app rendering.

Notes​

This file was generated by nuxt and will soon be redefined by hand. It's safe to add new plugins to this file.

Pattern​

Define the store in a file that resides within shell/plugins. Then add the plugins import and execution to shell/initialize/index.js.

shell/plugins/version.js

/**
* Fetch version metadata from backend /rancherversion API and store it
*
* This metadata does not change for an installation of Rancher
*/

import { setVersionData } from '@shell/config/version';

export default async function({ store }) {
try {
const response = await store.dispatch('rancher/request', {
url: '/rancherversion',
method: 'get',
redirectUnauthorized: false
});

setVersionData(response);
} catch (e) {
console.warn('Failed to fetch Rancher version metadata', e); // eslint-disable-line no-console
}
}

shell/initialize/index.js

...
import version from '../plugins/version';
...
if (process.client && typeof version === 'function') {
await version(app.context, inject);
}
...

/**

  • Do we need this file??????? */