From 969580b770cdd4972d5aed9ceac574b45348da2f Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Sat, 17 Dec 2022 15:59:59 +0800 Subject: [PATCH] fix: Instance Relation and Endpoint Relation dashboards show up (#209) --- src/components/Graph.vue | 7 ++++ src/store/modules/topology.ts | 8 +++- src/types/components.d.ts | 1 - .../topology/components/PodTopology.vue | 15 ++++++- tests/e2e/.eslintrc.js | 26 ------------ tests/e2e/plugins/index.js | 41 ------------------- tests/e2e/specs/test.js | 24 ----------- tests/e2e/support/commands.js | 41 ------------------- tests/e2e/support/index.js | 36 ---------------- tests/unit/example.spec.ts | 23 ----------- 10 files changed, 26 insertions(+), 196 deletions(-) delete mode 100644 tests/e2e/.eslintrc.js delete mode 100644 tests/e2e/plugins/index.js delete mode 100644 tests/e2e/specs/test.js delete mode 100644 tests/e2e/support/commands.js delete mode 100644 tests/e2e/support/index.js delete mode 100644 tests/unit/example.spec.ts diff --git a/src/components/Graph.vue b/src/components/Graph.vue index 24fb20e2..c7ff2f91 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -96,6 +96,10 @@ limitations under the License. --> } instance.on("click", (params: EventParams) => { currentParams.value = params; + if (props.option.series.type === "sankey") { + emits("select", currentParams.value); + return; + } if (!menus.value || !chartRef.value) { return; } @@ -113,6 +117,9 @@ limitations under the License. --> menus.value.style.top = params.event.offsetY + 2 + "px"; } }); + if (props.option.series.type === "sankey") { + return; + } document.addEventListener( "click", () => { diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts index 960a2579..2a4fbb8e 100644 --- a/src/store/modules/topology.ts +++ b/src/store/modules/topology.ts @@ -191,9 +191,13 @@ export const topologyStore = defineStore({ return res.data.data.topology; }, async getInstanceTopology() { - const serverServiceId = useSelectorStore().currentService.id; - const clientServiceId = useSelectorStore().currentDestService.id; + const { currentService, currentDestService } = useSelectorStore(); + const serverServiceId = (currentService && currentService.id) || ""; + const clientServiceId = (currentDestService && currentDestService.id) || ""; const duration = useAppStoreWithOut().durationTime; + if (!(serverServiceId && clientServiceId)) { + return; + } const res: AxiosResponse = await graphql.query("getInstanceTopology").params({ clientServiceId, serverServiceId, diff --git a/src/types/components.d.ts b/src/types/components.d.ts index 05ec63bd..fa07aadd 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -22,7 +22,6 @@ declare module '@vue/runtime-core' { ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup'] ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] - ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] ElPopover: typeof import('element-plus/es')['ElPopover'] ElProgress: typeof import('element-plus/es')['ElProgress'] ElRadio: typeof import('element-plus/es')['ElRadio'] diff --git a/src/views/dashboard/related/topology/components/PodTopology.vue b/src/views/dashboard/related/topology/components/PodTopology.vue index 506b1544..cc63d346 100644 --- a/src/views/dashboard/related/topology/components/PodTopology.vue +++ b/src/views/dashboard/related/topology/components/PodTopology.vue @@ -105,7 +105,7 @@ limitations under the License. --> window.addEventListener("resize", resize); }); - async function loadTopology(id: string) { + async function loadTopology(id?: string) { loading.value = true; const resp = await getTopology(id); loading.value = false; @@ -212,7 +212,7 @@ limitations under the License. --> loadTopology(selectorStore.currentPod.id); } - async function getTopology(id: string) { + async function getTopology(id?: string) { let resp; switch (dashboardStore.entity) { case EntityType[2].value: @@ -242,6 +242,17 @@ limitations under the License. --> topologyStore.setLink(null); }, ); + watch( + () => [selectorStore.currentService, selectorStore.currentDestService], + () => { + if (dashboardStore.entity !== EntityType[4].value) { + return; + } + loadTopology(); + topologyStore.setNode(null); + topologyStore.setLink(null); + }, + ); watch( () => appStore.durationTime, () => { diff --git a/tests/e2e/.eslintrc.js b/tests/e2e/.eslintrc.js deleted file mode 100644 index 4aa35a33..00000000 --- a/tests/e2e/.eslintrc.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -module.exports = { - plugins: ["cypress"], - env: { - mocha: true, - "cypress/globals": true, - }, - rules: { - strict: "off", - }, -}; diff --git a/tests/e2e/plugins/index.js b/tests/e2e/plugins/index.js deleted file mode 100644 index 0ac7f368..00000000 --- a/tests/e2e/plugins/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* eslint-disable arrow-body-style */ -// https://docs.cypress.io/guides/guides/plugins-guide.html - -// if you need a custom webpack configuration you can uncomment the following import -// and then use the `file:preprocessor` event -// as explained in the cypress docs -// https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples - -// /* eslint-disable import/no-extraneous-dependencies, global-require */ -// const webpack = require('@cypress/webpack-preprocessor') - -module.exports = (on, config) => { - // on('file:preprocessor', webpack({ - // webpackOptions: require('@vue/cli-service/webpack.config'), - // watchOptions: {} - // })) - - return Object.assign({}, config, { - fixturesFolder: "tests/e2e/fixtures", - integrationFolder: "tests/e2e/specs", - screenshotsFolder: "tests/e2e/screenshots", - videosFolder: "tests/e2e/videos", - supportFile: "tests/e2e/support/index.js", - }); -}; diff --git a/tests/e2e/specs/test.js b/tests/e2e/specs/test.js deleted file mode 100644 index b448e957..00000000 --- a/tests/e2e/specs/test.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// https://docs.cypress.io/api/introduction/api.html - -describe("My First Test", () => { - it("Visits the app root url", () => { - cy.visit("/"); - cy.contains("h1", "Welcome to Your Vue.js + TypeScript App"); - }); -}); diff --git a/tests/e2e/support/commands.js b/tests/e2e/support/commands.js deleted file mode 100644 index 4fc91b55..00000000 --- a/tests/e2e/support/commands.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add("login", (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This is will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/tests/e2e/support/index.js b/tests/e2e/support/index.js deleted file mode 100644 index 44607154..00000000 --- a/tests/e2e/support/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import "./commands"; - -// Alternatively you can use CommonJS syntax: -// require('./commands') diff --git a/tests/unit/example.spec.ts b/tests/unit/example.spec.ts deleted file mode 100644 index 9438cda0..00000000 --- a/tests/unit/example.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -describe("My First Test", () => { - it("renders props.msg when passed", () => { - const msg = "new message"; - console.log(msg); - }); -});