/
DeployingIntoManagedClusterWarning.tsx
59 lines (53 loc) · 1.88 KB
/
DeployingIntoManagedClusterWarning.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import React from 'react';
import { IServerGroupCommand } from 'core/serverGroup';
import { FormikProps } from 'formik';
import { Application } from 'core/application';
import { toggleResourcePause } from './toggleResourceManagement';
export interface IDeployingIntoManagedClusterWarningProps {
app: Application;
formik: FormikProps<IServerGroupCommand>;
}
export const DeployingIntoManagedClusterWarning = ({ app, formik }: IDeployingIntoManagedClusterWarningProps) => {
const [userPaused, setUserPaused] = React.useState(false);
const command = formik.values;
const pauseResource = React.useCallback(() => {
const { resourceSummary, backingData } = formik.values;
toggleResourcePause(resourceSummary, app).then(
() => {
backingData.managedResources = app.getDataSource('managedResources')?.data?.resources;
setUserPaused(true);
formik.setFieldValue('resourceSummary', null);
},
() => {},
);
}, [app, formik]);
if (!command.resourceSummary && !userPaused) {
return null;
}
if (userPaused) {
return (
<div className="alert alert-info">
<div className="horizontal top">
<div>
<i className="fa fa-check-circle" />
</div>
<div className="sp-margin-m-left">Resource management has been paused.</div>
</div>
</div>
);
}
return (
<div className="alert alert-danger">
<p>
<b>🌈 Spinnaker is managing this resource.</b>
</p>
<p>Any changes you make to this cluster will be overridden in favor of the desired state.</p>
<p>If you need to manually deploy a new version of this server group, you should pause management.</p>
<div className="sp-margin-m-top">
<button className="passive" onClick={pauseResource}>
<i className="fa fa-pause" /> Pause management
</button>
</div>
</div>
);
};