Skip to content

Commit df03ec0

Browse files
author
Magnus Brurås
authored
Merge pull request #6 from mabruraas/develop
Now displays a warning on container removal.
2 parents 9181a8b + ce21e43 commit df03ec0

File tree

3 files changed

+74
-17
lines changed

3 files changed

+74
-17
lines changed

web/src/components/ContainerDetails.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export default function ContainerDetails (props) {
135135
)}
136136
/>
137137
)}
138-
139138
</LogWrapper>
140139
</Container>
141140
</Flex>

web/src/components/DockContainer.js

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
2-
import styled from 'styled-components';
1+
import React, { useState } from 'react';
2+
import styled, { css } from 'styled-components';
33
import determineColorForString from '../utils/determineColorForString';
44
import DockContainerState from './DockContainerState';
55
import useApi from '../hooks/useApi';
@@ -14,13 +14,18 @@ const DockContainerWrapper = styled.div`
1414
justify-content: space-between;
1515
padding: 1rem;
1616
border-bottom: 1px solid #624694;
17-
1817
@media all and (max-width: 450px) {
1918
flex-direction: column;
2019
}
20+
21+
${props => props.isRemoving && css`
22+
border-bottom: 0;
23+
background-color: #222;
24+
`}
25+
2126
`;
2227

23-
const StyledObjectLink = styled.a`
28+
const StyledObjectLink = styled(({ ...props }) => <Link {...props} />)`
2429
display: flex;
2530
flex-direction: column;
2631
text-decoration: none;
@@ -90,11 +95,16 @@ const StyledActionButton = styled.button`
9095
${COMMON_ACTION_BUTTON_STYLES}
9196
`;
9297

93-
const LogLink = styled(({ ...props }) => <Link {...props} />)`
98+
const SiteLink = styled.a`
9499
color: lightskyblue;
95100
${COMMON_ACTION_BUTTON_STYLES}
96101
`;
97102

103+
const Cancel = styled(StyledActionButton)`
104+
color: #dbdbdb;
105+
`;
106+
107+
98108
const Remove = styled(StyledActionButton)`
99109
color: salmon;
100110
`;
@@ -116,12 +126,34 @@ const Spinner = styled.span`
116126
}
117127
`;
118128

129+
const RemoveWarn = styled.div`
130+
width: 100%;
131+
display: flex;
132+
padding: 1rem;
133+
background: #222;
134+
align-items: center;
135+
justify-content: center;
136+
flex-direction: column;
137+
`;
138+
139+
const StyledWarnHeader = styled.h3`
140+
color: salmon;
141+
margin: 0;
142+
`;
143+
144+
const StyledWarnText = styled.p`
145+
color: salmon;
146+
margin: 1rem;
147+
`;
148+
119149
export default function DockContainer({ imageId, container, handleRefetch }) {
120150

121151
if (!container) {
122152
return null;
123153
}
124154

155+
const [isRemoving, setIsRemoving] = useState(false);
156+
125157
// eslint-disable-next-line
126158
const [restartingContainer, restartResponse, err1, restartContainer] = useApi({
127159
endpoint: `containers/${container.id}/restart`,
@@ -151,8 +183,12 @@ export default function DockContainer({ imageId, container, handleRefetch }) {
151183
}
152184

153185
return (
154-
<DockContainerWrapper>
155-
<StyledObjectLink href={containerHref}>
186+
<div>
187+
188+
189+
190+
<DockContainerWrapper isRemoving={isRemoving}>
191+
<StyledObjectLink to={`/${imageId}/${container.id}`}>
156192
<ContainerNameWrapper>
157193
<ContainerTag color={determineColorForString(container.name)}>
158194
{ restartingContainer ? <Spinner>{loading}</Spinner> : "#" }
@@ -171,11 +207,28 @@ export default function DockContainer({ imageId, container, handleRefetch }) {
171207
removingContainer && <StyledMessage>Removing container..</StyledMessage>
172208
}
173209
</StyledObjectLink>
174-
<ContainerOptions>
175-
{isRestartable && <Restart onClick={() => restartContainer()}>RESTART</Restart>}
176-
{isRemovable && <Remove onClick={() => removeContainer()}>REMOVE</Remove>}
177-
<LogLink to={`/${imageId}/${container.id}`}>VIEW DETAILS</LogLink>
178-
</ContainerOptions>
210+
{
211+
!isRemoving && (
212+
<ContainerOptions>
213+
{isRestartable && <Restart onClick={() => restartContainer()}>RESTART</Restart>}
214+
{isRemovable && <Remove onClick={() => setIsRemoving(true)}>REMOVE</Remove>}
215+
{containerHref !== '#' && <SiteLink href={containerHref}>VIEW SITE</SiteLink>}
216+
</ContainerOptions>
217+
)
218+
}
179219
</DockContainerWrapper>
220+
{
221+
isRemoving && (
222+
<RemoveWarn>
223+
<StyledWarnHeader>Confirm remove</StyledWarnHeader>
224+
<StyledWarnText>Warning: This action cannot be undone.</StyledWarnText>
225+
<ContainerOptions>
226+
<Cancel onClick={() => setIsRemoving(false)}>CANCEL</Cancel>
227+
<Remove onClick={() => removeContainer()}>REMOVE</Remove>
228+
</ContainerOptions>
229+
</RemoveWarn>
230+
)
231+
}
232+
</div>
180233
);
181234
}

web/src/components/Images.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@ const ImageItem = styled(Flex)`
5656
flex-basis: 100%;
5757
}
5858
59-
background-color: ${props => (props.color ? props.color : "#222")};
59+
background-color: #222;
6060
`;
61+
62+
const ChangeNodeImageItem =styled(ImageItem)`
63+
background-color: #62469452;
64+
padding: 2rem;
65+
`;
66+
6167
const Versions = styled.div`
6268
display: flex;
6369
`;
@@ -151,14 +157,13 @@ export default function Images() {
151157

152158
<Busy busy={busy || !selectedNodeContext.hasLoaded}>
153159
<ImagesGrid>
154-
<ImageItem
160+
<ChangeNodeImageItem
155161
child
156162
basis="32%"
157163
gutterBottom
158164
alignItems="center"
159165
justify="center"
160166
fullWidth
161-
color={"#62469452"}
162167
>
163168
<StyledImageLink to={`/nodes`}>
164169
<ImageExtraName>
@@ -173,7 +178,7 @@ export default function Images() {
173178
</ImageExtraName>
174179
<StyledName color={"#fff"}>Change Node</StyledName>
175180
</StyledImageLink>
176-
</ImageItem>
181+
</ChangeNodeImageItem>
177182
{images.map(c => {
178183
return (
179184
<ImageItem

0 commit comments

Comments
 (0)