diff --git a/pkg/app-launcher/components/AppLauncherCard.vue b/pkg/app-launcher/components/AppLauncherCard.vue index dd0cc51..10e299f 100644 --- a/pkg/app-launcher/components/AppLauncherCard.vue +++ b/pkg/app-launcher/components/AppLauncherCard.vue @@ -2,6 +2,7 @@ import { Card } from '@components/Card'; import ButtonDropDown from '@shell/components/ButtonDropdown'; import { isMaybeSecure } from '@shell/utils/url'; +import { ingressFullPath } from '@shell/models/networking.k8s.io.ingress'; export default { components: { @@ -19,46 +20,11 @@ export default { }, service: { type: Object, - required: true, - default: () => ({ - id: '', - metadata: { - labels: { - /** - * Helm chart name that created this app (if relevant). - */ - 'helm.sh/chart': '', - /** - * The component of the app. - * - * See `app.kubernetes.io/component` from: - * https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels - */ - 'app.kubernetes.io/component': '', - /** - * The version of the app. - * - * See `app.kubernetes.io/version` from: - * https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels - */ - 'app.kubernetes.io/version': '', - }, - /** - * The name of the app. - * - * See `app.kubernetes.io/name` from: - * https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels - */ - name: '', - /** - * The namespace of the app. - */ - namespace: '', - }, - spec: { - ports: [], - }, - }), + default: null, + }, + ingress: { + type: Object, + default: null, }, }, methods: { @@ -70,12 +36,15 @@ export default { }, }, computed: { + app() { + return this.service || this.ingress; + }, endpoints() { return ( - this.service?.spec.ports?.map((port) => { + this.service?.spec?.ports?.map((port) => { const endpoint = `${ isMaybeSecure(port.port, port.protocol) ? 'https' : 'http' - }:${this.service.metadata.name}:${port.port}`; + }:${this.service?.metadata?.name}:${port.port}`; return { label: `${endpoint}${port.protocol === 'UDP' ? ' (UDP)' : ''}`, @@ -86,32 +55,35 @@ export default { }, computedServiceName() { return ( - this.service?.metadata.labels?.['app.kubernetes.io/component'] ?? - this.service?.metadata.name + this.service?.metadata?.labels?.['app.kubernetes.io/component'] ?? + this.service?.metadata?.name ); }, helmChart() { - return this.service?.metadata.labels?.['helm.sh/chart']; + return this.service?.metadata?.labels?.['helm.sh/chart']; }, kubernetesVersion() { - return this.service?.metadata.labels?.['app.kubernetes.io/version']; + return this.service?.metadata?.labels?.['app.kubernetes.io/version']; }, name() { - return this.service?.metadata.name; + return this.service?.metadata?.name; }, namespace() { - return this.service?.metadata.namespace; + return this.service?.metadata?.namespace; }, isFavorited() { return this.favoritedServices.some( (favoritedService) => - favoritedService.clusterId === this.clusterId && - favoritedService.service.id === this.service.id + favoritedService?.clusterId === this.clusterId && + favoritedService?.service?.id === this.service?.id ); }, isGlobalApp() { - return this.service.metadata.annotations?.['extensions.applauncher/global-app'] === 'true'; + return this.service?.metadata?.annotations?.['extensions.applauncher/global-app'] === 'true'; }, + ingressPath() { + return ingressFullPath(this.ingress, this.ingress?.spec?.rules?.[0]); + } }, name: 'AppLauncherCard', layout: 'plain', @@ -123,27 +95,24 @@ export default { +