diff --git a/.gitignore b/.gitignore index f6fd20f..de04b9a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ coverage # IDE - VSCode .vscode/* -!.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json diff --git a/.vscode/settings.json b/.vscode/settings.json index eef4040..fafc223 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,14 +1,5 @@ { "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "vscode.typescript-language-features" }, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "eslint.enable": true, - "eslint.rules.customizations": [ - { - "rule": "*", - "severity": "warn" - } - ], - "eslint.useESLintClass": true } diff --git a/package.json b/package.json index 2d01683..5632c62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "krum-rancher-extensions-demo", - "version": "0.1.4", + "version": "0.1.5", "private": true, "engines": { "node": "16.19.1" diff --git a/pkg/app-launcher/components/AppLauncherCard.vue b/pkg/app-launcher/components/AppLauncherCard.vue index fb05f5d..a908565 100644 --- a/pkg/app-launcher/components/AppLauncherCard.vue +++ b/pkg/app-launcher/components/AppLauncherCard.vue @@ -8,45 +8,15 @@ export default { Card, ButtonDropDown, }, - computed: { - endpoints() { - return ( - this.service?.spec.ports?.map((port) => { - const endpoint = `${ - isMaybeSecure(port.port, port.protocol) ? 'https' : 'http' - }:${this.service.metadata.name}:${port.port}`; - - return { - label: `${endpoint}${port.protocol === 'UDP' ? ' (UDP)' : ''}`, - value: `/k8s/clusters/${this.clusterId}/api/v1/namespaces/${this.service.metadata.namespace}/services/${endpoint}/proxy`, - }; - }) ?? [] - ); - }, - computedServiceName() { - return ( - this.service?.metadata.labels?.['app.kubernetes.io/component'] ?? - this.service?.metadata.name - ); - }, - helmChart() { - return this.service?.metadata.labels?.['helm.sh/chart']; - }, - kubernetesVersion() { - return this.service?.metadata.labels?.['app.kubernetes.io/version']; - }, - name() { - return this.service?.metadata.name; - }, - namespace() { - return this.service?.metadata.namespace; - }, - }, props: { clusterId: { type: String, required: true, }, + favoritedServices: { + type: Array, + required: true, + }, service: { type: Object, required: true, @@ -95,6 +65,50 @@ export default { openLink(link) { window.open(link); }, + toggleFavorite() { + this.$emit('toggle-favorite', this.service); + }, + }, + computed: { + endpoints() { + return ( + this.service?.spec.ports?.map((port) => { + const endpoint = `${ + isMaybeSecure(port.port, port.protocol) ? 'https' : 'http' + }:${this.service.metadata.name}:${port.port}`; + + return { + label: `${endpoint}${port.protocol === 'UDP' ? ' (UDP)' : ''}`, + value: `/k8s/clusters/${this.clusterId}/api/v1/namespaces/${this.service.metadata.namespace}/services/${endpoint}/proxy`, + }; + }) ?? [] + ); + }, + computedServiceName() { + return ( + this.service?.metadata.labels?.['app.kubernetes.io/component'] ?? + this.service?.metadata.name + ); + }, + helmChart() { + return this.service?.metadata.labels?.['helm.sh/chart']; + }, + kubernetesVersion() { + return this.service?.metadata.labels?.['app.kubernetes.io/version']; + }, + name() { + return this.service?.metadata.name; + }, + namespace() { + return this.service?.metadata.namespace; + }, + isFavorited() { + return this.favoritedServices.some( + (favoritedService) => + favoritedService.clusterId === this.clusterId && + favoritedService.service.id === this.service.id + ); + }, }, name: 'AppLauncherCard', layout: 'plain', @@ -129,6 +143,9 @@ export default {
{{ namespace }}/{{ name }}
+ + + diff --git a/pkg/app-launcher/l10n/en-us.yaml b/pkg/app-launcher/l10n/en-us.yaml index c19c827..6eb00e4 100644 --- a/pkg/app-launcher/l10n/en-us.yaml +++ b/pkg/app-launcher/l10n/en-us.yaml @@ -6,3 +6,8 @@ appLauncher: launchEndpoint: Launch {endpoint} launchAnEndpointFromSelection: Select an endpoint to launch noEndpointFoundForApp: No endpoint found for app + noServicesFound: No services found + loading: Loading... + loadingServices: Loading services... + selectCluster: Select a cluster + globalApps: Global Apps diff --git a/pkg/app-launcher/pages/index.vue b/pkg/app-launcher/pages/index.vue index 46eaa21..9c86d0f 100644 --- a/pkg/app-launcher/pages/index.vue +++ b/pkg/app-launcher/pages/index.vue @@ -1,27 +1,74 @@ -{{ $store.getters['i18n/t']('appLauncher.noServicesFound') }}
+ +{{ $store.getters['i18n/t']('appLauncher.noClusterSelected') }}