diff --git a/.vscode/settings.json b/.vscode/settings.json index c8fb851..eef4040 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,12 +2,7 @@ "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "editor.codeActionsOnSave": { - "source.fixAll": false, - "source.fixAll.eslint": true - }, "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true, "eslint.enable": true, "eslint.rules.customizations": [ { diff --git a/package.json b/package.json index 8e99d7b..2d01683 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "clean": "./node_modules/@rancher/shell/scripts/clean", "build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh", "serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs", - "publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish" + "publish-pkgs": "./node_modules/@rancher/shell/scripts/extension/publish", + "parse-tag-name": "./node_modules/@rancher/shell/scripts/extension/parse-tag-name" }, "devDependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", @@ -28,4 +29,4 @@ "@types/lodash": "4.14.184", "css-loader": "6.7.3" } -} +} \ No newline at end of file diff --git a/pkg/app-launcher/config/app-launcher.ts b/pkg/app-launcher/config/app-launcher.ts index 6538e5d..765417b 100644 --- a/pkg/app-launcher/config/app-launcher.ts +++ b/pkg/app-launcher/config/app-launcher.ts @@ -1 +1,2 @@ export const PRODUCT_NAME = 'app-launcher'; +export const BLANK_CLUSTER = '_'; \ No newline at end of file diff --git a/pkg/app-launcher/index.ts b/pkg/app-launcher/index.ts index f97539e..a1a3d8f 100644 --- a/pkg/app-launcher/index.ts +++ b/pkg/app-launcher/index.ts @@ -1,6 +1,6 @@ import { importTypes } from '@rancher/auto-import'; import { IPlugin } from '@shell/core/types'; -import routes from './routing/extension-routing'; +import extensionRouting from './routing/extension-routing'; // Init the package export default function (plugin: IPlugin) { @@ -11,5 +11,5 @@ export default function (plugin: IPlugin) { // Load a product plugin.addProduct(require('./product')); // Add Vue routes - plugin.addRoutes(routes); + plugin.addRoutes(extensionRouting); } diff --git a/pkg/app-launcher/pages/app-launcher.vue b/pkg/app-launcher/pages/index.vue similarity index 58% rename from pkg/app-launcher/pages/app-launcher.vue rename to pkg/app-launcher/pages/index.vue index ade401c..46eaa21 100644 --- a/pkg/app-launcher/pages/app-launcher.vue +++ b/pkg/app-launcher/pages/index.vue @@ -14,27 +14,40 @@ export default { loading: true, }; }, - async fetch() { - const allClusters = await this.$store.dispatch(`management/findAll`, { - type: MANAGEMENT.CLUSTER, - }); - - this.servicesByCluster = await Promise.all( - allClusters - .filter((cluster) => cluster.isReady) - .map(async (cluster) => ({ - name: `${this.$store.getters['i18n/t']('nav.group.cluster')} ${ - cluster.spec.displayName - }`, - id: cluster.id, - services: ( - await this.$store.dispatch('cluster/request', { - url: `/k8s/clusters/${cluster.id}/v1/services`, - }) - ).data, - })) - ); - this.loading = false; + async mounted() { + console.log('mounted'); + try { + const allClusters = await this.getClusters(); + this.servicesByCluster = await this.getServicesByCluster(allClusters); + } catch (error) { + console.error('Error fetching clusters', error); + } finally{ + this.loading = false; + }; + }, + methods: { + async getClusters() { + return await this.$store.dispatch(`management/findAll`, { + type: MANAGEMENT.CLUSTER, + }); + }, + async getServicesByCluster(allClusters) { + return await Promise.all( + allClusters + .filter((cluster) => cluster.isReady) + .map(async (cluster) => ({ + name: `${this.$store.getters['i18n/t']('nav.group.cluster')} ${ + cluster.spec.displayName + }`, + id: cluster.id, + services: ( + await this.$store.dispatch('cluster/request', { + url: `/k8s/clusters/${cluster.id}/v1/services`, + }) + ).data, + })) + ); + }, }, layout: 'plain', }; @@ -43,14 +56,8 @@ export default {