Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen committed Nov 7, 2023
1 parent 3c16c27 commit 264b1af
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,18 @@
</template>

<script lang="ts" setup>
import { KCard } from '@kong/kongponents'
import { GlobalInsightSource } from '../sources'
import { useCan } from '@/app/application'
import { useCan, useI18n } from '@/app/application'
import ErrorBlock from '@/app/common/ErrorBlock.vue'
import LoadingBlock from '@/app/common/LoadingBlock.vue'
import ResourceStatus from '@/app/common/ResourceStatus.vue'
import { useI18n } from '@/utilities'
const { t } = useI18n()
const can = useCan()
</script>
<style lang="scss" scoped>
.card-header {
margin-bottom: $kui-space-50;
height: 42px;
min-height: 42px;
}
</style>
File renamed without changes.
33 changes: 32 additions & 1 deletion src/app/control-planes/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
import ControlPlaneStatus from './components/ControlPlaneStatus.vue'
import { features } from './features'
import { routes } from './routes'
import { sources } from './sources'
import type { ServiceDefinition } from '@/services/utils'
import { token } from '@/services/utils'

import { token, createInjections } from '@/services/utils'

type Token = ReturnType<typeof token>

const $ = {
sources: token<ReturnType<typeof sources>>('control-planes.sources'),
ControlPlaneStatus: token<typeof ControlPlaneStatus>('control-planes.components.ControlPlaneStatus'),
}
export const services = (app: Record<string, Token>): ServiceDefinition[] => {
return [
[$.sources, {
service: sources,
arguments: [
app.env,
app.api,
],
labels: [
app.sources,
],
}],
[$.ControlPlaneStatus, {
service: () => {
return ControlPlaneStatus
},
}],
[token('control-planes.routes'), {
service: routes,
labels: [
app.routes,
],
}],
[token('control-planes.features'), {
service: features,
arguments: [
app.env,
],
labels: [
app.features,
],
}],
]
}

export const TOKENS = $
export const [
useControlPlaneStatus,
] = createInjections(
$.ControlPlaneStatus,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const routes = (): RouteRecordRaw[] => {
{
path: `${prefix}`,
name: 'home',
component: () => import('@/app/main-overview/views/MainOverviewView.vue'),
component: () => import('@/app/control-planes/views/item/IndexView.vue'),
},
]
}
14 changes: 10 additions & 4 deletions src/app/control-planes/sources.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { DataSourceResponse } from '@/app/application/services/data-source/DataSourcePool'
import type { DataSourceResponse } from '@/app/application'
import type Env from '@/services/env/Env'
import type KumaApi from '@/services/kuma-api/KumaApi'
import type { GlobalInsight } from '@/types/index.d'

export type ControlPlaneAddresses = {
http: string
kds: string
}

