-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d54bf2
commit 799a030
Showing
6 changed files
with
188 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
packages/entities/entities-shared/src/components/entity-tooltip/EntityTooltip.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<template> | ||
<KPop | ||
placement="bottom" | ||
trigger="hover" | ||
width="300" | ||
> | ||
<div class="label-wrapper"> | ||
<ConnectionsIcon :size="KUI_ICON_SIZE_30" /> | ||
<span class="label">{{ tooltipData?.label }}</span> | ||
</div> | ||
<template | ||
v-if="tooltipData?.items" | ||
#content | ||
> | ||
<ConfigCardItem | ||
v-for="item in tooltipData.items" | ||
:key="item.key" | ||
:item="item" | ||
slim | ||
truncated | ||
/> | ||
</template> | ||
<template #footer> | ||
<div class="footer-container"> | ||
<EntityLink | ||
allow-copy | ||
:entity-link-data="{ | ||
id: entityConfig.id, | ||
label: 'View', | ||
deleted: entityDeleted | ||
}" | ||
:external-link="externalLink" | ||
new-window | ||
/> | ||
<KExternalLink | ||
v-if="exploreLink" | ||
:href="exploreLink" | ||
> | ||
Explore | ||
</KExternalLink> | ||
</div> | ||
</template> | ||
</KPop> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { PropType } from 'vue' | ||
import { ref } from 'vue' | ||
import ConfigCardItem from '../entity-base-config-card/ConfigCardItem.vue' | ||
import useSWRV from 'swrv' | ||
import EntityLink from '../entity-link/EntityLink.vue' | ||
import { ConnectionsIcon } from '@kong/icons' | ||
import { KUI_ICON_SIZE_30 } from '@kong/design-tokens' | ||
import type { EntityTooltipConfig, TooltipData } from '../../types' | ||
|
||
const props = defineProps({ | ||
entityConfig: { | ||
type: Object as PropType<EntityTooltipConfig>, | ||
required: true, | ||
}, | ||
externalLink: { | ||
type: String, | ||
required: true, | ||
}, | ||
exploreLink: { | ||
type: String, | ||
required: false, | ||
default: null, | ||
}, | ||
}) | ||
|
||
const entityDeleted = ref(false) | ||
|
||
const { data: tooltipData } = useSWRV<TooltipData>( | ||
() => `entity-tooltip-${props.entityConfig.id}`, | ||
async () => { | ||
|
||
const items = await props.entityConfig.data() | ||
|
||
return items | ||
}, | ||
{ | ||
refreshInterval: 0, | ||
revalidateOnFocus: false, | ||
}, | ||
) | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
:deep(.config-card-details-row) { | ||
padding: $kui-space-30 $kui-space-0 $kui-space-30 0 !important; | ||
} | ||
|
||
:deep(.config-card-details-value) { | ||
display: flex !important; | ||
justify-content: end !important; | ||
overflow: hidden; | ||
text-overflow: ellipsis !important; | ||
white-space: nowrap !important; | ||
width: 60% !important; | ||
|
||
.copy-text { | ||
max-width: 15ch !important; | ||
overflow: hidden; | ||
text-overflow: ellipsis !important; | ||
white-space: nowrap !important; | ||
} | ||
} | ||
|
||
:deep(.config-card-details-label) { | ||
width: 40% !important; | ||
} | ||
|
||
.label-wrapper { | ||
display: flex; | ||
flex-direction: row; | ||
gap: $kui-space-20; | ||
|
||
.label { | ||
cursor: pointer; | ||
text-decoration: underline; | ||
text-decoration-style: dashed; | ||
text-decoration-thickness: 1px; | ||
text-underline-offset: 3px; | ||
} | ||
} | ||
|
||
.footer-container { | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/entities/entities-shared/src/types/entity-tooltip-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { RecordItem } from './entity-base-config-card' | ||
|
||
|
||
export const entityTypes = [ | ||
'api_product', | ||
'api_product_version', | ||
'control_plane', | ||
'control_plane_group', | ||
'data_plane_node', | ||
'gateway_service', | ||
'route', | ||
'application', | ||
'consumer', | ||
] as const | ||
|
||
export type EntityType = typeof entityTypes[number] | ||
|
||
export interface TooltipData { | ||
items: RecordItem[] | null, | ||
label: string, | ||
} | ||
|
||
export interface EntityTooltipConfig { | ||
title: string | ||
deleted: boolean | ||
id: string, | ||
type: EntityType, | ||
data: () => Promise<TooltipData> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.