diff --git a/pkg/app-launcher/components/AppLauncherCard.vue b/pkg/app-launcher/components/AppLauncherCard.vue index 9e19477..60245a9 100644 --- a/pkg/app-launcher/components/AppLauncherCard.vue +++ b/pkg/app-launcher/components/AppLauncherCard.vue @@ -10,21 +10,17 @@ export default { ButtonDropDown, }, props: { - clusterId: { - type: String, - required: true, - }, - favoritedServices: { + favoritedApps: { type: Array, required: true, }, - service: { + app: { type: Object, default: null, }, - ingress: { - type: Object, - default: null, + isInGlobalView: { + type: Boolean, + default: false, }, }, methods: { @@ -32,57 +28,54 @@ export default { window.open(link); }, toggleFavorite() { - this.$emit('toggle-favorite', this.service); + this.$emit('toggle-favorite', this.app) }, }, computed: { - app() { - return this.service || this.ingress; - }, endpoints() { return ( - this.service?.spec?.ports?.map((port) => { + this.app?.spec?.ports?.map((port) => { const endpoint = `${ isMaybeSecure(port.port, port.protocol) ? 'https' : 'http' - }:${this.service?.metadata?.name}:${port.port}`; + }:${this.app.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`, + value: `/k8s/clusters/${this.clusterId}/api/v1/namespaces/${this.app.namespace}/services/${endpoint}/proxy`, }; }) ?? [] ); }, computedServiceName() { return ( - this.service?.metadata?.labels?.['app.kubernetes.io/component'] ?? - this.service?.metadata?.name + this.app?.metadata?.labels?.['app.kubernetes.io/component'] ?? + this.app?.metadata?.name ); }, helmChart() { - return this.service?.metadata?.labels?.['helm.sh/chart']; + return this.app?.metadata?.labels?.['helm.sh/chart']; }, kubernetesVersion() { - return this.service?.metadata?.labels?.['app.kubernetes.io/version']; + return this.app?.metadata?.labels?.['app.kubernetes.io/version']; }, name() { - return this.service?.metadata?.name; + return this.app?.metadata?.name; }, namespace() { - return this.service?.metadata?.namespace; + return this.app?.metadata?.namespace; }, isFavorited() { - return this.favoritedServices.some( - (favoritedService) => - favoritedService?.clusterId === this.clusterId && - favoritedService?.service?.id === this.service?.id + return this.favoritedApps.some( + (favoritedApp) => + favoritedApp?.id === this.app.id && + favoritedApp?.kind === this.app.kind ); }, isGlobalApp() { - return this.service?.metadata?.annotations?.['extensions.applauncher/global-app'] === 'true'; + return this.app?.metadata?.annotations?.['extensions.applauncher/global-app'] === 'true'; }, ingressPath() { - return ingressFullPath(this.ingress, this.ingress?.spec?.rules?.[0]); + return ingressFullPath(this.app, this.app?.spec?.rules?.[0]); } }, name: 'AppLauncherCard', @@ -95,24 +88,28 @@ export default {