Skip to content

Commit

Permalink
Merge pull request #1205 from leoendless/hotfix/clusterListAPI
Browse files Browse the repository at this point in the history
fix: Fix clusters fetch API when creating workspace
  • Loading branch information
ks-ci-bot authored Aug 19, 2020
2 parents e0bd5e5 + e4f8170 commit c265922
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default class ClusterSettings extends Component {
} else {
await this.clusterStore.fetchList({
limit: -1,
from: 'resource',
labelSelector: 'cluster.kubesphere.io/visibility=public',
})
}
Expand Down
18 changes: 5 additions & 13 deletions src/stores/cluster/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ClusterStore extends Base {
`kapis/tenant.kubesphere.io/v1alpha2${this.getPath(params)}/${this.module}`

@action
async fetchList({ cluster, workspace, namespace, more, ...params } = {}) {
async fetchList({ from, more, ...params } = {}) {
this.list.isLoading = true

if (!params.sortBy && params.ascending === undefined) {
Expand All @@ -72,23 +72,15 @@ export default class ClusterStore extends Base {
if (!globals.app.isMultiCluster) {
result = { items: [DEFAULT_CLUSTER] }
} else if (
from === 'resource' ||
globals.app.hasPermission({ module: 'clusters', action: 'view' })
) {
result = await request.get(
this.getResourceUrl({ cluster, workspace, namespace }),
params
)
result = await request.get(this.getResourceUrl({}), params)
} else {
result = await request.get(
this.getTenantUrl({ cluster, workspace, namespace }),
params
)
result = await request.get(this.getTenantUrl({}), params)
}

const data = get(result, 'items', []).map(item => ({
cluster,
...this.mapper(item),
}))
const data = get(result, 'items', []).map(this.mapper)

this.list.update({
data: more ? [...this.list.data, ...data] : data,
Expand Down

0 comments on commit c265922

Please sign in to comment.