Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: First Pass of UI changes #9

Merged
merged 6 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading