From 995aa1f1a843d8b3239b0371e78835dc883a2264 Mon Sep 17 00:00:00 2001 From: Jeroen Nijhuis Date: Thu, 11 Jan 2024 22:59:14 +0100 Subject: [PATCH] feat: added tab icons --- src/assets/icons/describe.svg | 1 + src/assets/icons/edit.svg | 1 + src/assets/icons/logs.svg | 1 + src/assets/icons/shell.svg | 1 + src/assets/icons/tab.svg | 1 + src/components/TabIcon.vue | 18 ++++++++++++++++++ src/components/TabOrchestrator.vue | 2 ++ src/providers/TabProvider.ts | 18 ++++++++++++++++-- src/views/Pods.vue | 20 ++++++++++++-------- 9 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 src/assets/icons/describe.svg create mode 100644 src/assets/icons/edit.svg create mode 100644 src/assets/icons/logs.svg create mode 100644 src/assets/icons/shell.svg create mode 100644 src/assets/icons/tab.svg create mode 100644 src/components/TabIcon.vue diff --git a/src/assets/icons/describe.svg b/src/assets/icons/describe.svg new file mode 100644 index 0000000..0c4ff42 --- /dev/null +++ b/src/assets/icons/describe.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/edit.svg b/src/assets/icons/edit.svg new file mode 100644 index 0000000..2fba7c5 --- /dev/null +++ b/src/assets/icons/edit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/logs.svg b/src/assets/icons/logs.svg new file mode 100644 index 0000000..9f3650e --- /dev/null +++ b/src/assets/icons/logs.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/shell.svg b/src/assets/icons/shell.svg new file mode 100644 index 0000000..f3c334e --- /dev/null +++ b/src/assets/icons/shell.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/tab.svg b/src/assets/icons/tab.svg new file mode 100644 index 0000000..dd66b32 --- /dev/null +++ b/src/assets/icons/tab.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/TabIcon.vue b/src/components/TabIcon.vue new file mode 100644 index 0000000..1198ef3 --- /dev/null +++ b/src/components/TabIcon.vue @@ -0,0 +1,18 @@ + + + diff --git a/src/components/TabOrchestrator.vue b/src/components/TabOrchestrator.vue index dd6dbc9..bfac4a6 100644 --- a/src/components/TabOrchestrator.vue +++ b/src/components/TabOrchestrator.vue @@ -4,6 +4,7 @@ import { TabProviderCloseTabKey, } from "@/providers/TabProvider"; import { injectStrict } from "@/lib/utils"; +import TabIcon from "@/components/TabIcon.vue"; import Expand from "@/assets/icons/expand.svg"; import Close from "@/assets/icons/close.svg"; import { SettingsContextStateKey } from "@/providers/SettingsContextProvider"; @@ -99,6 +100,7 @@ const closeAndSetActiveTab = (id: string) => { @click="setActiveTab(tab.id)" :title="tab.title" > + {{ tab.title }}
> = Symbol("TabProviderState"); export const TabProviderAddTabKey: InjectionKey< - (id: string, title: string, component: any, props?: any) => void + ( + id: string, + title: string, + component: any, + props?: any, + icon?: string + ) => void > = Symbol("TabProviderAddTab"); export const TabProviderCloseTabKey: InjectionKey<(id: string) => void> = Symbol("TabProviderCloseTab"); export interface Tab { id: string; + icon: string; title: string; component: any; props?: any; @@ -37,7 +44,13 @@ export default { provide(TabProviderStateKey, toRefs(state)); - const addTab = (id: string, title: string, component: any, props?: any) => { + const addTab = ( + id: string, + title: string, + component: any, + props?: any, + icon: string = "tab" + ) => { if (state.tabs.find((tab) => tab.id === id)) { state.activeTabId = id; return; @@ -45,6 +58,7 @@ export default { state.tabs.push({ id, + icon, title, component: shallowRef(component), props, diff --git a/src/views/Pods.vue b/src/views/Pods.vue index 6a56e9e..fb4185c 100644 --- a/src/views/Pods.vue +++ b/src/views/Pods.vue @@ -28,13 +28,14 @@ const rowActions: RowAction[] = [ handler: (row) => { addTab( `edit_${row.metadata?.name}`, - `Edit ${row.metadata?.name}`, + `${row.metadata?.name}`, defineAsyncComponent(() => import("@/views/ObjectEditor.vue")), { context: context.value, namespace: namespace.value, object: `pods/${row.metadata?.name}`, - } + }, + "edit" ); }, }, @@ -43,13 +44,14 @@ const rowActions: RowAction[] = [ handler: (row) => { addTab( `describe_${row.metadata?.name}`, - `Describe ${row.metadata?.name}`, + `${row.metadata?.name}`, defineAsyncComponent(() => import("@/views/Describe.vue")), { context: context.value, namespace: namespace.value, object: `pods/${row.metadata?.name}`, - } + }, + "describe" ); }, }, @@ -61,14 +63,15 @@ const rowActions: RowAction[] = [ handler: () => { addTab( `shell_${row.metadata?.name}_${container.name}`, - `>_ ${row.metadata?.name}/${container.name}`, + `${row.metadata?.name}/${container.name}`, defineAsyncComponent(() => import("@/views/Shell.vue")), { context: context.value, namespace: namespace.value, pod: row, container: container, - } + }, + "shell" ); }, })); @@ -79,13 +82,14 @@ const rowActions: RowAction[] = [ handler: (row) => { addTab( `logs_${row.metadata?.name}`, - `Logs for ${row.metadata?.name}`, + `${row.metadata?.name}`, defineAsyncComponent(() => import("@/views/LogViewer.vue")), { context: context.value, namespace: namespace.value, pod: row.metadata?.name, - } + }, + "logs" ); }, },