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(xo-core): add CellObject component #7798

Merged
merged 1 commit into from
Jul 15, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<ComponentStory
v-slot="{ properties, settings }"
:params="[
prop('id').str().preset('550e8400-e29b-41d4-a716-446655440000').widget(),
prop('copiableId').bool().widget(),
slot().help('Meant to receive an ObjectLink component'),
setting('slot').preset('Object link').widget(),
]"
>
<table>
<tr>
<CellObject v-bind="properties">
{{ settings.slot }}
</CellObject>
</tr>
</table>
</ComponentStory>
</template>

<script lang="ts" setup>
import ComponentStory from '@/components/component-story/ComponentStory.vue'
import { prop, setting, slot } from '@/libs/story/story-param'
import CellObject from '@core/components/cell-object/CellObject.vue'
</script>
61 changes: 61 additions & 0 deletions @xen-orchestra/web-core/lib/components/cell-object/CellObject.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!-- v1.0 -->
<template>
<td class="cell-object">
<div class="data">
<slot />
<template v-if="id !== undefined">
<span v-tooltip class="id typo p4-regular-italic ellipsis">
{{ id }}
</span>
<UiButton
v-if="isSupported && copiableId"
:left-icon="faCopy"
level="secondary"
size="extra-small"
:color="copied ? 'success' : 'info'"
@click="copy(id)"
>
{{ copied ? $t('core.copied') : $t('core.copy-id') }}
</UiButton>
</template>
</div>
</td>
</template>

<script lang="ts" setup>
import UiButton from '@core/components/button/UiButton.vue'
import { vTooltip } from '@core/directives/tooltip.directive'
import { faCopy } from '@fortawesome/free-solid-svg-icons'
import { useClipboard } from '@vueuse/core'

defineProps<{
id?: string
copiableId?: boolean
}>()

const { isSupported, copy, copied } = useClipboard()
</script>

<style lang="postcss" scoped>
.cell-object {
padding: 0.8rem;
border: 0.1rem solid var(--color-grey-500);
}

.data {
display: flex;
gap: 1.6rem;
align-items: center;
}

.id {
color: var(--color-grey-300);
}

.ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
min-width: 0;
}
</style>
2 changes: 2 additions & 0 deletions @xen-orchestra/web-core/lib/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"coming-soon": "Coming soon!",
"console": "Console",

"core.copied": "Copied",
"core.copy-id": "Copy ID",
"core.close": "Close",
"core.current": "Current",
"core.filter": "Filter",
Expand Down
2 changes: 2 additions & 0 deletions @xen-orchestra/web-core/lib/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"coming-soon": "Bientôt disponible !",
"console": "Console",

"core.copied": "Copié",
"core.copy-id": "Copier l'ID",
"core.close": "Fermer",
"core.current": "Actuel",
"core.filter": "Filtrer",
Expand Down
Loading