diff --git a/packages/kuma-gui/src/app/application/index.ts b/packages/kuma-gui/src/app/application/index.ts index dc6333ea3..56ce621f5 100644 --- a/packages/kuma-gui/src/app/application/index.ts +++ b/packages/kuma-gui/src/app/application/index.ts @@ -102,6 +102,26 @@ const addPath = (item: RouteRecordRaw, parent?: RouteRecordRaw) => { item.meta.path = `${path}${path.length > 0 ? '.' : ''}${String(item.name)}` } } +const addRouteName = (item: RouteRecordRaw) => { + if (typeof item.name !== 'undefined') { + const props = ((props) => { + switch (true) { + case typeof props === 'function': + return props + case typeof props === 'undefined': + return () => ({}) + default: + return () => props + } + })(item.props) + item.props = (...args) => { + return { + ...props(...args), + routeName: item.name, + } + } + } +} export const services = (app: Record): ServiceDefinition[] => { return [ @@ -140,6 +160,7 @@ export const services = (app: Record): ServiceDefinition[] => { return [ addModule, addPath, + addRouteName, ] }, labels: [ diff --git a/packages/kuma-gui/src/app/data-planes/routes.ts b/packages/kuma-gui/src/app/data-planes/routes.ts index 6f5ab29d1..af8e07506 100644 --- a/packages/kuma-gui/src/app/data-planes/routes.ts +++ b/packages/kuma-gui/src/app/data-planes/routes.ts @@ -63,26 +63,17 @@ export const routes = () => { { path: ':dataPlane', name: `${fullPrefix}data-plane-summary-view`, - props: () => ({ - routeName: `${fullPrefix}data-plane-summary-view`, - }), redirect: { name: `${fullPrefix}data-plane-summary-overview-view` }, component: () => import('@/app/data-planes/views/DataPlaneSummaryView.vue'), children: [ { path: 'summary-overview', name: `${fullPrefix}data-plane-summary-overview-view`, - props: () => ({ - routeName: `${fullPrefix}data-plane-summary-overview-view`, - }), component: () => import('@/app/data-planes/views/DataPlaneSummaryOverviewView.vue'), }, { path: 'summary-config', name: `${fullPrefix}data-plane-summary-config-view`, - props: () => ({ - routeName: `${fullPrefix}data-plane-summary-config-view`, - }), component: () => import('@/app/data-planes/views/DataPlaneSummaryConfigView.vue'), }, ], diff --git a/packages/kuma-gui/src/app/subscriptions/routes.ts b/packages/kuma-gui/src/app/subscriptions/routes.ts index c279f9e75..fd24ae2eb 100644 --- a/packages/kuma-gui/src/app/subscriptions/routes.ts +++ b/packages/kuma-gui/src/app/subscriptions/routes.ts @@ -5,25 +5,16 @@ export const routes = (prefix: string): RouteRecordRaw[] => { path: 'subscription/:subscription', name: `${prefix}-subscription-summary-view`, redirect: { name: `${prefix}-subscription-summary-overview-view` }, - props: () => ({ - routeName: `${prefix}-subscription-summary-view`, - }), component: () => import('@/app/subscriptions/views/SubscriptionSummaryView.vue'), children: [ { path: 'overview', name: `${prefix}-subscription-summary-overview-view`, - props: () => ({ - routeName: `${prefix}-subscription-summary-overview-view`, - }), component: () => import('@/app/subscriptions/views/SubscriptionSummaryOverviewView.vue'), }, { path: 'config', name: `${prefix}-subscription-summary-config-view`, - props: () => ({ - routeName: `${prefix}-subscription-summary-config-view`, - }), component: () => import('@/app/subscriptions/views/SubscriptionSummaryConfigView.vue'), }, ],