Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate workload resource actions to new extensions
- Loading branch information
1 parent
e12eb74
commit 1e27dfb
Showing
23 changed files
with
563 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
frontend/packages/console-app/src/actions/creators/job-factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import i18next from 'i18next'; | ||
import { configureJobParallelismModal } from '@console/internal/components/modals'; | ||
import { JobKind, K8sKind } from '@console/internal/module/k8s'; | ||
import { ResourceActionFactory } from './common-factory'; | ||
|
||
export const JobActionFactory: ResourceActionFactory = { | ||
ModifyJobParallelism: (kind: K8sKind, obj: JobKind) => ({ | ||
id: 'edit-parallelism', | ||
label: i18next.t('console-app~Edit parallelism'), | ||
cta: () => | ||
configureJobParallelismModal({ | ||
resourceKind: kind, | ||
resource: obj, | ||
}), | ||
accessReview: { | ||
group: kind.apiGroup, | ||
resource: kind.plural, | ||
name: obj.metadata.name, | ||
namespace: obj.metadata.namespace, | ||
verb: 'patch', | ||
}, | ||
}), | ||
}; |
20 changes: 20 additions & 0 deletions
20
frontend/packages/console-app/src/actions/providers/daemon-set-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as React from 'react'; | ||
import { K8sResourceKind, referenceFor } from '@console/internal/module/k8s'; | ||
import { useK8sModel } from '@console/shared/src/hooks/useK8sModel'; | ||
import { CommonActionFactory, getCommonResourceActions } from '../creators/common-factory'; | ||
import { getHealthChecksAction } from '../creators/health-checks-factory'; | ||
|
||
export const useDaemonSetActionsProvider = (resource: K8sResourceKind) => { | ||
const [kindObj, inFlight] = useK8sModel(referenceFor(resource)); | ||
|
||
const actions = React.useMemo( | ||
() => [ | ||
getHealthChecksAction(kindObj, resource), | ||
CommonActionFactory.AddStorage(kindObj, resource), | ||
...getCommonResourceActions(kindObj, resource), | ||
], | ||
[kindObj, resource], | ||
); | ||
|
||
return [actions, !inFlight, undefined]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from './deployment-provider'; | ||
export * from './stateful-set-provider'; | ||
export * from './daemon-set-provider'; | ||
export * from './job-provider'; |
30 changes: 30 additions & 0 deletions
30
frontend/packages/console-app/src/actions/providers/job-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import { K8sResourceKind, referenceFor } from '@console/internal/module/k8s'; | ||
import { useK8sModel } from '@console/shared/src/hooks/useK8sModel'; | ||
import { getCommonResourceActions } from '../creators/common-factory'; | ||
import { JobActionFactory } from '../creators/job-factory'; | ||
|
||
export const useJobActionsProvider = (resource: K8sResourceKind) => { | ||
const [kindObj, inFlight] = useK8sModel(referenceFor(resource)); | ||
|
||
const actions = React.useMemo( | ||
() => [ | ||
JobActionFactory.ModifyJobParallelism(kindObj, resource), | ||
...getCommonResourceActions(kindObj, resource), | ||
], | ||
[kindObj, resource], | ||
); | ||
|
||
return [actions, !inFlight, undefined]; | ||
}; | ||
|
||
export const useCronJobActionsProvider = (resource: K8sResourceKind) => { | ||
const [kindObj, inFlight] = useK8sModel(referenceFor(resource)); | ||
|
||
const actions = React.useMemo(() => getCommonResourceActions(kindObj, resource), [ | ||
kindObj, | ||
resource, | ||
]); | ||
|
||
return [actions, !inFlight, undefined]; | ||
}; |
Oops, something went wrong.