From 2ec8dad6398a76ddac2180551cd63916b6ef9de0 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 24 Jul 2023 17:54:29 +0100 Subject: [PATCH 1/4] fix service typing and 'version' colour --- dashboard/pkg/epinio/edit/services.vue | 6 +++-- .../pkg/epinio/pages/c/_cluster/dashboard.vue | 26 ++++++++++++------- dashboard/pkg/epinio/types.ts | 2 +- dashboard/pkg/epinio/utils/custom-routing.ts | 25 +++++++++++------- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/dashboard/pkg/epinio/edit/services.vue b/dashboard/pkg/epinio/edit/services.vue index e963669..173887d 100644 --- a/dashboard/pkg/epinio/edit/services.vue +++ b/dashboard/pkg/epinio/edit/services.vue @@ -6,7 +6,9 @@ import CruResource from '@shell/components/CruResource.vue'; import Loading from '@shell/components/Loading.vue'; import { epinioExceptionToErrorsArray } from '../utils/errors'; import LabeledSelect from '@shell/components/form/LabeledSelect.vue'; -import { EpinioCatalogServiceResource, EPINIO_TYPES, EpinioNamespace, EpinioCompRecord } from '../types'; +import { + EpinioCatalogServiceResource, EPINIO_TYPES, EpinioNamespace, EpinioCompRecord, EpinioCatalogService +} from '../types'; import { validateKubernetesName } from '@shell/utils/validators/kubernetes-name'; import NameNsDescription from '@shell/components/form/NameNsDescription.vue'; import EpinioBindAppsMixin from './bind-apps-mixin.js'; @@ -94,7 +96,7 @@ export default Vue.extend ({ + return this.$store.getters['epinio/all'](EPINIO_TYPES.CATALOG_SERVICE).map((cs: EpinioCatalogService) => ({ label: `${ cs.name } (${ cs.short_description })`, value: cs.name })); diff --git a/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue b/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue index 80beaab..a0f2478 100644 --- a/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue +++ b/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue @@ -8,6 +8,13 @@ import Namespace from '@shell/models/namespace'; import EpinioServiceModel from '../../../models/services'; import isEqual from 'lodash/isEqual'; import { sortBy } from 'lodash'; +import { Location } from 'vue-router'; + +type ComponentService = { + name: string, + link: Location, + isEnabled: boolean +} export default Vue.extend({ components: { DashboardCard, ConsumptionGauge }, @@ -113,21 +120,20 @@ export default Vue.extend({ const fetchServices: EpinioCatalogService[] = this.$store.getters['epinio/all'](EPINIO_TYPES.CATALOG_SERVICE); // Try to find the desired services - const findDesiredServices = fetchServices?.filter((service) => service?.shortId === 'mysql-dev' || service?.shortId === 'redis-dev'); + const findDesiredServices = fetchServices?.filter((service) => service.id === 'mysql-dev' || service.id === 'redis-dev'); // if not found, return the first two services from the catalog - const services: EpinioCatalogService[] | any = - findDesiredServices.length ? findDesiredServices : fetchServices.slice(0, 2); + const services: EpinioCatalogService[] = findDesiredServices.length ? findDesiredServices : fetchServices.slice(0, 2); - const s = services.reduce((acc: any[], service: { shortId: string; }) => { + const s = services.reduce((acc: ComponentService[], service: EpinioCatalogService) => { acc.push({ - link: createEpinioRoute('c-cluster-resource-create', { resource: EPINIO_TYPES.SERVICE_INSTANCE, name: service?.shortId }, { query: { service: service?.shortId } }), - shortId: service?.shortId, + link: createEpinioRoute('c-cluster-resource-create', { resource: EPINIO_TYPES.SERVICE_INSTANCE, name: service.id }, { query: { service: service.id } }), + name: service.name, isEnabled: true }); return acc; - }, []); + }, [] as ComponentService[]); return { servicesInstances: fetchServicesInstances.length, @@ -239,7 +245,7 @@ export default Vue.extend({ :to="service.link" class="link" > - {{ service.shortId }} + {{ service.name }} + @@ -247,7 +253,7 @@ export default Vue.extend({ v-if="!service.isEnabled" class="link disabled" > - {{ service.shortId }} + {{ service.name }} + @@ -288,7 +294,7 @@ export default Vue.extend({ span { background: var(--primary); - color: var(--default); + color: var(--body-text); border-radius: var(--border-radius); padding: 4px 8px; } diff --git a/dashboard/pkg/epinio/types.ts b/dashboard/pkg/epinio/types.ts index 092be47..1644ec4 100644 --- a/dashboard/pkg/epinio/types.ts +++ b/dashboard/pkg/epinio/types.ts @@ -182,7 +182,7 @@ export interface EpinioHelmRepoResource { } export interface EpinioCatalogServiceResource { - name: string, + id: string, description: string, short_description: string, // eslint-disable-line camelcase chart: string, diff --git a/dashboard/pkg/epinio/utils/custom-routing.ts b/dashboard/pkg/epinio/utils/custom-routing.ts index 2f531eb..c3d5875 100644 --- a/dashboard/pkg/epinio/utils/custom-routing.ts +++ b/dashboard/pkg/epinio/utils/custom-routing.ts @@ -1,15 +1,22 @@ import { EPINIO_PRODUCT_NAME } from '../types'; -export const rootEpinioRoute = () => ({ +import { Location } from 'vue-router'; +type Dictionary = { [key: string]: T } + +export const rootEpinioRoute = (): Location => ({ name: EPINIO_PRODUCT_NAME, params: { product: EPINIO_PRODUCT_NAME } }); -export const createEpinioRoute = (name: string, params: Object, query?: Object) => ({ - name: `${ rootEpinioRoute().name }-${ name }`, - params: { - ...rootEpinioRoute().params, - ...params - }, - ...query -}); +export const createEpinioRoute = (name: string, params: Dictionary, query?: Object): Location => { + const rootParams = rootEpinioRoute().params || {}; + + return { + name: `${ rootEpinioRoute().name }-${ name }`, + params: { + ...rootParams, + ...params + }, + ...query + }; +}; From e904be8f183af31fdb49430aa4d6d99bbe6b1dac Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 24 Jul 2023 18:09:06 +0100 Subject: [PATCH 2/4] update readme with quicker way to dev embedded extension --- docs/developer/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/developer/README.md b/docs/developer/README.md index c64cb08..e8cbe36 100644 --- a/docs/developer/README.md +++ b/docs/developer/README.md @@ -12,6 +12,12 @@ The Epinio UI is currently served via the [Rancher Dashboard](https://github.com > Follow the Epinio docs or [this guide](install-epinio.md) to install an Epinio instance locally ##### Developer Flow +Option A - Run the extension 'built-in' +1. `cd dashboard` +2. `API= yarn mem-dev` + +Option B - Run the extension in a local Rancher +1. Build and run the rancher dashboard locally. This should be from the `rancher/dashboard` repo (see README there) 1. Build and serve the epinio extension - `cd dashboard` - `yarn build-pkg epinio` From 3a24f64869947e041933dce39f2a83623b605cf8 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 24 Jul 2023 18:09:21 +0100 Subject: [PATCH 3/4] Add link to about page in embedded world --- dashboard/pkg/epinio/l10n/en-us.yaml | 1 + dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dashboard/pkg/epinio/l10n/en-us.yaml b/dashboard/pkg/epinio/l10n/en-us.yaml index f8ca260..62fd273 100644 --- a/dashboard/pkg/epinio/l10n/en-us.yaml +++ b/dashboard/pkg/epinio/l10n/en-us.yaml @@ -60,6 +60,7 @@ epinio: noNamespaces: Create a Namespace, then create your Applications getStarted: Get started issues: Issues + about: About cards: namespaces: linkText: Create Namespace diff --git a/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue b/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue index a0f2478..9ea9b59 100644 --- a/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue +++ b/dashboard/pkg/epinio/pages/c/_cluster/dashboard.vue @@ -63,7 +63,8 @@ export default Vue.extend({ colorStops: { 0: '--info', 30: '--info', 70: '--info' }, - version: null + version: null, + aboutLink: !this.$store.getters['isSingleProduct'] ? createEpinioRoute('c-cluster-about', { cluster: this.$store.getters['clusterId'] }) : null }; }, created() { @@ -189,6 +190,12 @@ export default Vue.extend({ target="_blank" rel="noopener noreferrer nofollow" >{{ t('epinio.intro.issues') }} + + {{ t('epinio.intro.about') }} +
From 2d3aba16bf1f0607f07f2d708269aca5e2275c0b Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 24 Jul 2023 18:16:36 +0100 Subject: [PATCH 4/4] Fix linting --- dashboard/pkg/epinio/edit/services.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dashboard/pkg/epinio/edit/services.vue b/dashboard/pkg/epinio/edit/services.vue index 173887d..faae808 100644 --- a/dashboard/pkg/epinio/edit/services.vue +++ b/dashboard/pkg/epinio/edit/services.vue @@ -6,9 +6,7 @@ import CruResource from '@shell/components/CruResource.vue'; import Loading from '@shell/components/Loading.vue'; import { epinioExceptionToErrorsArray } from '../utils/errors'; import LabeledSelect from '@shell/components/form/LabeledSelect.vue'; -import { - EpinioCatalogServiceResource, EPINIO_TYPES, EpinioNamespace, EpinioCompRecord, EpinioCatalogService -} from '../types'; +import { EPINIO_TYPES, EpinioNamespace, EpinioCompRecord, EpinioCatalogService } from '../types'; import { validateKubernetesName } from '@shell/utils/validators/kubernetes-name'; import NameNsDescription from '@shell/components/form/NameNsDescription.vue'; import EpinioBindAppsMixin from './bind-apps-mixin.js';