-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/managed): surface pre-deployment steps for versions (#8750)
* feat(core/presentation): add bake icon * feat(core/domain): add lifecycle steps to managed artifact versions * feat(core/managed): show status bubble for baking on versions * feat(core/managed): surface baking on version detail pane Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0cdf836
commit f4d7d14
Showing
8 changed files
with
200 additions
and
2 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
17 changes: 17 additions & 0 deletions
17
app/scripts/modules/core/src/managed/PreDeploymentRow.less
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,17 @@ | ||
.PreDeploymentRow { | ||
max-width: 100%; | ||
|
||
.srow { | ||
display: flex; | ||
align-items: center; | ||
box-shadow: inset 0 -1px 0 0 var(--color-nobel); | ||
height: 44px; | ||
font-size: 16px; | ||
color: var(--color-nobel); | ||
padding-left: 8px; | ||
} | ||
|
||
.titleColumn { | ||
flex-basis: 50%; | ||
} | ||
} |
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,19 @@ | ||
import React from 'react'; | ||
|
||
import './PreDeploymentRow.less'; | ||
|
||
interface IPreDeploymentRowProps { | ||
children?: React.ReactNode; | ||
} | ||
|
||
export function PreDeploymentRow({ children }: IPreDeploymentRowProps) { | ||
return ( | ||
<div className="PreDeploymentRow"> | ||
<div className="srow"> | ||
<div className="titleColumn text-bold flex-container-h left middle sp-margin-s-right">PRE-DEPLOYMENT</div> | ||
</div> | ||
|
||
<div style={{ margin: '16px 0 40px 8px' }}>{children}</div> | ||
</div> | ||
); | ||
} |
96 changes: 96 additions & 0 deletions
96
app/scripts/modules/core/src/managed/PreDeploymentStepCard.tsx
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,96 @@ | ||
import React, { memo } from 'react'; | ||
import ReactGA from 'react-ga'; | ||
import { DateTime } from 'luxon'; | ||
import * as distanceInWords from 'date-fns/distance_in_words'; | ||
|
||
import { IManagedArtifactVersionLifecycleStep } from '../domain'; | ||
import { Application } from '../application'; | ||
|
||
import { StatusCard } from './StatusCard'; | ||
import { Button } from './Button'; | ||
|
||
const SUPPORTED_TYPES = ['BAKE']; | ||
|
||
const cardConfigurationByType = { | ||
BAKE: { | ||
iconName: 'bake', | ||
appearance: { | ||
NOT_STARTED: 'future', | ||
RUNNING: 'info', | ||
SUCCEEDED: 'neutral', | ||
FAILED: 'error', | ||
}, | ||
title: ({ status, startedAt, completedAt }: IManagedArtifactVersionLifecycleStep) => { | ||
const startedAtDate = startedAt ? DateTime.fromISO(startedAt).toJSDate() : null; | ||
const completedAtDate = completedAt ? DateTime.fromISO(completedAt).toJSDate() : null; | ||
|
||
switch (status) { | ||
case 'NOT_STARTED': | ||
return 'An image will be baked before deployment'; | ||
case 'RUNNING': | ||
return 'Baking'; | ||
case 'SUCCEEDED': | ||
return `Baked in ${distanceInWords(startedAtDate, completedAtDate)}`; | ||
case 'FAILED': | ||
return `Baking failed after ${distanceInWords(startedAtDate, completedAtDate)}`; | ||
default: | ||
return null; | ||
} | ||
}, | ||
}, | ||
} as const; | ||
|
||
const logEvent = (label: string, application: string, reference: string, type: string, status: string) => | ||
ReactGA.event({ | ||
category: 'Environments - version details', | ||
action: label, | ||
label: `${application}:${reference}:${type}:${status}`, | ||
}); | ||
|
||
const getTimestamp = (startedAt: string, completedAt: string) => { | ||
if (completedAt) { | ||
return DateTime.fromISO(completedAt); | ||
} else if (startedAt) { | ||
return DateTime.fromISO(startedAt); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
export interface PreDeploymentStepCardProps { | ||
step: IManagedArtifactVersionLifecycleStep; | ||
application: Application; | ||
reference: string; | ||
} | ||
|
||
export const PreDeploymentStepCard = memo(({ step, application, reference }: PreDeploymentStepCardProps) => { | ||
const { type, status, startedAt, completedAt, link } = step; | ||
|
||
if (!SUPPORTED_TYPES.includes(type)) { | ||
return null; | ||
} | ||
|
||
const { iconName, appearance, title } = cardConfigurationByType[type]; | ||
|
||
return ( | ||
<StatusCard | ||
appearance={appearance[status]} | ||
active={status !== 'NOT_STARTED'} | ||
iconName={iconName} | ||
timestamp={getTimestamp(startedAt, completedAt)} | ||
title={title(step)} | ||
actions={ | ||
link && ( | ||
<Button | ||
onClick={() => { | ||
window.open(link, '_blank', 'noopener noreferrer'); | ||
logEvent('Pre-deployment details link clicked', application.name, reference, type, status); | ||
}} | ||
> | ||
See {status === 'RUNNING' ? 'progress' : 'details'} | ||
</Button> | ||
) | ||
} | ||
/> | ||
); | ||
}); |
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
34 changes: 34 additions & 0 deletions
34
app/scripts/modules/core/src/presentation/icons/vectors/bake.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.