Skip to content

Commit

Permalink
fix: Fix api for single cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 4, 2020
1 parent fab97d0 commit 765edd6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/Terminal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import React, { lazy, Suspense, Component } from 'react'
import { observer } from 'mobx-react'
import { getWebSocketProtocol } from 'utils'
import { getWebSocketProtocol, getClusterUrl } from 'utils'

const ContainerTerminal = lazy(() =>
import(/* webpackChunkName: "terminal" */ './terminal')
Expand All @@ -31,7 +31,7 @@ export default class SessionTerminal extends Component {
get url() {
return `${getWebSocketProtocol(window.location.protocol)}://${
window.location.host
}/${this.props.url}`
}${getClusterUrl(`/${this.props.url}`)}`
}

resizeTerminal = () => {
Expand Down
11 changes: 11 additions & 0 deletions src/pages/workspaces/components/Modals/WorkspaceCreate/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ export default class WorkspaceCreateModal extends React.Component {
}

get steps() {
if (!globals.app.isMultiCluster) {
return [
{
title: 'Basic Info',
component: BaseInfo,
required: true,
isForm: true,
},
]
}

return [
{
title: 'Basic Info',
Expand Down
2 changes: 1 addition & 1 deletion src/stores/logging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class LoggingStore {

getApiPath(cluster) {
return cluster
? `kapis/clusters/${cluster}/tenant.kubesphere.io/v1alpha2/logs`
? `kapis/klusters/${cluster}/tenant.kubesphere.io/v1alpha2/logs`
: 'kapis/tenant.kubesphere.io/v1alpha2/logs'
}

Expand Down
14 changes: 7 additions & 7 deletions src/stores/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export default class TerminalStore {
@computed
get kubeWebsocketUrl() {
const { cluster, namespace, pod, container, shell = 'sh' } = this.kubectl
return `kapis${this.getClusterPath({
return `kapis/terminal.kubesphere.io/v1alpha2${this.getClusterPath({
cluster,
})}/terminal.kubesphere.io/v1alpha2/namespaces/${namespace}/pods/${pod}?container=${container}&shell=${shell}`
})}/namespaces/${namespace}/pods/${pod}?container=${container}&shell=${shell}`
}

@observable
Expand All @@ -51,16 +51,16 @@ export default class TerminalStore {
}

getClusterPath({ cluster } = {}) {
return cluster ? `/clusters/${cluster}` : ''
return cluster ? `/klusters/${cluster}` : ''
}

@action
async fetchKubeCtl({ cluster }) {
this.kubectl.isLoading = true
const result = await request.get(
`kapis${this.getClusterPath({
`kapis/resources.kubesphere.io/v1alpha2${this.getClusterPath({
cluster,
})}/resources.kubesphere.io/v1alpha2/users/${this.username}/kubectl`,
})}/users/${this.username}/kubectl`,
null,
null,
this.reject
Expand All @@ -75,9 +75,9 @@ export default class TerminalStore {
@action
async fetchKubeConfig(params) {
const result = await request.get(
`kapis${this.getClusterPath(
`kapis/resources.kubesphere.io/v1alpha2${this.getClusterPath(
params
)}/resources.kubesphere.io/v1alpha2/users/${this.username}/kubeconfig`
)}/users/${this.username}/kubeconfig`
)
this.kubeconfig = result
}
Expand Down

0 comments on commit 765edd6

Please sign in to comment.