Skip to content

Commit

Permalink
feat(dashboard-renderer): stub out support for EntityLink [MA-2716]
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-peteu committed Mar 14, 2024
1 parent e51f145 commit 13a1ff3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ import {
SimpleChart,
TopNTable,
} from '../../src'
import { SeededRandom } from '@kong-ui-public/analytics-utilities'
import type { AnalyticsExploreRecord, DisplayBlob, ExploreResultV4, QueryResponseMeta } from '@kong-ui-public/analytics-utilities'
import type { AnalyticsChartColors, SimpleChartOptions } from '../../src/types'
import { SeededRandom } from '../utils/SeedRandom'
import { rand } from '../utils/utils'
import { lookupDatavisColor } from '../../src/utils'
import { lookupStatusCodeColor } from '../../src/utils/customColors'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const errorMessage = computed((): string => {
})
const getId = (record: AnalyticsExploreRecord): string => {
console.log(' >>> record >>>', record)
const event = record.event
return String(event[displayKey.value])
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/dashboard-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
},
"dependencies": {
"@kong-ui-public/core": "workspace:^",
"@kong-ui-public/entities-shared": "workspace:^",
"ajv": "^8.12.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,40 @@
:description="chartOptions.description"
:synthetics-data-key="chartOptions.syntheticsDataKey"
:title="chartOptions.chartTitle || ''"
/>
>
<template
v-if="props.chartOptions?.entityLink"
#name="{ record }"
>
<EntityLink
:entity-link-data="{
id: record.id,
label: record.name,
deleted: record.deleted
}"
:external-link="generateEntityUrl([
'{geo}',
'gateway-manager',
'{idTuple0}',
'gateway-services',
'{idTuple1}'
])"
/>
</template>
</TopNTable>
</QueryDataProvider>
</template>

<script setup lang="ts">
import type { RendererProps, TopNTableOptions } from '../types'
import { TopNTable } from '@kong-ui-public/analytics-chart'
import composables from '../composables'
import QueryDataProvider from './QueryDataProvider.vue'
defineProps<RendererProps<TopNTableOptions>>()
const props = defineProps<RendererProps<TopNTableOptions>>()
const generateEntityUrl = (routeParams: string[]): string => {
return composables.useExternalLinkCreator(routeParams)
}
</script>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import useExternalLinkCreator from './useExternalLinkCreator'
import useI18n from './useI18n'

// All composables must be exported as part of the default object for Cypress test stubs
export default {
useExternalLinkCreator,
useI18n,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useExternalLinkCreator } from '@kong-ui-public/entities-shared'

export default (routeParams: string[]): string => {
// TODO: may have to pass in geo from consuming app
const activeGeoCode = 'us'

const parsedRouteParams = routeParams.map(rp => rp.replace('{geo}', activeGeoCode))

// TODO: replace `{idTuple0}` and `{idTuple1}` with actual record ID vales

return useExternalLinkCreator(parsedRouteParams)
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export const topNTableSchema = {
description: {
type: 'string',
},
entityLink: {
type: 'string',
},
},
required: ['type'],
additionalProperties: false,
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 13a1ff3

Please sign in to comment.