Skip to content

Commit 59699ef

Browse files
authored
Merge pull request #2844 from DhairyaMajmudar/frontend/ScaleButton
frontend: ScaleButton and RestartButton: Storybook added
2 parents b382b7b + 6263ec9 commit 59699ef

7 files changed

+300
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { Meta, StoryFn } from '@storybook/react';
2+
import Deployment from '../../../lib/k8s/deployment';
3+
import StatefulSet from '../../../lib/k8s/statefulSet';
4+
import { TestContext } from '../../../test';
5+
import { RestartButton } from './RestartButton';
6+
export default {
7+
title: 'Resource/RestartButton',
8+
component: RestartButton,
9+
decorators: [
10+
Story => (
11+
<TestContext>
12+
<Story />
13+
</TestContext>
14+
),
15+
],
16+
} as Meta;
17+
18+
const Template: StoryFn<typeof RestartButton> = args => <RestartButton {...args} />;
19+
20+
const mockDeployment = new Deployment({
21+
metadata: {
22+
name: 'mock-deployment',
23+
namespace: 'default',
24+
creationTimestamp: new Date().toDateString(),
25+
uid: 'mock-uid',
26+
},
27+
spec: {
28+
replicas: 3,
29+
template: {
30+
spec: {
31+
nodeName: 'mock-node',
32+
containers: [
33+
{
34+
name: 'mock-container',
35+
image: 'mock-image',
36+
ports: [{ containerPort: 80 }],
37+
imagePullPolicy: 'Always',
38+
},
39+
],
40+
},
41+
},
42+
},
43+
status: {},
44+
kind: 'Deployment',
45+
});
46+
47+
const mockStatefulSet = new StatefulSet({
48+
metadata: {
49+
name: 'mock-statefulset',
50+
namespace: 'default',
51+
creationTimestamp: new Date().toDateString(),
52+
uid: 'mock-uid',
53+
},
54+
spec: {
55+
replicas: 3,
56+
selector: {
57+
matchLabels: { app: 'headlamp' },
58+
},
59+
updateStrategy: {
60+
rollingUpdate: { partition: 1 },
61+
type: 'RollingUpdate',
62+
},
63+
template: {
64+
spec: {
65+
nodeName: 'mock-node',
66+
containers: [
67+
{
68+
name: 'mock-container',
69+
image: 'mock-image',
70+
ports: [{ containerPort: 80 }],
71+
imagePullPolicy: 'Always',
72+
},
73+
],
74+
},
75+
},
76+
status: {},
77+
},
78+
status: {},
79+
kind: 'StatefulSet',
80+
});
81+
82+
export const DeploymentExample = Template.bind({});
83+
DeploymentExample.args = {
84+
item: mockDeployment,
85+
};
86+
87+
export const StatefulSetExample = Template.bind({});
88+
StatefulSetExample.args = {
89+
item: mockStatefulSet,
90+
};
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import { Meta, StoryFn } from '@storybook/react';
2+
import Deployment from '../../../lib/k8s/deployment';
3+
import ReplicaSet from '../../../lib/k8s/replicaSet';
4+
import StatefulSet from '../../../lib/k8s/statefulSet';
5+
import { TestContext } from '../../../test';
6+
import ScaleButton from './ScaleButton';
7+
8+
export default {
9+
title: 'Resource/ScaleButton',
10+
component: ScaleButton,
11+
decorators: [
12+
Story => (
13+
<TestContext>
14+
<Story />
15+
</TestContext>
16+
),
17+
],
18+
} as Meta;
19+
20+
const Template: StoryFn<typeof ScaleButton> = args => <ScaleButton {...args} />;
21+
22+
const mockDeployment = new Deployment({
23+
metadata: {
24+
name: 'mock-deployment',
25+
namespace: 'default',
26+
creationTimestamp: new Date().toDateString(),
27+
uid: 'mock-uid',
28+
},
29+
spec: {
30+
replicas: 3,
31+
template: {
32+
spec: {
33+
nodeName: 'mock-node',
34+
containers: [
35+
{
36+
name: 'mock-container',
37+
image: 'mock-image',
38+
ports: [{ containerPort: 80 }],
39+
imagePullPolicy: 'Always',
40+
},
41+
],
42+
},
43+
},
44+
},
45+
status: {},
46+
kind: 'Deployment',
47+
});
48+
49+
const mockStatefulSet = new StatefulSet({
50+
metadata: {
51+
name: 'mock-statefulset',
52+
namespace: 'default',
53+
creationTimestamp: new Date().toDateString(),
54+
uid: 'mock-uid',
55+
},
56+
spec: {
57+
replicas: 3,
58+
selector: {
59+
matchLabels: { app: 'headlamp' },
60+
},
61+
updateStrategy: {
62+
rollingUpdate: { partition: 1 },
63+
type: 'RollingUpdate',
64+
},
65+
template: {
66+
spec: {
67+
nodeName: 'mock-node',
68+
containers: [
69+
{
70+
name: 'mock-container',
71+
image: 'mock-image',
72+
ports: [{ containerPort: 80 }],
73+
imagePullPolicy: 'Always',
74+
},
75+
],
76+
},
77+
},
78+
status: {},
79+
},
80+
status: {},
81+
kind: 'StatefulSet',
82+
});
83+
84+
const mockReplicaSet = new ReplicaSet({
85+
metadata: {
86+
name: 'mock-statefulset',
87+
namespace: 'default',
88+
creationTimestamp: new Date().toDateString(),
89+
uid: 'mock-uid',
90+
},
91+
spec: {
92+
minReadySeconds: 0,
93+
replicas: 3,
94+
selector: {
95+
matchLabels: { app: 'headlamp' },
96+
},
97+
template: {
98+
spec: {
99+
nodeName: 'mock-node',
100+
containers: [
101+
{
102+
name: 'mock-container',
103+
image: 'mock-image',
104+
ports: [{ containerPort: 80 }],
105+
imagePullPolicy: 'Always',
106+
},
107+
],
108+
},
109+
},
110+
},
111+
status: {
112+
availableReplicas: 3,
113+
conditions: [],
114+
fullyLabeledReplicas: 3,
115+
observedGeneration: 3,
116+
readyReplicas: 2,
117+
replicas: 3,
118+
},
119+
kind: 'ReplicaSet',
120+
});
121+
122+
export const DeploymentExample = Template.bind({});
123+
DeploymentExample.args = {
124+
item: mockDeployment,
125+
};
126+
127+
export const StatefulSetExample = Template.bind({});
128+
StatefulSetExample.args = {
129+
item: mockStatefulSet,
130+
};
131+
132+
export const ReplicaSetExample = Template.bind({});
133+
ReplicaSetExample.args = {
134+
item: mockReplicaSet,
135+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<body>
2+
<div>
3+
<button
4+
aria-label="Restart"
5+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
6+
data-mui-internal-clone-element="true"
7+
tabindex="0"
8+
type="button"
9+
>
10+
<span
11+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
12+
/>
13+
</button>
14+
</div>
15+
</body>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<body>
2+
<div>
3+
<button
4+
aria-label="Restart"
5+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
6+
data-mui-internal-clone-element="true"
7+
tabindex="0"
8+
type="button"
9+
>
10+
<span
11+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
12+
/>
13+
</button>
14+
</div>
15+
</body>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<body>
2+
<div>
3+
<button
4+
aria-label="Scale"
5+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
6+
data-mui-internal-clone-element="true"
7+
tabindex="0"
8+
type="button"
9+
>
10+
<span
11+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
12+
/>
13+
</button>
14+
</div>
15+
</body>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<body>
2+
<div>
3+
<button
4+
aria-label="Scale"
5+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
6+
data-mui-internal-clone-element="true"
7+
tabindex="0"
8+
type="button"
9+
>
10+
<span
11+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
12+
/>
13+
</button>
14+
</div>
15+
</body>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<body>
2+
<div>
3+
<button
4+
aria-label="Scale"
5+
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-whz9ym-MuiButtonBase-root-MuiIconButton-root"
6+
data-mui-internal-clone-element="true"
7+
tabindex="0"
8+
type="button"
9+
>
10+
<span
11+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
12+
/>
13+
</button>
14+
</div>
15+
</body>

0 commit comments

Comments
 (0)