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
This commit is contained in:
xusongfu 2022-12-21 13:35:41 +08:00
parent 331c2ddd3b
commit 583386d2ce
6 changed files with 68 additions and 6 deletions

View File

@ -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() {

View File

@ -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() {

View File

@ -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 || {};

View File

@ -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;

View File

@ -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));

View File

@ -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;