Skip to content

Commit

Permalink
feature(policies): add more information to the policy detail page (#2935
Browse files Browse the repository at this point in the history
)

Adds further info to the policy detail page. Please note this purposefully doesn't add the producer/consumer/system type yet.

I'll be adding that along with the same in the listing page.

Closes #2929

Also defaults any empty top-level targetRef to `Mesh`

Closes #2934

---

Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen authored Sep 18, 2024
1 parent 381cc67 commit 7096832
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 34 deletions.
26 changes: 15 additions & 11 deletions src/app/policies/components/PolicySummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
</template>

<template #body>
<template v-if="props.policy.spec.targetRef">
<KBadge appearance="neutral">
{{ props.policy.spec.targetRef.kind }}<span v-if="props.policy.spec.targetRef.name">:<b>{{ props.policy.spec.targetRef.name }}</b></span>
</KBadge>
</template>

<template v-else>
{{ t('common.detail.none') }}
</template>
<KBadge
v-if="props.policy.spec.targetRef"
appearance="neutral"
>
{{ props.policy.spec.targetRef.kind }}<span v-if="props.policy.spec.targetRef.name">:<b>{{ props.policy.spec.targetRef.name }}</b></span>
</KBadge>
<KBadge
v-else
appearance="neutral"
>
Mesh
</KBadge>
</template>
</DefinitionCard>
<DefinitionCard
Expand All @@ -40,7 +43,7 @@
</template>
</DefinitionCard>
<DefinitionCard
v-if="props.policy.zone"
v-if="can('use zones') && props.policy.zone"
layout="horizontal"
>
<template
Expand Down Expand Up @@ -80,10 +83,11 @@

