Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix basic scenario of built-in (embedded) extention #264

Merged
merged 6 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dashboard/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
/dist
dist-pkg
/tmp
/out-tsc

Expand Down Expand Up @@ -70,4 +71,4 @@ jspm_packages/

# System Files
.DS_Store
Thumbs.db
Thumbs.db
8 changes: 4 additions & 4 deletions dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Node 16.15.0 or lower, `yarn`
1) UI Dev Only Step - Setup the Rancher Dashboard repo
- Clone https://github.com/rancher/dashboard and checkout `epinio-dev`
- Run `cd shell && yarn link`
2) Clone https://github.com/epinio/ui and checkout `main`
3) UI Dev Only Step - Link in Rancher Dashboard packages
1) Clone https://github.com/epinio/ui and checkout `main`
1) UI Dev Only Step - Link in Rancher Dashboard packages
- Run `cd <epini/ui root>/dashboard && yarn link @rancher/shell`
4) Run `yarn install`
5) Run `EXCLUDES_PKG=harvester,rancher-components EXCLUDE_OPERATOR_PKG=true RANCHER_ENV=epinio API=https://localhost:5443 yarn dev`
1) Run `yarn install`
1) Run `EXCLUDES_PKG=harvester,rancher-components EXCLUDE_OPERATOR_PKG=true RANCHER_ENV=epinio API=https://localhost:5443 yarn dev`

## Getting Started - Run in embedded Mode
Update to follow
6 changes: 3 additions & 3 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"node": ">=12"
},
"dependencies": {
"@rancher/components": "0.1.3",
"@rancher/shell": "^0.3.15",
"@types/lodash": "4.14.184",
"core-js": "3.21.1",
"css-loader": "6.7.3"
"css-loader": "6.7.3",
"@types/lodash": "4.14.184",
"@rancher/components": "0.1.3"
},
"resolutions": {
"**/webpack": "4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
value: s.metadata.name,
}));

return sortBy(list, 'label');
return sortBy(list, 'label', false);
},

namespacedServices() {
Expand All @@ -82,7 +82,7 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
value: s,
}));

return sortBy(list, 'label');
return sortBy(list, 'label', false);
},

