Skip to content

Commit

Permalink
Merge pull request #9 from krumIO/feat/APPLAUNCHER-23__take2_first_ui…
Browse files Browse the repository at this point in the history
…_pass

feat: First Pass of UI changes
  • Loading branch information
krumware authored Mar 8, 2024
2 parents 95f7423 + e2d4acc commit cde6b5b
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 75 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ coverage

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
Expand Down
11 changes: 1 addition & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "krum-rancher-extensions-demo",
"version": "0.1.4",
"version": "0.1.5",
"private": true,
"engines": {
"node": "16.19.1"
Expand Down
99 changes: 65 additions & 34 deletions pkg/app-launcher/components/AppLauncherCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -129,6 +143,9 @@ export default {
<p>{{ namespace }}/{{ name }}</p>
</template>
<template #actions>
<button class="icon-button" @click="toggleFavorite">
<i :class="['icon', isFavorited ? 'icon-star' : 'icon-star-open']" />
</button>
<a
v-if="(endpoints?.length ?? 0) <= 1"
:disabled="!endpoints?.length"
Expand Down Expand Up @@ -156,3 +173,17 @@ export default {
</template>
</Card>
</template>
<style lang="scss" scoped>
@import "@shell/assets/styles/fonts/_icons.scss";
.icon-button {
background: none;
border: none;
cursor: pointer;
padding: 0;
color: var(--primary);
font-size: 1.8rem;
margin-right: 1rem;
}
</style>
5 changes: 5 additions & 0 deletions pkg/app-launcher/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit cde6b5b

Please sign in to comment.