Skip to content

Commit

Permalink
feat(xo-6): simplify functions
Browse files Browse the repository at this point in the history
  • Loading branch information
CzechSebastian committed Dec 11, 2024
1 parent d71c025 commit 077a198
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 13 additions & 5 deletions @xen-orchestra/web/src/components/pif/PifPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
{{ $t('ip-mode') }}
</template>
<template #value>
{{ props.pif.mode }}
{{ getPifData('mode') }}
</template>
</VtsCardRowKeyValue>
</div>
Expand Down Expand Up @@ -245,14 +245,22 @@ const getNetworkData = (type: keyof XoNetwork) => {
return network[type] ? 'on' : 'off'
case 'tags':
return network.tags.length ? network.tags : '-'
default:
return undefined
}
}
const getPifData = (type: keyof XoPif) => {
const value = type === 'vlan' ? props.pif.vlan : props.pif[type]
return value === -1 || value === '' ? '-' : value
const value = props.pif[type]
switch (type) {
case 'vlan':
return value === -1 ? '-' : value
case 'netmask':
case 'dns':
case 'gateway':
return value === '' ? '-' : props.pif.netmask
case 'mode':
return value === 'None' ? '-' : value
}
}
</script>

Expand Down
8 changes: 3 additions & 5 deletions @xen-orchestra/web/src/components/pif/PifTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</div>
<div v-if="column.id === 'ip'" v-tooltip class="text-ellipsis">{{ row.value.ip }}</div>
<div v-if="column.id === 'mac'" v-tooltip class="text-ellipsis">{{ row.value.mac }}</div>
<div v-if="column.id === 'mode'" v-tooltip class="text-ellipsis">{{ row.value.mode }}</div>
<div v-if="column.id === 'mode'" v-tooltip class="text-ellipsis">{{ getPifData(row.value, 'mode') }}</div>
<div v-if="column.id === 'more'" v-tooltip>
<VtsIcon accent="info" :icon="faEllipsis" />
</div>
Expand Down Expand Up @@ -141,10 +141,8 @@ const getNetworkName = (pif: XoPif) => {
return network.name_label ? network.name_label : ''
}
const getPifData = (pif: XoPif, type: keyof XoPif) => {
const value = type === 'vlan' ? pif.vlan : pif[type]
return value === -1 || value === '' ? '' : value
}
const getPifData = (pif: XoPif, type: keyof XoPif) =>
(type === 'vlan' && pif[type] === -1) || (type === 'mode' && pif[type] === 'None') ? '' : pif[type]
const searchQuery = ref('')
Expand Down

0 comments on commit 077a198

Please sign in to comment.