-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44856: ui: Release notes signup - Show Alert notification after signup r=dhartunian a=koorosh Resolves: #43912 Existing AlertBox component doesn't fit to new designs from Design system, so new one is added as a wrapper on top of Ant design component. The major problem which occur is how to integrate new AlertMessage component to live with old one and do not affect each other behaviour. To achieve this: - AlertMessage component (new one) has the same set of properties. As result it will allow easily consume old alert messages by new component. - To preserve old messages without any changes, one additional property is added to specify which Alert component to show, old or new one. - Current implementation reuses existing logic where we store state of alert in local settings instead of redux store. Co-authored-by: Andrii Vorobiov <[email protected]>
- Loading branch information
Showing
6 changed files
with
211 additions
and
6 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
46 changes: 46 additions & 0 deletions
46
pkg/ui/src/views/shared/components/alertMessage/alertMessage.styl
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,46 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
@require '~src/components/core/index.styl' | ||
|
||
.alert-massage | ||
max-width 470px | ||
font-size 12px | ||
// it is !important because Ant sets margin to 0 | ||
// when closing animation happens and Alert panel | ||
// jumps to the left side. | ||
margin 0 0 0 auto!important | ||
padding-left 48px | ||
border-radius 3px | ||
box-shadow 0 0 10px 0 rgba(71, 88, 114, 0.47) | ||
background-color #ffffff | ||
border-color #ffffff | ||
.alert-massage__icon | ||
font-size 20px | ||
left 16px | ||
.ant-alert-close-icon | ||
margin unset | ||
right 0 | ||
top 0 | ||
padding-right 16px | ||
.ant-alert-message | ||
font-size 14px | ||
color #242a35 | ||
font-weight 600 | ||
|
||
&__close-text | ||
color $colors--neutral-7 | ||
margin $spacing-smaller 0 | ||
font-size $font-size--large | ||
line-height $spacing-smaller | ||
font-weight $font-weight--extra-bold | ||
|
||
.ant-alert-success .alert-massage__icon | ||
color #37a806 |
89 changes: 89 additions & 0 deletions
89
pkg/ui/src/views/shared/components/alertMessage/alertMessage.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,89 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import React from "react"; | ||
import { Alert, Icon } from "antd"; | ||
import { Link } from "react-router-dom"; | ||
|
||
import { AlertInfo, AlertLevel } from "src/redux/alerts"; | ||
import "./alertMessage.styl"; | ||
|
||
interface AlertMessageProps extends AlertInfo { | ||
dismiss(): void; | ||
} | ||
|
||
type AlertType = "success" | "info" | "warning" | "error"; | ||
|
||
const mapAlertLevelToType = (alertLevel: AlertLevel): AlertType => { | ||
switch (alertLevel) { | ||
case AlertLevel.SUCCESS: | ||
return "success"; | ||
case AlertLevel.NOTIFICATION: | ||
return "info"; | ||
case AlertLevel.WARNING: | ||
return "warning"; | ||
case AlertLevel.CRITICAL: | ||
return "error"; | ||
default: | ||
return "info"; | ||
} | ||
}; | ||
|
||
const getIconType = (alertLevel: AlertLevel): string => { | ||
switch (alertLevel) { | ||
case AlertLevel.SUCCESS: | ||
return "check-circle"; | ||
case AlertLevel.NOTIFICATION: | ||
return "info-circle"; | ||
case AlertLevel.WARNING: | ||
return "warning"; | ||
case AlertLevel.CRITICAL: | ||
return "close-circle"; | ||
default: | ||
return "info-circle"; | ||
} | ||
}; | ||
|
||
export class AlertMessage extends React.Component<AlertMessageProps> { | ||
render() { | ||
const { | ||
level, | ||
dismiss, | ||
link, | ||
title, | ||
text, | ||
} = this.props; | ||
|
||
let description: React.ReactNode = text; | ||
|
||
if (link) { | ||
description = <Link to={link} onClick={dismiss}>{text}</Link>; | ||
} | ||
|
||
const type = mapAlertLevelToType(level); | ||
const iconType = getIconType(level); | ||
return ( | ||
<Alert | ||
className="alert-massage" | ||
message={title} | ||
description={description} | ||
showIcon | ||
icon={<Icon type={iconType} theme="filled" className="alert-massage__icon" />} | ||
closable | ||
onClose={dismiss} | ||
closeText={ | ||
<div className="alert-massage__close-text"> | ||
× | ||
</div> | ||
} | ||
type={type} /> | ||
); | ||
} | ||
} |
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,11 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
export * from "./alertMessage"; |