Skip to content

Commit 0a4a759

Browse files
authored
Merge pull request #1375 from bbc/feat/consistent-rundown-activation-logic
Feat: Consistent rundown activation logic
2 parents 7ba5ede + d2b30f0 commit 0a4a759

File tree

3 files changed

+174
-42
lines changed

3 files changed

+174
-42
lines changed

packages/webui/src/client/lib/ModalDialog.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface IModalDialogAttributes {
2727
warning?: boolean
2828
actions?: ModalAction[]
2929
className?: string
30+
discardAsPrimary?: boolean
3031
}
3132
interface ModalInput {
3233
type: EditAttributeType
@@ -56,6 +57,7 @@ export function ModalDialog({
5657
onDiscard,
5758
onSecondary,
5859
secondaryText,
60+
discardAsPrimary,
5961
}: React.PropsWithChildren<IModalDialogAttributes>): JSX.Element | null {
6062
const { t } = useTranslation()
6163
const inputResult = useRef<ModalInputResult>(
@@ -114,7 +116,7 @@ export function ModalDialog({
114116
e.stopPropagation()
115117

116118
if (isAcceptKey(e.code)) {
117-
handleAccept(e)
119+
discardAsPrimary ? handleDiscard(e) : handleAccept(e)
118120
} else if (isDismissKey(e.code)) {
119121
handleDiscard(e)
120122
}
@@ -203,13 +205,23 @@ export function ModalDialog({
203205
</div>
204206
) : null}
205207
<div
206-
className={ClassNames('mod', {
207-
alright: !secondaryText,
208-
})}
208+
className={ClassNames(
209+
'mod',
210+
{
211+
alright: !secondaryText,
212+
},
213+
'modal-dialog-actions'
214+
)}
209215
>
210216
{secondaryText && (
211217
<button
212-
className="btn btn-secondary"
218+
className={ClassNames(
219+
'btn',
220+
discardAsPrimary ? 'btn-primary' : 'btn-secondary',
221+
'discard-btn',
222+
{ 'btn-warn': discardAsPrimary && warning }
223+
)}
224+
autoFocus={discardAsPrimary}
213225
onClick={handleSecondary}
214226
onKeyDown={preventClickOnEnter}
215227
onKeyUp={emulateClick}
@@ -240,11 +252,11 @@ export function ModalDialog({
240252
})
241253
)}
242254
<button
243-
className={ClassNames('btn btn-primary', {
255+
className={ClassNames('btn', !discardAsPrimary ? 'btn-primary' : 'btn-secondary', {
244256
right: secondaryText !== undefined,
245-
'btn-warn': warning,
257+
'btn-warn': !discardAsPrimary && warning,
246258
})}
247-
autoFocus
259+
autoFocus={!discardAsPrimary}
248260
onClick={handleAccept}
249261
onKeyDown={preventClickOnEnter}
250262
onKeyUp={emulateClick}
@@ -284,6 +296,8 @@ export interface ModalDialogQueueItem {
284296
actions?: ModalAction[]
285297
/** Is a critical decition/information */
286298
warning?: boolean
299+
/** Discard as primary */
300+
discardAsPrimary?: boolean
287301
}
288302
interface IModalDialogGlobalContainerProps {}
289303
interface IModalDialogGlobalContainerState {
@@ -382,6 +396,7 @@ class ModalDialogGlobalContainer0 extends React.Component<
382396
actions={actions}
383397
show={true}
384398
warning={onQueue.warning}
399+
discardAsPrimary={onQueue.discardAsPrimary}
385400
>
386401
{_.isString(onQueue.message) ? this.renderString(onQueue.message) : onQueue.message}
387402
</ModalDialog>

packages/webui/src/client/styles/modalDialog.scss

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
padding: 0;
55
border: none;
66
pointer-events: auto;
7+
min-width: 550px;
78

89
.big {
9-
max-width: 500px;
10+
max-width: 550px;
1011
width: 100%;
1112
}
1213

@@ -18,14 +19,40 @@
1819
}
1920
}
2021

22+
.modal-dialog-actions {
23+
display: flex;
24+
justify-content: space-between;
25+
26+
.discard-btn {
27+
margin-right: 2rem;
28+
margin-left: 0px;
29+
}
30+
}
31+
2132
.dark .border-box {
2233
color: #fff;
2334
}
2435

36+
.btn {
37+
font-weight: 100;
38+
min-width: fit-content;
39+
}
40+
41+
.btn.btn-primary {
42+
font-weight: 500;
43+
border: #fffcfc;
44+
border-width: 1px;
45+
border-style: solid;
46+
}
47+
48+
2549
.btn.btn-primary.btn-warn {
2650
background: #e62421;
2751
border-color: #e62421;
2852
color: #ffffff;
53+
border: #ffffff;
54+
border-width: 1px;
55+
border-style: solid;
2956
}
3057

3158
.btn.btn-secondary.btn-warn {

0 commit comments

Comments
 (0)