Skip to content

Commit

Permalink
feat: open exposed services in a new window
Browse files Browse the repository at this point in the history
Instead of rendering them inside an iframe, open them in a new window.

Closes #25.

Signed-off-by: Utku Ozdemir <[email protected]>
  • Loading branch information
utkuozdemir committed Mar 12, 2024
1 parent 0960100 commit 190218a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 79 deletions.
12 changes: 9 additions & 3 deletions frontend/src/components/common/MenuItem/TMenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,36 @@ Use of this software is governed by the Business Source License
included in the LICENSE file.
-->
<template>
<router-link :to="route" active-class="item__active">
<component :is="componentType" v-bind="componentAttributes">
<div class="item">
<t-icon v-if="icon" class="item__icon" :icon="icon" :svg-base64="iconSvgBase64"/>
<p class="item__name truncate">{{ name }}</p>
<div v-if="label" class="rounded-full text-naturals-N13 bg-naturals-N4 text-xs p-1 w-6 h-6 text-center" :class="labelColor ? 'text-' + labelColor : ''">
{{ label }}
</div>
</div>
</router-link>
</component>
</template>

<script setup lang="ts">
import TIcon, { IconType } from "@/components/common/Icon/TIcon.vue";

type Props = {
route: string | object,
regularLink?: boolean,
name: string,
icon?: IconType,
iconSvgBase64?: string,
label?: string | number,
labelColor?: string
};

defineProps<Props>();
const props = defineProps<Props>();

const componentType = props.regularLink ? "a" : "router-link";
const componentAttributes = props.regularLink ?
{ href: props.route, target: "_blank" } :
{ to: props.route, activeClass: "item__active" };
</script>

<style scoped>
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import ConfigPatches from "@/views/cluster/Config/Patches.vue";
import PatchEdit from "@/views/cluster/Config/PatchEdit.vue";
import KubernetesManifestSync from "@/views/cluster/Manifest/Sync.vue";
import NodeDetails from "@/views/cluster/Nodes/NodeDetails.vue";
import ExposedService from "@/views/cluster/ExposedService/ExposedService.vue";
import ClusterBackups from "@/views/cluster/Backups/Backups.vue";

import PageNotFound from "@/views/common/PageNotFound.vue";
Expand Down Expand Up @@ -298,14 +297,6 @@ const routes: RouteRecordRaw[] = [
inner: KubernetesManifestSync,
},
},
{
path: "/services/:service",
name: "ExposedService",
component: ClusterScoped,
props: {
inner: ExposedService,
},
},
{
path: "/backups",
name: "Backups",
Expand Down
65 changes: 0 additions & 65 deletions frontend/src/views/cluster/ExposedService/ExposedService.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ included in the LICENSE file.
<t-menu-item
v-for="service in exposedServices"
:key="service.metadata.id"
:route="'/cluster/' + route.params.cluster + '/services/' + service.metadata.labels?.[LabelExposedServiceAlias]"
:route="exposedServiceUrl(service)"
:name="service.spec.label"
:icon-svg-base64="service.spec.icon_base64"
icon="exposed-service"
regular-link
/>
</template>
<template v-else>
Expand All @@ -39,7 +40,7 @@ import { useRoute } from "vue-router";
import { ResourceTyped } from "@/api/grpc";
import Watch from "@/api/watch";
import { ExposedServiceSpec } from "@/api/omni/specs/omni.pb";
import { DefaultNamespace, LabelCluster, ExposedServiceType, LabelExposedServiceAlias } from "@/api/resources";
import { DefaultNamespace, LabelCluster, ExposedServiceType, LabelExposedServiceAlias, workloadProxyHostPrefix } from "@/api/resources";
import { Runtime } from "@/api/common/omni.pb";
import TIcon from "@/components/common/Icon/TIcon.vue";
import { Disclosure, DisclosureButton, DisclosurePanel } from "@headlessui/vue";
Expand All @@ -57,6 +58,12 @@ exposedServicesWatch.setup({
},
selectors: [`${LabelCluster}=${route.params.cluster}`]
});

const exposedServiceUrl = (service: ResourceTyped<ExposedServiceSpec>) => {
const alias = service.metadata.labels?.[LabelExposedServiceAlias];

return `${window.location.protocol}//${workloadProxyHostPrefix}-${alias}-${window.location.hostname}`
}
</script>

<style scoped>
Expand Down

0 comments on commit 190218a

Please sign in to comment.