Skip to content

Commit

Permalink
fix: Fix project resources search by app
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jul 10, 2020
1 parent 1d18e4b commit c71d050
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 78 deletions.
6 changes: 3 additions & 3 deletions src/components/Modals/ProjectSelect/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@ export default class ProjectSelectModal extends React.Component {
rootStore.triggerAction('project.create', {
store: this.projectStore,
workspace,
success: this.fetchData,
success: () => this.fetchData(),
})
} else if (this.state.type === 'federatedprojects') {
rootStore.triggerAction('federated.project.create', {
store: this.projectStore,
workspace,
clusters: this.store.clusters.data.slice(),
success: this.fetchData,
success: () => this.fetchData(),
})
} else {
rootStore.triggerAction('devops.create', {
store: this.devopsStore,
cluster,
workspace,
success: this.fetchData,
success: () => this.fetchData(),
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/locales/zh/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default {
PLATFORM_SETTINGS_DESC: '定制化平台设置,如平台基本信息等',

Loading: '加载中',
Active: '已启用',
Active: '活跃',
Running: '运行中',
Succeeded: '运行中',
'Not Running': '未运行',
Expand All @@ -108,7 +108,7 @@ export default {
Completed: '已完成',
Unfinished: '未完成',
Healthy: '健康',
active: '已启用',
active: '活跃',
running: '运行中',
waiting: '等待中',
pending: '等待中',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ export default class PipelineDetail extends Base {
return this.props.rootStore.routing
}

get application() {
const { detail } = this.store
return detail.labels && detail.labels.chart && detail.labels.release
? `${detail.labels.release}/${detail.labels.chart}`
: '-'
}

get creator() {
return get(this.store.detail, 'creator', t('unknown'))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,6 @@ class RunSider extends Base {
return this.props.rootStore.routing
}

get application() {
const { detail } = this.store
return detail.labels && detail.labels.chart && detail.labels.release
? `${detail.labels.release}/${detail.labels.chart}`
: '-'
}

get creator() {
return get(this.store.detail, 'creator', t('unknown'))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class DeploymentDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Created Time'),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/fedprojects/containers/Routes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class RouteDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Created Time'),
Expand Down
3 changes: 1 addition & 2 deletions src/pages/fedprojects/containers/Routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ export default class Routers extends React.Component {
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
dataIndex: 'app',
isHideable: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Created Time'),
Expand Down
7 changes: 7 additions & 0 deletions src/pages/fedprojects/containers/Services/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export default class Services extends React.Component {
/>
),
},
{
title: t('Application'),
dataIndex: 'app',
isHideable: true,
search: true,
width: '22%',
},
{
title: t('Created Time'),
dataIndex: 'createTime',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class DeploymentDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Created Time'),
Expand Down
3 changes: 1 addition & 2 deletions src/pages/fedprojects/containers/StatefulSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ export default class StatefulSets extends React.Component {
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
dataIndex: 'app',
isHideable: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Updated Time'),
Expand Down
4 changes: 0 additions & 4 deletions src/pages/projects/containers/DaemonSets/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ export default class DaemonSetDetail extends React.Component {
name: t('Project'),
value: namespace,
},
{
name: t('Application'),
value: detail.application,
},
{
name: t('Created Time'),
value: getLocalTime(detail.createTime).format('YYYY-MM-DD HH:mm:ss'),
Expand Down
8 changes: 0 additions & 8 deletions src/pages/projects/containers/DaemonSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ export default class DaemonSets extends React.Component {
<WorkloadStatus data={record} module={module} />
),
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
isHideable: true,
search: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Created Time'),
dataIndex: 'createTime',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/projects/containers/Deployments/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class DeploymentDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Created Time'),
Expand Down
3 changes: 1 addition & 2 deletions src/pages/projects/containers/Deployments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ export default class Deployments extends React.Component {
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
dataIndex: 'app',
isHideable: true,
search: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Updated Time'),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/projects/containers/Pods/Containers/Detail.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pages/projects/containers/Pods/Detail/index.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/pages/projects/containers/Pods/index.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pages/projects/containers/Routes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class RouteDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Gateway Address'),
Expand Down
20 changes: 8 additions & 12 deletions src/pages/projects/containers/Routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ export default class Routers extends React.Component {
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
dataIndex: 'app',
isHideable: true,
search: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Created Time'),
Expand Down Expand Up @@ -224,16 +223,13 @@ export default class Routers extends React.Component {
return (
<ListPage {...this.props}>
<Banner {...bannerProps} tips={this.tips} />
{isEmpty(data) && !isLoading ? (
this.renderCreateGateway()
) : (
<Table
{...tableProps}
itemActions={this.itemActions}
columns={this.getColumns()}
onCreate={this.showCreate}
/>
)}
{isEmpty(data) && !isLoading && this.renderCreateGateway()}
<Table
{...tableProps}
itemActions={this.itemActions}
columns={this.getColumns()}
onCreate={this.showCreate}
/>
</ListPage>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/projects/containers/Services/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class ServiceDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Virtual IP'),
Expand Down
7 changes: 7 additions & 0 deletions src/pages/projects/containers/Services/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ export default class Services extends React.Component {
/>
),
},
{
title: t('Application'),
dataIndex: 'app',
isHideable: true,
search: true,
width: '22%',
},
{
title: t('Internet Access'),
dataIndex: 'specType',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default class StatefulSetDetail extends React.Component {
},
{
name: t('Application'),
value: detail.application,
value: detail.app,
},
{
name: t('Created Time'),
Expand Down
3 changes: 1 addition & 2 deletions src/pages/projects/containers/StatefulSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ export default class StatefulSets extends React.Component {
},
{
title: t('Application'),
dataIndex: 'app.kubernetes.io/name',
dataIndex: 'app',
isHideable: true,
search: true,
width: '22%',
render: (_, record) => record.app,
},
{
title: t('Created Time'),
Expand Down
4 changes: 1 addition & 3 deletions src/pages/workspaces/containers/FedProjects/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ export default class Projects extends React.Component {
this.props.trigger('federated.project.create', {
...this.props.match.params,
store: this.projectStore,
success: () => {
this.getData()
},
success: () => this.getData(),
})

render() {
Expand Down
12 changes: 11 additions & 1 deletion src/stores/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ export default class BaseStore {
this.module
}`

getFilterParams = params => {
const result = { ...params }
if (result.app) {
result.labelSelector = result.labelSelector || ''
result.labelSelector += `app.kubernetes.io/name=${result.app}`
delete result.app
}
return result
}

@action
setModule(module) {
this.module = module
Expand Down Expand Up @@ -121,7 +131,7 @@ export default class BaseStore {

const result = await request.get(
this.getResourceUrl({ cluster, workspace, namespace, devops }),
params
this.getFilterParams(params)
)
const data = get(result, 'items', []).map(item => ({
cluster,
Expand Down
16 changes: 4 additions & 12 deletions src/utils/object.mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ const WorkLoadMapper = item => ({
availableCondition:
get(item, 'status.conditions', []).find(cd => cd.type === 'Available') ||
{},
app:
get(item, 'metadata.labels.release') ||
get(item, 'metadata.labels["app.kubernetes.io/name"]'),
app: get(item, 'metadata.labels["app.kubernetes.io/name"]'),
ownerReference: get(item, 'metadata.ownerReferences[0]', {}),
hasS2i: Object.keys(get(item, 'metadata.labels', {})).some(labelKey =>
labelKey.startsWith('s2ibuilder')
Expand Down Expand Up @@ -382,9 +380,7 @@ const PodsMapper = item => ({
node: get(item, 'spec.nodeName', ''),
nodeIp: get(item, 'status.hostIP', 'none'),
podIp: get(item, 'status.podIP'),
app:
get(item, 'metadata.labels.release') ||
get(item, 'metadata.labels["app.kubernetes.io/name"]'),
app: get(item, 'metadata.labels["app.kubernetes.io/name"]'),
containers: getContainers(
get(item, 'spec.containers', []),
get(item, 'status.containerStatuses', []),
Expand Down Expand Up @@ -514,9 +510,7 @@ const ServiceMapper = item => {
loadBalancerIngress:
get(item, 'status.loadBalancer.ingress[0].ip') ||
get(item, 'status.loadBalancer.ingress[0].hostname'),
app:
get(item, 'metadata.labels.release') ||
get(item, 'metadata.labels["app.kubernetes.io/name"]'),
app: get(item, 'metadata.labels["app.kubernetes.io/name"]'),
_originData: getOriginData(item),
}
}
Expand Down Expand Up @@ -624,9 +618,7 @@ const IngressMapper = item => ({
rules: get(item, 'spec.rules', []),
tls: get(item, 'spec.tls', []),
loadBalancerIngress: get(item, 'status.loadBalancer.ingress', []),
app:
get(item, 'metadata.labels.release') ||
get(item, 'metadata.labels["app.kubernetes.io/name"]'),
app: get(item, 'metadata.labels["app.kubernetes.io/name"]'),
_originData: getOriginData(item),
})

Expand Down

0 comments on commit c71d050

Please sign in to comment.