adamant-kite-43734
10/08/2023, 2:37 AMbusy-ability-54059
10/09/2023, 2:14 PMindex.ts
import { importTypes } from '@rancher/auto-import';
import { IPlugin } from '@shell/core/types';
import routing from './routing';
// Init the package
export default function(plugin: IPlugin) {
// Auto-import model, detail, edit from the folders
importTypes(plugin);
// Provide extension metadata from package.json
plugin.metadata = require('./package.json');
// Load a product
plugin.addProduct(require('./product'));
// Add Vue Routes
plugin.addRoutes(routing);
}
product.ts
(for the addProduct
method in index.ts
)
import { IPlugin } from '@shell/core/types';
export function init($plugin: IPlugin, store: any) {
const YOUR_PRODUCT_NAME = 'myProductName';
const BLANK_CLUSTER = '_';
const { product } = $plugin.DSL(store, YOUR_PRODUCT_NAME);
product({
icon: 'gear',
inStore: 'management',
weight: 100,
to: {
name: `${ YOUR_PRODUCT_NAME }-c-cluster`,
path: `/${ YOUR_PRODUCT_NAME }/c/:cluster/dashboard`,
params: {
product: YOUR_PRODUCT_NAME,
cluster: BLANK_CLUSTER,
pkg: YOUR_PRODUCT_NAME
}
}
});
}
routing.js
(for the addRoutes
method in index.ts
)
import Dashboard from './pages/index.vue';
const BLANK_CLUSTER = '_';
const YOUR_PRODUCT_NAME = 'myProductName';
const routes = [
{
name: `${ YOUR_PRODUCT_NAME }-c-cluster`,
path: `/${ YOUR_PRODUCT_NAME }/c/:cluster`,
component: Dashboard,
meta: {
product: YOUR_PRODUCT_NAME,
cluster: BLANK_CLUSTER,
pkg: YOUR_PRODUCT_NAME
}
}
];
export default routes;
on routing.js
note that we are importing Dashboard. It’s just a basic Vue page. You’ll need to create the pages
folder and there a file called index.vue
.
That should do it.
We are going to update the docs https://rancher.github.io/dashboard/extensions/extensions-getting-started as soon as possible 🙏abundant-account-84261
10/10/2023, 1:04 AMabundant-account-84261
10/10/2023, 1:07 AMbuild-pkg
and serve-pkgs
?abundant-account-84261
10/10/2023, 3:10 AMbusy-ability-54059
10/10/2023, 1:25 PMbusy-ability-54059
10/10/2023, 1:27 PMabundant-account-84261
10/10/2023, 5:44 PMbuild-pkg
and serve-pkgs
commands available. I am guessing that may be because of vue
not being installed. Even though it may be obvious for a seasoned developer may be a good idea to include that in the pre-reqs?abundant-account-84261
10/10/2023, 5:49 PMEXCLUDES_PKG='test'
option in the .env
file and even doing source .env
to include the env vars, I am seeing that the UI still has the pkg as BUILT-IN
and the extension link available in the left side menu (and working) as well.
The docs says put the .env
file in the test-app
folder. Seems like a typo to me as there is no such folder referred to earlier. I put in the my-app
(did not work). Then put in also in the pkg
folders and it still did not work.
My goal is to be able to get to the point of creating a helm chart for my extension (as the documentation also directs towards) that can be installed/loaded on any rancher UI.abundant-account-84261
10/10/2023, 5:50 PMbusy-ability-54059
10/11/2023, 9:14 AMvue.config.js
file in the root of my-app
and add to the excludes
array there the name of pkg: ['test']
. Restart your dev app again.
The next step would be to do a Developer Load. Remember to enable the feature on the UI side + run on your terminal yarn serve-pkgs
. This will spin up a web server to serve whatever is in dist-pkg
(output of build-pkg
).
Use the URL of the yarn serve-pkgs
in the developer load URL box in the UI and your built extension should load.
Will update the docs. Thanks 🙏busy-ability-54059
10/13/2023, 11:19 AM