noConfigs() {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/components/application/AppInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default Vue.extend<Data, any, any, any>({

computed: {
namespaces() {
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name');
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name', false);
},

namespaceNames() {
Expand Down
6 changes: 3 additions & 3 deletions dashboard/pkg/epinio/components/application/AppSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export default Vue.extend<Data, any, any, any>({
return res;
}, {} as { [key: string]: any});

generateZip(filesToZip).then((zip) => {
generateZip(filesToZip).then((zip: any) => {
Vue.set(this.archive, 'tarball', zip);
Vue.set(this.archive, 'fileName', folderName || 'folder');

Expand Down Expand Up @@ -370,11 +370,11 @@ export default Vue.extend<Data, any, any, any>({
},

namespaces() {
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name');
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name', false);
},

appCharts() {
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.APP_CHARTS), 'name').map((ap: EpinioApplicationChartResource) => ({
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.APP_CHARTS), 'name', false).map((ap: EpinioApplicationChartResource) => ({
value: ap.meta.name,
label: `${ ap.meta.name } (${ ap.short_description })`
}));
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/edit/applications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
},

updateSource(changes: EpinioAppSource) {
this.source = {};
this.source = {} as EpinioAppSource;
const { appChart, ...cleanChanges } = changes;

this.value.configuration = this.value.configuration || {};
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/edit/configurations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
...mapGetters({ t: 'i18n/t' }),

namespaces() {
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name');
return sortBy(this.$store.getters['epinio/all'](EPINIO_TYPES.NAMESPACE), 'name', false);
},

namespaceNames() {
Expand Down
9 changes: 6 additions & 3 deletions dashboard/pkg/epinio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import epinioRoutes from './routing/epinio-routing';
import epinioMgmtStore from './store/epinio-mgmt-store';
import epinioStore from './store/epinio-store';

const onEnter: OnNavToPackage = async(store, config) => {
await store.dispatch(`${ epinioMgmtStore.config.namespace }/loadManagement`);
await store.dispatch(`${ epinioStore.config.namespace }/info`);
const onEnter: OnNavToPackage = async({ getters, dispatch }, config) => {
await dispatch(`${ epinioMgmtStore.config.namespace }/loadManagement`);

if (getters['isSingleProduct']) {
dispatch(`${ epinioStore.config.namespace }/info`); // We can get this in the background
}
};

const onLeave: OnNavAwayFromPackage = async(store, config) => {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/models/application-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const APPLICATION_ACTION_TYPE = {

export default class ApplicationActionResource extends Resource {
constructor(...args) {
super(args);
super(...args);

// Props ---------------------------------------------------
this.run = true;
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/models/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function isGitRepo(type) {

export default class EpinioApplicationModel extends EpinioNamespacedResource {
constructor(...args) {
super(args);
super(...args);

// Props ---------------------------------------------------
this.buildCache = {};
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/models/epinio-namespaced-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const bulkRemove = async(items, opt = {}) => {

export default class EpinioMetaResource extends EpinioResource {
constructor(...args) {
super(args);
super(...args);
if (!this.meta) {
this.meta = {
name: '',
Expand Down
8 changes: 5 additions & 3 deletions dashboard/pkg/epinio/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ export default Vue.extend<Data, any, any, any>({
}
});

this.$store.dispatch('epinio/request', { opt: { url: `/ready` }, clusterId: c.id })
.then(() => this.$store.dispatch(`epinio/request`, { opt: { url: `/api/v1/info` }, clusterId: c.id }))
// Calls to `/ready` currently throw CORS error (but not `/api/v1`). This code block will probably change given auth stuff
// this.$store.dispatch('epinio/request', { opt: { url: `/ready` }, clusterId: c.id })
this.$store.dispatch(`epinio/request`, { opt: { url: `/api/v1/info` }, clusterId: c.id })
// .then(() => this.$store.dispatch(`epinio/request`, { opt: { url: `/api/v1/info` }, clusterId: c.id }))
.then((res: any) => {
Vue.set(c, 'version', res?.version);
this.setClusterState(c, 'available', { state: { transitioning: false } });
Expand Down Expand Up @@ -156,7 +158,7 @@ export default Vue.extend<Data, any, any, any>({
<div class="epinio-row">
<n-link
v-if="row.state === 'available'"
:to="{name: 'epinio-c-cluster-applications', params: {cluster: row.id}}"
:to="{name: 'epinio-c-cluster-dashboard', params: {cluster: row.id}}"
>
{{ row.name }}
</n-link>
Expand Down
31 changes: 25 additions & 6 deletions dashboard/pkg/epinio/routing/epinio-routing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { RouteConfig } from 'vue-router';

import { EPINIO_PRODUCT_NAME } from '../types';
Expand All @@ -12,43 +13,61 @@ import CreateEpinioResource from '../pages/c/_cluster/_resource/create.vue';
import ViewEpinioResource from '../pages/c/_cluster/_resource/_id.vue';
import ViewEpinioNsResource from '../pages/c/_cluster/_resource/_namespace/_id.vue';

const meta = {
product: EPINIO_PRODUCT_NAME,
pkg: EPINIO_PRODUCT_NAME
};

const routes: RouteConfig[] = [{
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-dashboard`,
path: `/:product/c/:cluster/dashboard`,
component: Dashboard,
},
{
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-applications-createapp`,
path: `/:product/c/:cluster/applications/createapp`,
component: CreateApp,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-applications`,
path: `/:product/c/:cluster/applications`,
component: ListApp,
}, {
name: `${ EPINIO_PRODUCT_NAME }-applications`,
path: `/:product/application`,
component: ListEpinio,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-about`,
path: `/:product/c/:cluster/about`,
component: AboutEpinio,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-resource`,
path: `/:product/c/:cluster/:resource`,
component: ListEpinioResource,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-resource-create`,
path: `/:product/c/:cluster/:resource/create`,
component: CreateEpinioResource,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-resource-id`,
path: `/:product/c/:cluster/:resource/:id`,
component: ViewEpinioResource,
meta
}, {
name: `${ EPINIO_PRODUCT_NAME }-c-cluster-resource-namespace-id`,
path: `/:product/c/:cluster/:resource/:namespace/:id`,
component: ViewEpinioNsResource,
meta
}];

const isEpinioSingleProduct = process.env.rancherEnv === 'epinio';

if (!isEpinioSingleProduct) {
routes.unshift({
name: `${ EPINIO_PRODUCT_NAME }`,
path: `/:product/`,
component: ListEpinio,
});
}

export default routes;
23 changes: 11 additions & 12 deletions dashboard/pkg/epinio/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
"sourceMap": true,
"baseUrl": ".",
"preserveSymlinks": true,
"typeRoots": [
"../../node_modules",
"../../node_modules/@rancher/shell/types"
],
"types": [
"node",
"webpack-env",
"@types/node",
"@types/jest",
"@types/lodash",
"@nuxt/types",
"rancher",
"shell"
],
"lib": [
"esnext",
Expand All @@ -31,25 +38,17 @@
"../../node_modules/@rancher/shell/*"
],
"@components/*": [
"../../node_modules/@rancher/components/*"
],
"@pkg/*": [
"./*"
"@rancher/components/*"
]
}
},
"include": [
"**/*.ts",
"**/*.d.ts",
"**/*.tsx",
"**/*.vue",
"@rancher/shell/types/*.d.ts",
"@rancher/shell/core/*.ts",
"@rancher/shell/config/**/*.js",
"**/*.yaml",
"../../vue-shim.d.ts",
"**/*.vue"
],
"exclude": [
"node_modules"
"../../node_modules"
]
}
}
23 changes: 17 additions & 6 deletions dashboard/pkg/epinio/utils/epinio-discovery.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EPINIO_TYPES } from '../types';

import { MANAGEMENT } from '@shell/config/types';
import { base64Decode } from '@shell/utils/crypto';
import { ingressFullPath } from '@shell/models/networking.k8s.io.ingress';
import { allHash } from '@shell/utils/promise';

Expand All @@ -16,18 +15,30 @@ export default {
const epinioIngress = await store.dispatch(`cluster/request`, { url: `/k8s/clusters/${ c.id }/v1/networking.k8s.io.ingresses/epinio/epinio` }, { root: true });
const url = ingressFullPath(epinioIngress, epinioIngress.spec.rules?.[0]);

const epinio: any = await allHash({ authData: store.dispatch(`cluster/request`, { url: `/k8s/clusters/${ c.id }/v1/secrets/epinio/default-epinio-user` }, { root: true }) });
let username;
let password;

const username = epinio.authData.data.username;
const password = epinio.authData.data.password;
if (url) {
// TODO: RC hack
username = 'admin';
password = 'password';
} else {
// TODO: RC old
const epinio: any = await allHash({ authData: store.dispatch(`cluster/request`, { url: `/k8s/clusters/${ c.id }/v1/secrets/epinio/default-epinio-user` }, { root: true }) });

username = epinio.authData.data.username;
password = epinio.authData.data.password;
}

epinioClusters.push({
id: c.id,
name: c.spec.displayName,
api: url,
readyApi: `${ url }/ready`,
username: base64Decode(username),
password: base64Decode(password),
// username: base64Decode(username),
// password: base64Decode(password),
username,
password,
type: EPINIO_TYPES.INSTANCE,
mgmtCluster: c
});
Expand Down
5 changes: 3 additions & 2 deletions dashboard/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@/*": [
"./*"
],
"@shell/*": [
"./node_modules/@rancher/shell/*"
"@components/*": [
"./node_modules/@rancher/components/*"
]
},
"typeRoots": [
Expand All @@ -31,6 +31,7 @@
],
"types": [
"@types/node",
"@nuxt/types",
"cypress",
"rancher",
"shell"
Expand Down
12 changes: 6 additions & 6 deletions dashboard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5488,9 +5488,9 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, can
integrity sha512-F6x5IEuigtUfU5ZMQK2jsy5JqUUlEFRVZq8bO2a+ysq5K7jD6PPc9YXZj78xDNS3uNchesp1Jw47YXEqr+Viyg==

caniuse-lite@^1.0.30001503:
version "1.0.30001508"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001508.tgz#4461bbc895c692a96da399639cc1e146e7302a33"
integrity sha512-sdQZOJdmt3GJs1UMNpCCCyeuS2IEGLXnHyAo9yIO5JJDjbjoVRij4M1qep6P6gFpptD1PqIYgzM+gwJbOi92mw==
version "1.0.30001509"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001509.tgz#2b7ad5265392d6d2de25cd8776d1ab3899570d14"
integrity sha512-2uDDk+TRiTX5hMcUYT/7CSyzMZxjfGu0vAUjS2g0LSD8UoXOv0LtpH4LxGMemsiPq6LCVIUjNwVM0erkOkGCDA==

case-sensitive-paths-webpack-plugin@^2.3.0:
version "2.4.0"
Expand Down Expand Up @@ -7650,9 +7650,9 @@ electron-to-chromium@^1.4.411:
integrity sha512-wv1NufHxu11zfDbY4fglYQApMswleE9FL/DSeyOyauVXDZ+Kco96JK/tPfBUaDqfRarYp2WH2hJ/5UnVywp9Jg==

electron-to-chromium@^1.4.431:
version "1.4.440"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.440.tgz#d3b1eeb36b717eb479a240c0406ac1fa67901762"
integrity sha512-r6dCgNpRhPwiWlxbHzZQ/d9swfPaEJGi8ekqRBwQYaR3WmA5VkqQfBWSDDjuJU1ntO+W9tHx8OHV/96Q8e0dVw==
version "1.4.442"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.442.tgz#455f4c5bd6ae73afb634dcffee6f356c26c8e294"
integrity sha512-RkrZF//Ya+0aJq2NM3OdisNh5ZodZq1rdXOS96G8DdDgpDKqKE81yTbbQ3F/4CKm1JBPsGu1Lp/akkna2xO06Q==

element-matches@^0.1.2:
version "0.1.2"
Expand Down