Skip to content

Commit

Permalink
[release-3.3] feat: Support batch stop workloads (#3497)
Browse files Browse the repository at this point in the history
* fix: Support bath stop statfulsets and deamonets for cluster

Signed-off-by: TheYoungManLi <cjl@kubesphere.io>

* fix: Support bath stop statfulsets and deamonets for project

Signed-off-by: TheYoungManLi <cjl@kubesphere.io>

* fix: Support bath stop deployments for multi-cluster project

Signed-off-by: TheYoungManLi <cjl@kubesphere.io>

* fix: Support bath stop statfulsets for multi-cluster project

Signed-off-by: TheYoungManLi <cjl@kubesphere.io>

Co-authored-by: TheYoungManLi <cjl@kubesphere.io>
  • Loading branch information
ks-ci-bot and weili520 authored Aug 2, 2022
1 parent e3fab00 commit 2df3af7
Show file tree
Hide file tree
Showing 11 changed files with 227 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
module.exports = {
// Banner
// List
DAEMONSETS_LOW: 'daemonsets',
DAEMONSETS_PL: 'daemonsets',
// List > Create > Basic Information
// List > Create > Pod Settings
CONTAINER_SETTINGS_DESC: 'Set the image, name, type, and computing resources of the container.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
module.exports = {
// Banner
// List
STATEFULSETS_LOW: 'Statefulsets',
STATEFULSETS_PL: 'Statefulsets',
// List > Create > Basic Information
// List > Create > Pod Settings > Update Settings > Rolling Update Settings
PARTITION_ORDINAL_EMPTY: 'Please set a ordinal for dividing pod replicas.',
Expand Down
20 changes: 20 additions & 0 deletions src/pages/clusters/containers/Workload/DaemonSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { withClusterList, ListPage } from 'components/HOCs/withList'
import WorkloadStatus from 'projects/components/WorkloadStatus'
import StatusReason from 'projects/components/StatusReason'
import ResourceTable from 'clusters/components/ResourceTable'
import { get } from 'lodash'

import { getLocalTime, getDisplayName } from 'utils'
import { getWorkloadStatus } from 'utils/status'
Expand All @@ -36,6 +37,7 @@ import WorkloadStore from 'stores/workload'
store: new WorkloadStore('daemonsets'),
module: 'daemonsets',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class DaemonSets extends React.Component {
handleTabChange = value => {
Expand Down Expand Up @@ -64,6 +66,23 @@ export default class DaemonSets extends React.Component {
}
}

get selectActions() {
const { tableProps, trigger, module, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: module.toUpperCase(),
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { module, name, trigger } = this.props
return [
Expand Down Expand Up @@ -202,6 +221,7 @@ export default class DaemonSets extends React.Component {
<ResourceTable
{...tableProps}
itemActions={this.itemActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
cluster={match.params.cluster}
Expand Down
19 changes: 19 additions & 0 deletions src/pages/clusters/containers/Workload/StatefulSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { withClusterList, ListPage } from 'components/HOCs/withList'
import WorkloadStatus from 'projects/components/WorkloadStatus'
import StatusReason from 'projects/components/StatusReason'
import ResourceTable from 'clusters/components/ResourceTable'
import { get } from 'lodash'

import { getLocalTime, getDisplayName } from 'utils'
import { getWorkloadStatus } from 'utils/status'
Expand Down Expand Up @@ -67,6 +68,23 @@ export default class StatefulSets extends React.Component {

showAction = record => !record.isFedManaged

get selectActions() {
const { tableProps, trigger, module, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: module.toUpperCase(),
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { module, trigger, name } = this.props
return [
Expand Down Expand Up @@ -215,6 +233,7 @@ export default class StatefulSets extends React.Component {
<ResourceTable
{...tableProps}
itemActions={this.itemActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
cluster={match.params.cluster}
Expand Down
21 changes: 20 additions & 1 deletion src/pages/fedprojects/containers/Deployments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from 'react'

import { get } from 'lodash'
import { Avatar, Status } from 'components/Base'
import Banner from 'components/Cards/Banner'
import { withProjectList, ListPage } from 'components/HOCs/withList'
Expand All @@ -34,6 +34,7 @@ import WorkloadStore from 'stores/workload'
store: new FederatedStore(new WorkloadStore('deployments')),
module: 'deployments',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class Deployments extends React.Component {
get prefix() {
Expand Down Expand Up @@ -100,6 +101,23 @@ export default class Deployments extends React.Component {
]
}

get selectActions() {
const { tableProps, trigger, name, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: name,
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get tableActions() {
const { trigger, name, tableProps } = this.props
return {
Expand Down Expand Up @@ -191,6 +209,7 @@ export default class Deployments extends React.Component {
{...tableProps}
itemActions={this.itemActions}
tableActions={this.tableActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
searchType="name"
Expand Down
21 changes: 20 additions & 1 deletion src/pages/fedprojects/containers/StatefulSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from 'react'

import { get } from 'lodash'
import { Avatar, Status } from 'components/Base'
import Banner from 'components/Cards/Banner'
import { withProjectList, ListPage } from 'components/HOCs/withList'
Expand All @@ -35,6 +35,7 @@ import WorkloadStore from 'stores/workload'
store: new FederatedStore(new WorkloadStore('statefulsets')),
module: 'statefulsets',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class StatefulSets extends React.Component {
get prefix() {
Expand Down Expand Up @@ -63,6 +64,23 @@ export default class StatefulSets extends React.Component {
}
}

get selectActions() {
const { tableProps, trigger, module, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: module.toUpperCase(),
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { trigger, name } = this.props
return [
Expand Down Expand Up @@ -208,6 +226,7 @@ export default class StatefulSets extends React.Component {
{...tableProps}
itemActions={this.itemActions}
tableActions={this.tableActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
searchType="name"
Expand Down
21 changes: 20 additions & 1 deletion src/pages/projects/containers/DaemonSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from 'react'

import { get } from 'lodash'
import { Avatar } from 'components/Base'
import Banner from 'components/Cards/Banner'
import { withProjectList, ListPage } from 'components/HOCs/withList'
Expand All @@ -35,6 +35,7 @@ import WorkloadStore from 'stores/workload'
store: new WorkloadStore('daemonsets'),
module: 'daemonsets',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class DaemonSets extends React.Component {
get prefix() {
Expand Down Expand Up @@ -67,6 +68,23 @@ export default class DaemonSets extends React.Component {
}
}

get selectActions() {
const { tableProps, trigger, module, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: module.toUpperCase(),
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { module, trigger, name } = this.props
return [
Expand Down Expand Up @@ -215,6 +233,7 @@ export default class DaemonSets extends React.Component {
{...tableProps}
itemActions={this.itemActions}
tableActions={this.tableActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
/>
Expand Down
21 changes: 20 additions & 1 deletion src/pages/projects/containers/Deployments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from 'react'

import { get } from 'lodash'
import { Avatar } from 'components/Base'
import Banner from 'components/Cards/Banner'
import { withProjectList, ListPage } from 'components/HOCs/withList'
Expand All @@ -35,6 +35,7 @@ import WorkloadStore from 'stores/workload'
store: new WorkloadStore('deployments'),
module: 'deployments',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class Deployments extends React.Component {
get prefix() {
Expand Down Expand Up @@ -67,6 +68,23 @@ export default class Deployments extends React.Component {
}
}

get selectActions() {
const { tableProps, trigger, name, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: name,
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { module, trigger, name } = this.props
return [
Expand Down Expand Up @@ -224,6 +242,7 @@ export default class Deployments extends React.Component {
{...tableProps}
itemActions={this.itemActions}
tableActions={this.tableActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
/>
Expand Down
21 changes: 20 additions & 1 deletion src/pages/projects/containers/StatefulSets/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from 'react'

import { get } from 'lodash'
import { Avatar } from 'components/Base'
import Banner from 'components/Cards/Banner'
import { withProjectList, ListPage } from 'components/HOCs/withList'
Expand All @@ -35,6 +35,7 @@ import WorkloadStore from 'stores/workload'
store: new WorkloadStore('statefulsets'),
module: 'statefulsets',
name: 'WORKLOAD',
rowKey: 'uid',
})
export default class StatefulSets extends React.Component {
get prefix() {
Expand Down Expand Up @@ -67,6 +68,23 @@ export default class StatefulSets extends React.Component {
}
}

get selectActions() {
const { tableProps, trigger, module, rootStore } = this.props
return [
...get(tableProps, 'tableActions.selectActions', {}),
{
key: 'stop',
text: t('STOP'),
onClick: () =>
trigger('resource.batch.stop', {
type: module.toUpperCase(),
rowKey: 'uid',
success: rootStore.routing.query(),
}),
},
]
}

get itemActions() {
const { module, trigger, name } = this.props
return [
Expand Down Expand Up @@ -223,6 +241,7 @@ export default class StatefulSets extends React.Component {
{...tableProps}
itemActions={this.itemActions}
tableActions={this.tableActions}
selectActions={this.selectActions}
columns={this.getColumns()}
onCreate={this.showCreate}
/>
Expand Down
Loading

0 comments on commit 2df3af7

Please sign in to comment.