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

Add Labels tab to Virtual Machines resource page #1045

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,53 @@ export default {
</span>
</Banner>
</Tab>

<Tab
name="labels"
:label="t('generic.labels')"
:weight="-98"
>
<KeyValue
key="labels"
:value="value.labels"
:add-label="t('labels.addLabel')"
:mode="mode"
:read-allowed="false"
:value-can-be-empty="true"
:description="t(`harvester.virtualMachine.labels.description`)"
@input="value.setLabels($event)"
/>
</Tab>

<Tab
name="instanceLabel"
:label="t('harvester.tab.instanceLabel')"
:weight="-99"
>
<Labels
:default-container-class="'labels-and-annotations-container'"
:value="value"
:mode="mode"
:display-side-by-side="false"
:show-annotations="false"
:show-label-title="false"
:label-description="t(`harvester.virtualMachine.instanceLabels.description`)"
>
<template #labels="{toggler}">
<KeyValue
key="labels"
:value="value.instanceLabels"
:protected-keys="value.systemLabels || []"
:toggle-filter="toggler"
:add-label="t('labels.addLabel')"
:mode="mode"
:read-allowed="false"
:value-can-be-empty="true"
@input="value.setInstanceLabels($event)"
/>
</template>
</Labels>
</Tab>
</Tabbed>

<RestartVMDialog
Expand Down
4 changes: 4 additions & 0 deletions pkg/harvester/l10n/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,10 @@ harvester:
inNamespaces: "Workloads in these namespaces"
namespaces:
label: Namespaces
labels:
description: ""
Copy link
Collaborator

@a110605 a110605 Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this key needed? description prop in KeyValue.vue default to empty string.

harvester.virtualMachine.labels.description

instanceLabels:
description: These labels are automatically synchronized to the Virtual Machine instance.

volume:
label: Volumes
Expand Down
9 changes: 9 additions & 0 deletions shell/components/form/KeyValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ export default {
default: false,
type: Boolean
},
description: {
default: '',
type: String,
},
},
data() {
const rows = this.getRows(this.value);
Expand Down Expand Up @@ -565,6 +569,11 @@ export default {
</h3>
</slot>
</div>
<div v-if="description">
<p class="mt-10 mb-10">
{{ description }}
</p>
</div>
<div
class="kv-container"
:style="containerStyle"
Expand Down
21 changes: 19 additions & 2 deletions shell/components/form/Labels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export default {
type: Boolean,
default: true,
},

showLabelDescription: {
type: Boolean,
default: true,
},

labelDescription: {
type: String,
default: '',
},
},

data() {
Expand Down Expand Up @@ -89,8 +99,15 @@ export default {
:on-label="t('labels.labels.show')"
/>
</div>
<p class="mt-10 mb-10">
<t k="labels.labels.description" />
<p
v-if="showLabelDescription"
class="mt-10 mb-10"
>
<span v-if="labelDescription">{{ labelDescription }}</span>
<t
v-if="!labelDescription"
k="labels.labels.description"
/>
</p>
<div :class="columnsClass">
<slot
Expand Down
Loading