Skip to content

Commit

Permalink
fix(dataplanes): Correct Dataplane Inbound cluster tab filter
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen committed Nov 28, 2024
1 parent 765d9f5 commit 625a4cf
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 66 deletions.
6 changes: 4 additions & 2 deletions packages/kuma-gui/cypress/support/step_definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,12 @@ Then(/^the "(.*)" element(s)? contain[s]?$/, (selector: string, multiple = '', t
})
}
})
Then(/^the "(.*)" element contains "(.*)"$/, (selector: string, value: string) => {
Then(/^the "(.*)" element( doesn't | )contain[s]? "(.*)"$/, (selector: string, assertion: string, value: string) => {
$(selector).then(($el) => {
const negative = assertion !== ' '
const prefix = negative ? 'not.' : ''
const chainer = $el[0].tagName === 'INPUT' ? 'have.value' : 'contain'
$(selector).should(chainer, value)
$(selector).should(`${prefix}${chainer}`, value)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,56 @@
connection: '',
}"
name="connection-inbound-summary-clusters-view"
v-slot="{ route }"
v-slot="{ route, uri }"
>
<RouteTitle
:render="false"
:title="`Clusters`"
/>
<AppView>
<DataLoader
:src="`/meshes/${route.params.mesh}/dataplanes/${route.params.dataPlane}/data-path/clusters`"
v-slot="{ data: clusters, refresh }: ClustersDataSource"
:src="uri(sources, '/meshes/:mesh/dataplanes/:name/clusters', {
mesh: route.params.mesh,
name: route.params.dataPlane,
})"
v-slot="{ data , refresh }"
>
<DataCollection
:items="clusters!.split('\n')"
:predicate="item => item.startsWith(`${props.data.service}::`)"
v-slot="{ items: lines }"
<template
v-for="prefix in [route.params.connection.replace('_', ':')]"
:key="typeof prefix"
>
<XCodeBlock
language="json"
:code="lines.map(item => item.replace(`${props.data.service}::`, '')).join('\n')"
is-searchable
:query="route.params.codeSearch"
:is-filter-mode="route.params.codeFilter"
:is-reg-exp-mode="route.params.codeRegExp"
@query-change="route.update({ codeSearch: $event })"
@filter-mode-change="route.update({ codeFilter: $event })"
@reg-exp-mode-change="route.update({ codeRegExp: $event })"
<DataCollection
:items="data.split('\n')"
:predicate="item => item.startsWith(`${prefix}::`)"
v-slot="{ items: lines }"
>
<template #primary-actions>
<XAction
action="refresh"
appearance="primary"
@click="refresh"
>
Refresh
</XAction>
</template>
</XCodeBlock>
</DataCollection>
<XCodeBlock
language="json"
:code="lines.map(item => item.replace(`${prefix}::`, '')).join('\n')"
is-searchable
:query="route.params.codeSearch"
:is-filter-mode="route.params.codeFilter"
:is-reg-exp-mode="route.params.codeRegExp"
@query-change="route.update({ codeSearch: $event })"
@filter-mode-change="route.update({ codeFilter: $event })"
@reg-exp-mode-change="route.update({ codeRegExp: $event })"
>
<template #primary-actions>
<XAction
action="refresh"
appearance="primary"
@click="refresh"
>
Refresh
</XAction>
</template>
</XCodeBlock>
</DataCollection>
</template>
</DataLoader>
</AppView>
</RouteView>
</template>
<script lang="ts" setup>
import type { DataplaneInbound } from '@/app/data-planes/data'
import type { ClustersDataSource } from '@/app/data-planes/sources'
const props = defineProps<{
data: DataplaneInbound
}>()
import { sources } from '@/app/data-planes/sources'
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,56 @@
connection: '',
}"
name="connection-outbound-summary-clusters-view"
v-slot="{ route }"
v-slot="{ route, uri }"
>
<RouteTitle
:render="false"
:title="`Clusters`"
/>
<AppView>
<DataLoader
:src="`/meshes/${route.params.mesh}/dataplanes/${route.params.dataPlane}/data-path/clusters`"
v-slot="{ data, refresh }: ClustersDataSource"
:src="uri(sources, '/meshes/:mesh/dataplanes/:name/clusters', {
mesh: route.params.mesh,
name: route.params.dataPlane,
})"
v-slot="{ data, refresh }"
>
<DataCollection
:items="data!.split('\n')"
:predicate="item => item.startsWith(`${route.params.connection}::`)"
v-slot="{ items: lines }"
<template
v-for="prefix in [route.params.connection]"
:key="typeof prefix"
>
<XCodeBlock
language="json"
:code="lines.map(item => item.replace(`${route.params.connection}::`, '')).join('\n')"
is-searchable
:query="route.params.codeSearch"
:is-filter-mode="route.params.codeFilter"
:is-reg-exp-mode="route.params.codeRegExp"
@query-change="route.update({ codeSearch: $event })"
@filter-mode-change="route.update({ codeFilter: $event })"
@reg-exp-mode-change="route.update({ codeRegExp: $event })"
<DataCollection
:items="data.split('\n')"
:predicate="item => item.startsWith(`${prefix}::`)"
v-slot="{ items: lines }"
>
<template #primary-actions>
<XAction
action="refresh"
appearance="primary"
@click="refresh"
>
Refresh
</XAction>
</template>
</XCodeBlock>
</DataCollection>
<XCodeBlock
language="json"
:code="lines.map(item => item.replace(`${prefix}::`, '')).join('\n')"
is-searchable
:query="route.params.codeSearch"
:is-filter-mode="route.params.codeFilter"
:is-reg-exp-mode="route.params.codeRegExp"
@query-change="route.update({ codeSearch: $event })"
@filter-mode-change="route.update({ codeFilter: $event })"
@reg-exp-mode-change="route.update({ codeRegExp: $event })"
>
<template #primary-actions>
<XAction
action="refresh"
appearance="primary"
@click="refresh"
>
Refresh
</XAction>
</template>
</XCodeBlock>
</DataCollection>
</template>
</DataLoader>
</AppView>
</RouteView>
</template>
<script lang="ts" setup>
import type { ClustersDataSource } from '@/app/data-planes/sources'
import { sources } from '@/app/data-planes/sources'
</script>
10 changes: 9 additions & 1 deletion packages/kuma-gui/src/app/data-planes/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const sources = (source: Source, api: KumaApi, can: Can) => {
'/meshes/:mesh/dataplanes/:name/as/kubernetes': async (params) => {
return api.getDataplaneFromMesh(params, { format: 'kubernetes' })
},

// @deprecated please use either /xds, /clusters or /stats endpoints (ie. without /data-path)
'/meshes/:mesh/dataplanes/:name/data-path/:dataPath': async (params) => {
const { mesh, name } = params
const dataPath = includes(['xds', 'clusters', 'stats'] as const, params.dataPath) ? params.dataPath : 'xds'
Expand All @@ -87,6 +87,14 @@ export const sources = (source: Source, api: KumaApi, can: Can) => {
dataPath,
})
},
'/meshes/:mesh/dataplanes/:name/clusters': async (params) => {
const { mesh, name } = params
return api.getDataplaneData({
mesh,
dppName: name,
dataPath: 'clusters',
})
},
'/meshes/:mesh/dataplanes/:name/xds/:endpoints': async (params) => {
const { mesh, name, endpoints } = params

Expand Down

0 comments on commit 625a4cf

Please sign in to comment.