<script lang="ts" setup>
import type { Policy } from '../data'
import { useI18n } from '@/app/application'
import { useI18n, useCan } from '@/app/application'
import DefinitionCard from '@/app/common/DefinitionCard.vue'
const { t } = useI18n()
const can = useCan()
const props = defineProps<{
policy: Policy
Expand Down
54 changes: 51 additions & 3 deletions src/app/policies/views/PolicyDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,37 @@
v-slot="{ route, t, uri, can, me }"
>
<AppView>
<KCard
v-if="can('use zones') && props.data.zone"
>
<KCard>
<div class="columns">
<DefinitionCard>
<template
#title
>
Type
</template>
<template
#body
>
{{ props.data.type }}
</template>
</DefinitionCard>
<DefinitionCard
v-if="props.data.namespace.length > 0"
>
<template
#title
>
Namespace
</template>
<template
#body
>
{{ props.data.namespace }}
</template>
</DefinitionCard>
<DefinitionCard
v-if="can('use zones') && props.data.zone"
>
<template
#title
>
Expand All @@ -38,6 +64,28 @@
</XAction>
</template>
</DefinitionCard>
<DefinitionCard
v-if="props.data.spec"
>
<template #title>
{{ t('http.api.property.targetRef') }}
</template>

<template #body>
<KBadge
v-if="props.data.spec.targetRef"
appearance="neutral"
>
{{ props.data.spec.targetRef.kind }}<span v-if="props.data.spec.targetRef.name">:<b>{{ props.data.spec.targetRef.name }}</b></span>
</KBadge>
<KBadge
v-else
appearance="neutral"
>
Mesh
</KBadge>
</template>
</DefinitionCard>
</div>
</KCard>
<div>
Expand Down
21 changes: 12 additions & 9 deletions src/app/policies/views/PolicyListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,18 @@
</template>

<template #targetRef="{ row }">
<template v-if="type.isTargetRefBased && typeof row.spec?.targetRef !== 'undefined'">
<KBadge appearance="neutral">
{{ row.spec.targetRef.kind }}<span v-if="row.spec.targetRef.name">:<b>{{ row.spec.targetRef.name }}</b></span>
</KBadge>
</template>

<template v-else>
{{ t('common.detail.none') }}
</template>
<KBadge
v-if="typeof row.spec?.targetRef !== 'undefined'"
appearance="neutral"
>
{{ row.spec.targetRef.kind }}<span v-if="row.spec.targetRef.name">:<b>{{ row.spec.targetRef.name }}</b></span>
</KBadge>
<KBadge
v-else
appearance="neutral"
>
Mesh
</KBadge>
</template>

<template #zone="{ row }">
Expand Down
2 changes: 2 additions & 0 deletions src/test-support/mocks/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import _138 from './src/meshes/_/meshexternalservices'
import _139 from './src/meshes/_/meshexternalservices/_'
import _52 from './src/meshes/_/meshfaultinjections'
import _53 from './src/meshes/_/meshfaultinjections/_'
import _54 from './src/meshes/_/meshfaultinjections/_/_resources/dataplanes'
import _31 from './src/meshes/_/meshgatewayroutes'
import _32 from './src/meshes/_/meshgatewayroutes/_'
import _33 from './src/meshes/_/meshgateways'
Expand Down Expand Up @@ -148,6 +149,7 @@ export const fs: FS = {
'/meshes/:mesh/health-checks/:name': _30,
'/meshes/:mesh/meshfaultinjections': _52,
'/meshes/:mesh/meshfaultinjections/:name': _53,
'/meshes/:mesh/meshfaultinjections/:name/_resources/dataplanes': _54,
'/meshes/:mesh/meshgatewayroutes': _31,
'/meshes/:mesh/meshgatewayroutes/:name': _32,
'/meshes/:mesh/meshgateways': _33,
Expand Down
22 changes: 19 additions & 3 deletions src/test-support/mocks/src/mesh-insights/_.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { EndpointDependencies, MockResponder } from '@/test-support'
export default ({ env, fake }: EndpointDependencies): MockResponder => (req) => {
const params = req.params
const policyTypes = [

const legacyTypes = [
'CircuitBreaker',
'FaultInjection',
'HealthCheck',
'MeshGatewayRoute',
'MeshGateway',
'ProxyTemplate',
'RateLimit',
'Retry',
Expand All @@ -17,6 +16,23 @@ export default ({ env, fake }: EndpointDependencies): MockResponder => (req) =>
'TrafficTrace',
'VirtualOutbound',
]
const policyTypes = [
'MeshAccessLog',
'MeshCircuitBreaker',
'MeshFaultInjection',
'MeshGatewayRoute',
'MeshHTTPRoute',
'MeshHealthCheck',
'MeshLoadBalancingStrategy',
'MeshMetric',
'MeshProxyPatch',
'MeshRateLimit',
'MeshRetry',
'MeshTCPRoute',
'MeshTimeout',
'MeshTrace',
'MeshTrafficPermission',
].concat(legacyTypes)

const serviceTotal = parseInt(env('KUMA_SERVICE_COUNT', `${fake.number.int({ min: 1, max: 30 })}`))

Expand Down
4 changes: 0 additions & 4 deletions src/test-support/mocks/src/meshes/_/meshfaultinjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export default ({ fake, pager, env }: EndpointDependencies): MockResponder => (r
}
: {}),
spec: {
targetRef: {
kind: 'MeshService',
name: fake.hacker.noun(),
},
from: [
{
targetRef: {
Expand Down
4 changes: 0 additions & 4 deletions src/test-support/mocks/src/meshes/_/meshfaultinjections/_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export default ({ fake, env }: EndpointDependencies): MockResponder => (req) =>
}
: {}),
spec: {
targetRef: {
kind: 'MeshService',
name: fake.hacker.noun(),
},
from: [
{
targetRef: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { EndpointDependencies, MockResponder } from '@/test-support'

export default (_deps: EndpointDependencies): MockResponder => (_req) => {
return {
headers: {},
body: {
total: 3,
items: [
{
type: 'Dataplane',
mesh: 'default',
name: 'backend',
},
{
type: 'Dataplane',
mesh: 'default',
name: 'db',
},
{
type: 'Dataplane',
mesh: 'default',
name: 'frontend',
},
],
next: null,
},
}
}

0 comments on commit 7096832

Please sign in to comment.