Skip to content

Commit 100316f

Browse files
committed
frontend:add create pod and job action button
1 parent 9772b3e commit 100316f

File tree

9 files changed

+121
-6
lines changed

9 files changed

+121
-6
lines changed

frontend/src/components/cronjob/__snapshots__/CronJobDetails.EveryAst.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,19 @@
268268
</h1>
269269
<div
270270
class="MuiBox-root css-ldp2l3"
271-
/>
271+
>
272+
<button
273+
aria-label="Create Job"
274+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
275+
data-mui-internal-clone-element="true"
276+
tabindex="0"
277+
type="button"
278+
>
279+
<span
280+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
281+
/>
282+
</button>
283+
</div>
272284
</div>
273285
</div>
274286
</div>

frontend/src/components/cronjob/__snapshots__/CronJobDetails.EveryMinute.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,19 @@
268268
</h1>
269269
<div
270270
class="MuiBox-root css-ldp2l3"
271-
/>
271+
>
272+
<button
273+
aria-label="Create Job"
274+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
275+
data-mui-internal-clone-element="true"
276+
tabindex="0"
277+
type="button"
278+
>
279+
<span
280+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
281+
/>
282+
</button>
283+
</div>
272284
</div>
273285
</div>
274286
</div>

frontend/src/components/job/List.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { KubeContainer } from '../../lib/k8s/cluster';
2222
import Job from '../../lib/k8s/job';
2323
import { formatDuration } from '../../lib/util';
2424
import { useNamespaces } from '../../redux/filterSlice';
25+
import { CreateResourceButton } from '../common';
2526
import { StatusLabel } from '../common/Label';
2627
import { StatusLabelProps } from '../common/Label';
2728
import ResourceListView from '../common/Resource/ResourceListView';
@@ -107,6 +108,7 @@ export function JobsListRenderer(props: JobsListRendererProps) {
107108
title={t('Jobs')}
108109
headerProps={{
109110
noNamespaceFilter,
111+
titleSideActions: [<CreateResourceButton resourceClass={Job} key="create-job-button" />],
110112
}}
111113
hideColumns={hideColumns}
112114
errors={errors}

frontend/src/components/job/__snapshots__/JobList.Items.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@
1919
</h1>
2020
<div
2121
class="MuiBox-root css-ldp2l3"
22-
/>
22+
>
23+
<button
24+
aria-label="Create Job"
25+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
26+
data-mui-internal-clone-element="true"
27+
tabindex="0"
28+
type="button"
29+
>
30+
<span
31+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
32+
/>
33+
</button>
34+
</div>
2335
</div>
2436
</div>
2537
<div

frontend/src/components/namespace/__snapshots__/NamespaceDetails.Active.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,19 @@
317317
</h1>
318318
<div
319319
class="MuiBox-root css-ldp2l3"
320-
/>
320+
>
321+
<button
322+
aria-label="Create Pod"
323+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
324+
data-mui-internal-clone-element="true"
325+
tabindex="0"
326+
type="button"
327+
>
328+
<span
329+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
330+
/>
331+
</button>
332+
</div>
321333
</div>
322334
</div>
323335
</div>

frontend/src/components/pod/List.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { parseCpu, parseRam, unparseCpu, unparseRam } from '../../lib/units';
2626
import { timeAgo } from '../../lib/util';
2727
import { useNamespaces } from '../../redux/filterSlice';
2828
import { HeadlampEventType, useEventCallback } from '../../redux/headlampEventSlice';
29+
import { CreateResourceButton } from '../common';
2930
import { StatusLabel, StatusLabelProps } from '../common/Label';
3031
import Link from '../common/Link';
3132
import ResourceListView from '../common/Resource/ResourceListView';
@@ -198,6 +199,7 @@ export function PodListRenderer(props: PodListProps) {
198199
title={t('Pods')}
199200
headerProps={{
200201
noNamespaceFilter,
202+
titleSideActions: [<CreateResourceButton resourceClass={Pod} key="create-pod-button" />],
201203
}}
202204
hideColumns={hideColumns}
203205
errors={errors}

frontend/src/components/pod/__snapshots__/PodList.Items.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@
1919
</h1>
2020
<div
2121
class="MuiBox-root css-ldp2l3"
22-
/>
22+
>
23+
<button
24+
aria-label="Create Pod"
25+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
26+
data-mui-internal-clone-element="true"
27+
tabindex="0"
28+
type="button"
29+
>
30+
<span
31+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
32+
/>
33+
</button>
34+
</div>
2335
</div>
2436
</div>
2537
<div

frontend/src/lib/k8s/job.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { KubePodSpec } from './pod';
2121

2222
export interface KubeJob extends KubeObjectInterface {
2323
spec: {
24-
selector: LabelSelector;
24+
selector?: LabelSelector;
2525
template: {
2626
metadata?: KubeMetadata;
2727
spec: KubePodSpec;
@@ -61,6 +61,35 @@ class Job extends KubeObject<KubeJob> {
6161
}
6262
return -1;
6363
}
64+
static getBaseObject(): KubeJob {
65+
const baseObject = super.getBaseObject() as KubeJob;
66+
baseObject.metadata = {
67+
...baseObject.metadata,
68+
namespace: '',
69+
labels: { app: 'headlamp' },
70+
};
71+
baseObject.spec = {
72+
selector: {
73+
matchLabels: { app: 'headlamp' },
74+
},
75+
template: {
76+
spec: {
77+
containers: [
78+
{
79+
name: '',
80+
image: '',
81+
command: [],
82+
imagePullPolicy: 'Always',
83+
},
84+
],
85+
restartPolicy: 'Never',
86+
nodeName: '',
87+
},
88+
},
89+
};
90+
91+
return baseObject;
92+
}
6493
}
6594

6695
export default Job;

frontend/src/lib/k8s/pod.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface KubePodSpec {
4040
serviceAccount?: string;
4141
priority?: string;
4242
tolerations?: any[];
43+
restartPolicy?: string;
4344
}
4445

4546
export interface KubePod extends KubeObjectInterface {
@@ -435,6 +436,27 @@ class Pod extends KubeObject<KubePod> {
435436

436437
return newDetails;
437438
}
439+
static getBaseObject(): KubePod {
440+
const baseObject = super.getBaseObject() as KubePod;
441+
baseObject.metadata = {
442+
...baseObject.metadata,
443+
namespace: '',
444+
labels: { app: 'headlamp' },
445+
};
446+
baseObject.spec = {
447+
containers: [
448+
{
449+
name: '',
450+
image: '',
451+
ports: [{ containerPort: 80 }],
452+
imagePullPolicy: 'Always',
453+
},
454+
],
455+
nodeName: '',
456+
};
457+
458+
return baseObject;
459+
}
438460
}
439461

440462
export default Pod;

0 commit comments

Comments
 (0)