Skip to content

Commit

Permalink
fix: Fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jul 3, 2020
1 parent b30004e commit ea05a61
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/actions/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import { get, set, cloneDeep, omitBy, uniqBy, isEmpty } from 'lodash'
import { get, set, unset, cloneDeep, omitBy, uniqBy, isEmpty } from 'lodash'
import { Modal, Notify } from 'components/Base'
import QuotaEditModal from 'components/Modals/QuotaEdit'
import ProjectCreateModal from 'components/Modals/ProjectCreate'
Expand Down Expand Up @@ -59,6 +59,7 @@ export default {
'metadata.labels["kubesphere.io/kubefed-host-namespace"]',
'true'
)
unset(hostData, 'spec.placement')
await store.create(hostData, { workspace })
await federatedStore.create(FED_TEMPLATES.namespaces(data), {
namespace: get(data, 'metadata.name'),
Expand Down
3 changes: 2 additions & 1 deletion src/components/Cards/Containers/EnvVariables/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ export default class ContainerItem extends React.Component {
}

renderTitle() {
const { type, name } = this.props.detail
return (
<div className={styles.title}>
<Icon name="docker" size={20} />
{t('Container')}: {this.props.detail.name}
{type === 'init' ? t('Init Container') : t('Container')}: {name}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ export default class MountConfig extends React.Component {
}

fetchData() {
const { namespace } = this.props

const { cluster, namespace } = this.props
Promise.all([
this.configMapStore.fetchListByK8s({ namespace }),
this.secretStore.fetchListByK8s({ namespace }),
this.configMapStore.fetchListByK8s({ cluster, namespace }),
this.secretStore.fetchListByK8s({ cluster, namespace }),
]).then(([configMaps, secrets]) => {
this.setState({ configMaps, secrets }, () => {
if (this.state.formData.name) {
Expand Down
1 change: 1 addition & 0 deletions src/components/Forms/Workload/VolumeSettings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class VolumeSettings extends React.Component {
<MountConfig
volume={this.selectVolume}
containers={containers}
cluster={this.cluster}
namespace={this.namespace}
containers={containers}
onSave={this.handleVolume}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Modals/Create/Code/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import React from 'react'
import PropTypes from 'prop-types'
import { keyBy, isArray } from 'lodash'

import { Button } from 'components/Base'
import EditMode from 'components/EditMode'
Expand Down Expand Up @@ -48,8 +49,8 @@ export default class CodeMode extends React.Component {

handleCreate = () => {
const { onOk } = this.props

onOk(this.getData())
const data = this.getData()
onOk(isArray(data) ? keyBy(data, 'kind') : data)
}

render() {
Expand Down
13 changes: 13 additions & 0 deletions src/core/containers/Base/Detail/EnvVariables/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@ class EnvVariables extends React.Component {
return []
}

get initContainers() {
const data = toJS(this.store.detail)
const { spec, initContainers = [] } = data

if (this.module === 'containers') return [data]

if (!isEmpty(initContainers)) return initContainers
if (!isEmpty(spec)) return get(spec, 'template.spec.initContainers', [])

return []
}

fetchData = () => {
this.envStore.fetchList({
namespace: this.namespace,
cluster: this.cluster,
containers: this.containers,
initContainers: this.initContainers,
})
}

Expand Down
1 change: 0 additions & 1 deletion src/pages/clusters/containers/Workload/Jobs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export default class Jobs extends React.Component {
sorter: true,
sortOrder: getSortOrder('updateTime'),
isHideable: true,
search: true,
width: '20%',
render: time => getLocalTime(time).format('YYYY-MM-DD HH:mm:ss'),
},
Expand Down
10 changes: 9 additions & 1 deletion src/stores/monitoring/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const getMinuteValue = (timeStr = '60s', hasUnit = true) => {
export const getTimeRange = ({ step = '600s', times = 20 } = {}) => {
const interval = parseFloat(step) * times
const end = Math.floor(Date.now() / 1000)
const start = end - interval
const start = Math.floor(end - interval)

return { start, end }
}
Expand Down Expand Up @@ -110,6 +110,14 @@ export default class BaseMonitoringStore {
}
}

if (params.start) {
params.start = Math.floor(params.start)
}

if (params.end) {
params.end = Math.floor(params.end)
}

if (!isEmpty(resources)) {
params.resources_filter = `${resources.join('|')}$`
}
Expand Down
9 changes: 7 additions & 2 deletions src/stores/workload/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ export default class EnvStore {
}

@action
async fetchList({ namespace, containers }) {
async fetchList({ namespace, containers, initContainers }) {
this.list.isLoading = true

const mergeContainers = [
...initContainers.map(item => ({ ...item, type: 'init' })),
...containers.map(item => ({ ...item, type: 'work' })),
]

const data = await Promise.all(
containers.map(container => {
mergeContainers.map(container => {
container.namespace = namespace
return this.fetchVariables(container)
})
Expand Down
1 change: 1 addition & 0 deletions src/utils/object.mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ const WorkLoadMapper = item => ({
podNums: get(item, 'spec.replicas', 0),
selector: get(item, 'spec.selector.matchLabels'),
containers: get(item, 'spec.template.spec.containers'),
initContainers: get(item, 'spec.template.spec.initContainers'),
volumes: get(item, 'spec.template.spec.volumes'),
strategy: get(item, 'spec.strategy', {}),
updateStrategy: get(item, 'spec.updateStrategy.type'),
Expand Down

0 comments on commit ea05a61

Please sign in to comment.