From 583386d2ce194f56890a967640a26db432ea326b Mon Sep 17 00:00:00 2001 From: xusongfu Date: Wed, 21 Dec 2022 13:35:41 +0800 Subject: [PATCH] fix: seprate clusters and templates by different project 1.use detail api to fetch list in console but no detail in administrator 2.fix the used quota with clusters detail api Change-Id: I104495a2b7c9937a9e6e922c4fac00d3f4178235 --- .../containers/ClusterTemplates/index.jsx | 9 +++++-- .../containers/Clusters/index.jsx | 9 +++++-- src/stores/keystone/project.js | 4 ++-- src/stores/magnum/clusterAdmin.js | 24 +++++++++++++++++++ src/stores/magnum/clusterTemplates.js | 4 ++++ src/stores/magnum/clusterTemplatesAdmin.js | 24 +++++++++++++++++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 src/stores/magnum/clusterAdmin.js create mode 100644 src/stores/magnum/clusterTemplatesAdmin.js diff --git a/src/pages/container-infra/containers/ClusterTemplates/index.jsx b/src/pages/container-infra/containers/ClusterTemplates/index.jsx index 23045444..84cbee73 100644 --- a/src/pages/container-infra/containers/ClusterTemplates/index.jsx +++ b/src/pages/container-infra/containers/ClusterTemplates/index.jsx @@ -12,13 +12,18 @@ import Base from 'containers/List'; import { inject, observer } from 'mobx-react'; -import globalClusterTemplateStore from 'src/stores/magnum/clusterTemplates'; +import { ClusterTemplatesStore } from 'stores/magnum/clusterTemplates'; +import { ClusterTemplatesAdminStore } from 'stores/magnum/clusterTemplatesAdmin'; import { getBaseTemplateColumns } from 'resources/magnum/template'; import actionConfigs from './actions'; export class ClusterTemplates extends Base { init() { - this.store = globalClusterTemplateStore; + if (this.isAdminPage) { + this.store = new ClusterTemplatesAdminStore(); + } else { + this.store = new ClusterTemplatesStore(); + } } get name() { diff --git a/src/pages/container-infra/containers/Clusters/index.jsx b/src/pages/container-infra/containers/Clusters/index.jsx index aef0f85b..de519f14 100644 --- a/src/pages/container-infra/containers/Clusters/index.jsx +++ b/src/pages/container-infra/containers/Clusters/index.jsx @@ -16,12 +16,17 @@ import Base from 'containers/List'; import { inject, observer } from 'mobx-react'; import { getOptions } from 'utils'; import { clusterStatus, healthStatus } from 'resources/magnum/cluster'; -import globalClustersStore from 'src/stores/magnum/clusters'; +import { ClustersStore } from 'stores/magnum/clusters'; +import { ClustersAdminStore } from 'stores/magnum/clusterAdmin'; import actionConfigs from './actions'; export class Clusters extends Base { init() { - this.store = globalClustersStore; + if (this.isAdminPage) { + this.store = new ClustersAdminStore(); + } else { + this.store = new ClustersStore(); + } } get name() { diff --git a/src/stores/keystone/project.js b/src/stores/keystone/project.js index 3807bc87..890fe394 100644 --- a/src/stores/keystone/project.js +++ b/src/stores/keystone/project.js @@ -296,7 +296,7 @@ export class ProjectStore extends Base { ); promiseArr.push( this.enableMagnum ? this.magnumQuotaClient.list(project_id) : null, - this.enableMagnum ? client.magnum.clusters.list() : null + this.enableMagnum ? client.magnum.clusters.listDetail() : null ); promiseArr.push( this.enableTrove ? this.troveQuotaClient.show(project_id) : null @@ -684,7 +684,7 @@ export class ProjectStore extends Base { async fetchProjectMagnumQuota(projectId) { const [quotas, clustersRes] = await Promise.all([ this.magnumQuotaClient.list(projectId || this.currentProjectId), - client.magnum.clusters.list(), + client.magnum.clusters.listDetail(), ]); const { hard_limit } = this.updateQuotaData(quotas); const { clusters = [] } = clustersRes || {}; diff --git a/src/stores/magnum/clusterAdmin.js b/src/stores/magnum/clusterAdmin.js new file mode 100644 index 00000000..24e417a6 --- /dev/null +++ b/src/stores/magnum/clusterAdmin.js @@ -0,0 +1,24 @@ +// Copyright 2021 99cloud +// +// Licensed 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. + +import { ClustersStore as Base } from 'stores/magnum/clusters'; + +export class ClustersAdminStore extends Base { + get listWithDetail() { + return false; + } +} + +const globalClustersAdminStore = new ClustersAdminStore(); +export default globalClustersAdminStore; diff --git a/src/stores/magnum/clusterTemplates.js b/src/stores/magnum/clusterTemplates.js index b61063fc..6a4b37e1 100644 --- a/src/stores/magnum/clusterTemplates.js +++ b/src/stores/magnum/clusterTemplates.js @@ -38,6 +38,10 @@ export class ClusterTemplatesStore extends Base { return client.glance.images; } + get listWithDetail() { + return true; + } + @action async create(newbody) { return this.submitting(this.client.create(newbody)); diff --git a/src/stores/magnum/clusterTemplatesAdmin.js b/src/stores/magnum/clusterTemplatesAdmin.js new file mode 100644 index 00000000..a6921a9e --- /dev/null +++ b/src/stores/magnum/clusterTemplatesAdmin.js @@ -0,0 +1,24 @@ +// Copyright 2021 99cloud +// +// Licensed 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. + +import { ClusterTemplatesStore as Base } from 'stores/magnum/clusterTemplates'; + +export class ClusterTemplatesAdminStore extends Base { + get listWithDetail() { + return false; + } +} + +const globalClusterTemplatesAdminStore = new ClusterTemplatesAdminStore(); +export default globalClusterTemplatesAdminStore;