export type ControlPlaneAddressesSource = DataSourceResponse<ControlPlaneAddresses>
export const sources = (env: Env['var']) => {
export type GlobalInsightSource = DataSourceResponse<GlobalInsight>

export const sources = (env: Env['var'], api: KumaApi) => {
return {
'/control-plane/addresses': async (_params: {}, source: { close: () => void }): Promise<ControlPlaneAddresses> => {
source.close()
'/control-plane/addresses': async (): Promise<ControlPlaneAddresses> => {
return {
http: env('KUMA_API_URL'),
kds: 'grpcs://<global-kds-address>:5685',
}
},
'/global-insight': () => {
return api.getGlobalInsight()
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="stack"
data-testid="detail-view-details"
>
<MainOverview />
<ControlPlaneStatus />

<div class="columns">
<KCard v-if="can('use zones')">
Expand Down Expand Up @@ -107,21 +107,23 @@ import { KUI_ICON_SIZE_30 } from '@kong/design-tokens'
import { AddIcon } from '@kong/icons'
import ErrorBlock from '@/app/common/ErrorBlock.vue'
import { useControlPlaneStatus } from '@/app/control-planes'
import MeshInsightsList from '@/app/meshes/components/MeshInsightsList.vue'
import { MeshInsightCollectionSource } from '@/app/meshes/sources'
import type { MeshInsightCollectionSource } from '@/app/meshes/sources'
import ZoneControlPlanesList from '@/app/zones/components/ZoneControlPlanesList.vue'
import { ZoneOverviewCollectionSource } from '@/app/zones/sources'
import { useMainOverview } from '@/components'
const MainOverview = useMainOverview()
import type { ZoneOverviewCollectionSource } from '@/app/zones/sources'
const ControlPlaneStatus = useControlPlaneStatus()
</script>
<style lang="scss" scoped>
.card-header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: $kui-space-50;
// Makes card header the same height as buttons so that they align with or without buttons present.
height: 42px;
min-height: 42px;
}
.card-title {
Expand Down
37 changes: 0 additions & 37 deletions src/app/main-overview/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/main-overview/sources.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import MainView from '@/app/application/components/app-view/MainView.vue'
import MainOverview from '@/app/main-overview/components/MainOverview.vue'
import MeshDetails from '@/app/meshes/components/MeshDetails.vue'
import KubernetesGraph from '@/app/onboarding/components/graphs/KubernetesGraph.vue'
import MemoryGraph from '@/app/onboarding/components/graphs/MemoryGraph.vue'
Expand All @@ -9,7 +8,6 @@ import StandaloneGraph from '@/app/onboarding/components/graphs/StandaloneGraph.
import { constant, createInjections } from '@/services/utils'

export const TOKENS = {
MainOverview: constant(MainOverview, { description: 'MainOverview' }),
KubernetesGraph: constant(KubernetesGraph, { description: 'KubernetesGraph' }),
PostgresGraph: constant(PostgresGraph, { description: 'PostgresGraph' }),
MemoryGraph: constant(MemoryGraph, { description: 'MemoryGraph' }),
Expand All @@ -19,7 +17,6 @@ export const TOKENS = {
MeshDetails: constant(MeshDetails, { description: 'MeshDetails' }),
}
export const [
useMainOverview,
useKubernetesGraph,
usePostgresGraph,
useMemoryGraph,
Expand All @@ -28,7 +25,6 @@ export const [
useMainView,
useMeshDetails,
] = createInjections(
TOKENS.MainOverview,
TOKENS.KubernetesGraph,
TOKENS.PostgresGraph,
TOKENS.MemoryGraph,
Expand Down
4 changes: 2 additions & 2 deletions src/locales/en-us/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import common from './common/index.yaml'
import components from './components/index.yaml'
import http from './http/index.yaml'
import controlplanes from '@/app/control-planes/locales/en-us/index.yaml'
import dataplanes from '@/app/data-planes/locales/en-us/index.yaml'
import diagnostics from '@/app/diagnostics/locales/en-us/index.yaml'
import gateways from '@/app/gateways/locales/en-us/index.yaml'
import mainoverview from '@/app/main-overview/locales/en-us/index.yaml'
import meshes from '@/app/meshes/locales/en-us/index.yaml'
import onboarding from '@/app/onboarding/locales/en-us/index.yaml'
import policies from '@/app/policies/locales/en-us/index.yaml'
Expand All @@ -17,7 +17,7 @@ export default {
...common,
...http,
...components,
...mainoverview,
...controlplanes,
...onboarding,
...diagnostics,
...meshes,
Expand Down
5 changes: 0 additions & 5 deletions src/services/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import createDisabledLogger from './logger/DisabledLogger'
import { TOKENS as _TOKENS } from './tokens'
import { services as application, TOKENS as APPLICATION } from '@/app/application'
import { services as kuma } from '@/app/kuma'
import { services as mainOverview } from '@/app/main-overview'
import { services as me } from '@/app/me'
import { services as meshes } from '@/app/meshes'
import { services as vue, TOKENS as VUE } from '@/app/vue'
Expand Down Expand Up @@ -85,10 +84,6 @@ export const services: ServiceConfigurator<SupportedTokens> = ($) => [
//

// service-mesh
...mainOverview({
...$,
routes: $.routesLabel,
}),
...zones({
...$,
routes: $.routesLabel,
Expand Down
5 changes: 5 additions & 0 deletions test-support/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { beforeEach, afterEach, beforeAll } from 'vitest'

import { TOKENS as TEST, services as testing } from './index'
import { TOKENS as COMPONENT_TOKENS } from '../src/components'
import { services as controlPlanes } from '@/app/control-planes'
import { services as onboarding } from '@/app/onboarding'
import { TOKENS as DEV, services as development } from '@/services/development'
import { TOKENS as PROD, services as production } from '@/services/production'
Expand All @@ -22,6 +23,10 @@ const $ = {
(async () => {
build(
production($),
controlPlanes({
...$,
routes: $.routesLabel,
}),
onboarding({
...$,
routes: $.routesLabel,
Expand Down

0 comments on commit 264b1af

Please sign in to comment.