Skip to content

Commit

Permalink
Merge pull request #876 from leoendless/hotfix/workspaceProjects
Browse files Browse the repository at this point in the history
fix: Fix workspace projects and fedprojects permissions
  • Loading branch information
ks-ci-bot authored Jul 22, 2020
2 parents 7cb98a8 + 69fdf57 commit 64cd31a
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 105 deletions.
4 changes: 3 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,16 @@ client:
- name: projects
title: NAV_PROJECTS
icon: project
skipAuth: true
tabs:
- { name: projects, title: Projects, skipAuth: true }
- { name: projects, title: Projects }
- { name: federatedprojects, title: Multi-cluster Projects }
- {
name: devops,
title: DevOps Projects,
icon: strategy-group,
ksModule: devops,
skipAuth: true,
}
- name: apps
title: Apps Management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export default class HealthChecker extends React.Component {
probType="readinessProbe"
/>
</Form.Item>
<Form.Item className={styles.item} label={t('Container Startup Check')}>
<Form.Item
className={styles.item}
label={t('Container Startup Check')}
tip={t('STARTUP_PROBE_TIP')}
>
<ProbeInput
name={`${this.prefix}startupProbe`}
type={t('Container Startup Check')}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
'All Nodes': 'All Nodes',
'Allocated CPU': 'Allocated CPU',
'Allocated Memory': 'Allocated Memory',
'Allocated Resources': 'Allocated Resources',
Annotations: 'Annotations',
Architecture: 'Architecture',
'Cluster Node': 'Cluster Node',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default {
'min replicas number should not be greater than max replicas number',
MinimumReplicasAvailable: 'MinimumReplicasAvailable',
MinimumReplicasUnavailable: 'MinimumReplicasUnavailable',
MinReadySeconds: 'MinReadySeconds',
Mount: 'Mount',
'Mount ConfigMap or Secret': 'Mount ConfigMap or Secret',
'Mount Path': 'Mount Path',
Expand Down Expand Up @@ -577,6 +578,8 @@ export default {
STARTUP_PROBE_DESC:
'This check method is used to detect if the container is started successfully.',

STARTUP_PROBE_TIP: 'Requires kubernetes version v1.18 or above.',

SEARCH_IMAGE_PLACEHOLDER: 'Enter keyword to search image',

POD_CONDITION_INITIALIZED: 'Initialized',
Expand Down
3 changes: 3 additions & 0 deletions src/locales/tc/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ export default {
LIVENESS_PROBE_DESC: '该检查方式用于检测容器是否活着。',
READINESS_PROBE_DESC: '该检查方式用于检测容器是否准备好开始处理用户请求。',
STARTUP_PROBE_DESC: '该检查方式用于检测容器是否启动成功。',
STARTUP_PROBE_TIP: '需要 kubernetes 版本 v1.18 或以上。',

COLLECT_SAVED_LOG_DESC:
'您已开启落盘日志收集,请至少添加一个存储卷并指定日志所在目录',
Expand Down Expand Up @@ -541,6 +542,8 @@ export default {
'Pod CPU Request': '容器组CPU请求',
'Pod Memory Request': '容器组内存请求',

MinReadySeconds: '最小就绪时间 (MinReadySeconds)',

POD_CONDITION_INITIALIZED: 'Initialized',
POD_CONDITION_INITIALIZED_DESC: '所有 init 容器都已成功启动',
POD_CONDITION_READY: '开始运行(Ready)',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default {
'Type Name': '类型名称',
'Allocated CPU': '已分配 CPU',
'Allocated Memory': '已分配内存',
'Allocated Resources': '已分配资源',

Metadata: '元数据',

Expand Down
2 changes: 2 additions & 0 deletions src/locales/zh/workload.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default {
Privileged: '特权模式',
'Desired Replicas': '期望副本',
'Current Replicas': '实际运行副本',
MinReadySeconds: '最小就绪时间 (MinReadySeconds)',

REPLICAS_SCALE_NOTIFY_TITLE: '立即生效?',
REPLICAS_SCALE_NOTIFY_CONTENT:
Expand Down Expand Up @@ -498,6 +499,7 @@ export default {
LIVENESS_PROBE_DESC: '该检查方式用于检测容器是否活着。',
READINESS_PROBE_DESC: '该检查方式用于检测容器是否准备好开始处理用户请求。',
STARTUP_PROBE_DESC: '该检查方式用于检测容器是否启动成功。',
STARTUP_PROBE_TIP: '需要 kubernetes 版本 v1.18 或以上。',

COLLECT_SAVED_LOG_DESC:
'您已开启落盘日志收集,请至少添加一个存储卷并指定日志所在目录',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import { get, isEmpty } from 'lodash'

import NodeMonitoringStore from 'stores/monitoring/node'

import { Panel } from 'components/Base'
import { cpuFormat, memoryFormat } from 'utils'

import { Panel, Text } from 'components/Base'
import MonitorTab from 'components/Cards/Monitoring/MonitorTab'
import ConditionCard from './ConditionCard'
import TaintCard from './TaintCard'
Expand Down Expand Up @@ -113,6 +115,53 @@ export default class RunningStatus extends React.Component {
)
}

renderAllocatedResources() {
const { detail } = this.store

return (
<Panel className={styles.allocated} title={t('Allocated Resources')}>
<Text
title={`${cpuFormat(
get(detail, 'annotations["node.kubesphere.io/cpu-requests"]')
)} Core (${get(
detail,
'annotations["node.kubesphere.io/cpu-requests-fraction"]'
)})`}
description={t('CPU Requests')}
/>
<Text
title={`${cpuFormat(
get(detail, 'annotations["node.kubesphere.io/cpu-limits"]')
)} Core (${get(
detail,
'annotations["node.kubesphere.io/cpu-limits-fraction"]'
)})`}
description={t('CPU Limits')}
/>
<Text
title={`${memoryFormat(
get(detail, 'annotations["node.kubesphere.io/memory-requests"]'),
'Gi'
)} Gi (${get(
detail,
'annotations["node.kubesphere.io/memory-requests-fraction"]'
)})`}
description={t('Memory Requests')}
/>
<Text
title={`${memoryFormat(
get(detail, 'annotations["node.kubesphere.io/memory-limits"]'),
'Gi'
)} Gi (${get(
detail,
'annotations["node.kubesphere.io/memory-limits-fraction"]'
)})`}
description={t('Memory Limits')}
/>
</Panel>
)
}

renderConditions() {
const { conditions } = this.store.detail

Expand Down Expand Up @@ -149,6 +198,7 @@ export default class RunningStatus extends React.Component {
return (
<div className={styles.main}>
{this.renderResourceStatus()}
{this.renderAllocatedResources()}
{this.renderConditions()}
{this.renderTanits()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
padding: 0;
}

.allocated {
display: flex;

& > div {
min-width: 200px;
margin-right: 20px;
}
}

.conditions {
display: grid;
grid-template-columns: repeat(3, 1fr);
Expand Down
70 changes: 3 additions & 67 deletions src/pages/clusters/containers/Nodes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import React from 'react'
import { toJS } from 'mobx'
import { observer, inject } from 'mobx-react'
import { get, isEmpty } from 'lodash'
import { Loading, Tooltip } from '@pitrix/lego-ui'
import { Loading } from '@pitrix/lego-ui'

import { getDisplayName, getLocalTime, cpuFormat, memoryFormat } from 'utils'
import { getDisplayName, getLocalTime } from 'utils'
import { getNodeRoles, getNodeStatus } from 'utils/node'
import { trigger } from 'utils/action'
import NodeStore from 'stores/node'

import DetailPage from 'clusters/containers/Base/Detail'
import { Status, Text } from 'components/Base'
import { Status } from 'components/Base'

import routes from './routes'

Expand Down Expand Up @@ -159,14 +159,6 @@ export default class NodeDetail extends React.Component {
name: t('Architecture'),
value: nodeInfo.architecture,
},
{
name: t('Allocated CPU'),
value: this.renderCPUTooltip(detail),
},
{
name: t('Allocated Memory'),
value: this.renderMemoryTooltip(detail),
},
{
name: t('Created Time'),
value: getLocalTime(detail.createTime).format('YYYY-MM-DD HH:mm:ss'),
Expand All @@ -184,62 +176,6 @@ export default class NodeDetail extends React.Component {
}
}

renderCPUTooltip = record => {
const content = (
<p>
{t('Resource Limits')}:{' '}
{cpuFormat(get(record, 'annotations["node.kubesphere.io/cpu-limits"]'))}{' '}
Core (
{get(record, 'annotations["node.kubesphere.io/cpu-limits-fraction"]')})
</p>
)
return (
<Tooltip content={content} placement="top">
<Text
title={`${cpuFormat(
get(record, 'annotations["node.kubesphere.io/cpu-requests"]')
)} Core (${get(
record,
'annotations["node.kubesphere.io/cpu-requests-fraction"]'
)})`}
description={t('Resource Requests')}
/>
</Tooltip>
)
}

renderMemoryTooltip = record => {
const content = (
<p>
{t('Resource Limits')}:{' '}
{memoryFormat(
get(record, 'annotations["node.kubesphere.io/memory-limits"]'),
'Gi'
)}{' '}
Gi (
{get(
record,
'annotations["node.kubesphere.io/memory-limits-fraction"]'
)}
)
</p>
)
return (
<Tooltip content={content} placement="top">
<Text
title={`${memoryFormat(
get(record, 'annotations["node.kubesphere.io/memory-requests"]'),
'Gi'
)} Gi (${get(
record,
'annotations["node.kubesphere.io/memory-requests-fraction"]'
)})`}
description={t('Resource Requests')}
/>
</Tooltip>
)
}

render() {
const stores = { detailStore: this.store }

Expand Down
1 change: 1 addition & 0 deletions src/pages/workspaces/containers/DevOps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default class DevOps extends React.Component {
title: t('Created Time'),
dataIndex: 'createTime',
isHideable: true,
sorter: true,
width: '20%',
render: time => getLocalTime(time).format('YYYY-MM-DD HH:mm:ss'),
},
Expand Down
29 changes: 5 additions & 24 deletions src/pages/workspaces/containers/FedProjects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import ClusterWrapper from 'components/Clusters/ClusterWrapper'

import { getDisplayName, getLocalTime } from 'utils'

import FederatedStore from 'stores/federated'
import FederatedStore from 'stores/project.federated'
import ProjectStore from 'stores/project'

@withList({
store: new FederatedStore({ module: 'namespaces' }),
name: 'Multi-cluster Project',
module: 'federatedprojects',
module: 'projects',
injectStores: ['rootStore', 'workspaceStore'],
})
export default class Projects extends React.Component {
Expand All @@ -51,7 +51,7 @@ export default class Projects extends React.Component {

get tabs() {
return {
value: this.props.module,
value: 'federatedprojects',
onChange: this.handleTabChange,
options: [
{
Expand All @@ -66,18 +66,6 @@ export default class Projects extends React.Component {
}
}

getData = async ({ silent, ...params } = {}) => {
const { store } = this.props
const { workspace } = this.props.match.params

silent && (store.list.silent = true)
await store.fetchList({
labelSelector: `kubesphere.io/workspace=${workspace}`,
...params,
})
store.list.silent = false
}

get workspace() {
return this.props.match.params.workspace
}
Expand All @@ -89,14 +77,12 @@ export default class Projects extends React.Component {
key: 'edit',
icon: 'pen',
text: t('Edit'),
action: 'edit',
onClick: item => trigger('resource.baseinfo.edit', { detail: item }),
},
{
key: 'delete',
icon: 'trash',
text: t('Delete'),
action: 'delete',
onClick: item =>
trigger('federated.project.delete', {
detail: item,
Expand All @@ -114,7 +100,6 @@ export default class Projects extends React.Component {
key: 'delete',
type: 'danger',
text: t('Delete'),
action: 'delete',
onClick: () =>
trigger('federated.project.delete.batch', {
type: t(name),
Expand Down Expand Up @@ -169,6 +154,7 @@ export default class Projects extends React.Component {
title: t('Created Time'),
dataIndex: 'createTime',
isHideable: true,
sorter: true,
width: '20%',
render: time => getLocalTime(time).format('YYYY-MM-DD HH:mm:ss'),
},
Expand All @@ -187,12 +173,7 @@ export default class Projects extends React.Component {
const { bannerProps, tableProps } = this.props

return (
<ListPage
{...this.props}
getData={this.getData}
module="namespaces"
isFederated
>
<ListPage {...this.props} module="namespaces" isFederated>
<Banner
{...bannerProps}
tabs={this.tabs}
Expand Down
Loading

0 comments on commit 64cd31a

Please sign in to comment.