Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alert bar component #17230

Draft
wants to merge 103 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
e789776
add alert bar component
sweta1308 Jul 30, 2024
9800572
Merge branch 'main' into alert-bar
sweta1308 Jul 30, 2024
8d832a5
updated as per comments
sweta1308 Jul 30, 2024
6e93bd1
Merge branch 'main' into alert-bar
sweta1308 Jul 30, 2024
15c64d6
updated as per comments
sweta1308 Jul 30, 2024
1caed64
updated alert bar component
sweta1308 Jul 31, 2024
e896c06
Merge branch 'main' into alert-bar
Sachin-chaurasiya Jul 31, 2024
ca7bafa
remove styles attributes
sweta1308 Jul 31, 2024
3f1dbd8
update styles
sweta1308 Jul 31, 2024
dd30c31
Merge branch 'main' into alert-bar
sweta1308 Jul 31, 2024
6dc6f64
Merge branch 'main' into alert-bar
Sachin-chaurasiya Jul 31, 2024
f87e47a
Merge branch 'main' into alert-bar
sweta1308 Jul 31, 2024
0c30bb1
add alert store and use alert in page layout
sweta1308 Jul 31, 2024
28d028b
Merge branch 'main' into alert-bar
Sachin-chaurasiya Jul 31, 2024
beb3e7c
update component to have reset method
sweta1308 Jul 31, 2024
d50634a
refactor: update reset calling method
sweta1308 Jul 31, 2024
3c00265
Merge branch 'main' into alert-bar
Sachin-chaurasiya Jul 31, 2024
2e6ad18
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 1, 2024
feae113
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 1, 2024
993a0ad
Merge branch 'main' into alert-bar
sweta1308 Aug 2, 2024
21535a0
Merge branch 'main' into alert-bar
sweta1308 Aug 2, 2024
42ec872
update reset method name
sweta1308 Aug 2, 2024
760b772
Merge branch 'main' into alert-bar
sweta1308 Aug 2, 2024
8f9bccf
updated as per feedbacks
sweta1308 Aug 2, 2024
0f12a12
refcator: update CrossIcon component usage
sweta1308 Aug 2, 2024
5a62c22
Merge branch 'main' into alert-bar
sweta1308 Aug 2, 2024
57927c0
chore: remove condition for CrossIcon
sweta1308 Aug 2, 2024
2073bfa
update animation for opening alert bar.
sweta1308 Aug 5, 2024
f48bb8d
Merge branch 'main' into alert-bar
sweta1308 Aug 5, 2024
e15b877
add autoCloseTimer to alert banner
sweta1308 Aug 5, 2024
3970cb6
remove cross icon component
sweta1308 Aug 5, 2024
7c16a64
add cross icon svg
sweta1308 Aug 5, 2024
eab3649
update to fix the height issue
sweta1308 Aug 5, 2024
6145a81
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 5, 2024
f830beb
Merge branch 'main' into alert-bar
sweta1308 Aug 6, 2024
5f8eaf8
Merge branch 'main' into alert-bar
sweta1308 Aug 6, 2024
5ea9c29
Merge branch 'main' into alert-bar
sweta1308 Aug 6, 2024
664c828
Merge branch 'main' into alert-bar
sweta1308 Aug 6, 2024
1633888
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 6, 2024
061c808
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 6, 2024
06b9fb0
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 6, 2024
79edf42
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 7, 2024
f34995d
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 7, 2024
d6dad5a
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 7, 2024
772c408
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 7, 2024
d8f12bd
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 7, 2024
b3710b1
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 8, 2024
be76be2
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 8, 2024
cad15ff
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 9, 2024
3707793
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 9, 2024
46ea364
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 9, 2024
c144736
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 10, 2024
60e376c
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 10, 2024
75c91f4
Merge branch 'main' into alert-bar
Sachin-chaurasiya Aug 11, 2024
229eb76
Merge branch 'main' into alert-bar
sweta1308 Aug 20, 2024
0eb761a
Merge branch 'main' into alert-bar
sweta1308 Aug 20, 2024
e95f918
Merge branch 'main' into alert-bar
sweta1308 Aug 21, 2024
5acc9bf
Merge branch 'main' into alert-bar
Sachin-chaurasiya Sep 3, 2024
c90f17c
Merge branch 'main' into alert-bar
sweta1308 Sep 4, 2024
8c3d968
Merge branch 'main' into alert-bar
sweta1308 Sep 4, 2024
5314897
Merge branch 'main' into alert-bar
sweta1308 Sep 16, 2024
1d88cff
Merge branch 'main' into alert-bar
Sachin-chaurasiya Sep 16, 2024
304e661
Merge branch 'main' into alert-bar
sweta1308 Sep 18, 2024
ea57b3e
Merge branch 'main' into alert-bar
sweta1308 Sep 19, 2024
1bc3307
Merge branch 'main' into alert-bar
sweta1308 Sep 19, 2024
e1e6181
fix height glitch issue when alert appears
sweta1308 Sep 20, 2024
5b94326
update the alert notification tests
sweta1308 Sep 20, 2024
a2a03a8
Merge branch 'main' into alert-bar
sweta1308 Sep 23, 2024
fafdc9d
Merge branch 'main' into alert-bar
sweta1308 Sep 24, 2024
c545756
update alert transition issue
sweta1308 Sep 24, 2024
f54efcf
Merge branch 'main' into alert-bar
sweta1308 Sep 25, 2024
f0791ca
revert the changes for height issue
sweta1308 Sep 25, 2024
fa6f712
resolve conflicts
Sachin-chaurasiya Oct 3, 2024
fc1c6fd
Merge branch 'main' into alert-bar
sweta1308 Oct 3, 2024
1d58d1b
Merge branch 'main' into alert-bar
sweta1308 Oct 17, 2024
cb9179b
Merge branch 'main' into alert-bar
sweta1308 Oct 22, 2024
a6a3a41
add alert in mydata
sweta1308 Oct 22, 2024
d4581ae
update alert animation issue
sweta1308 Oct 23, 2024
046f15a
update alert position in page layout
sweta1308 Oct 24, 2024
ad5e0e5
Merge branch 'main' into alert-bar
sweta1308 Oct 24, 2024
132e519
update as per feedbacks
sweta1308 Oct 24, 2024
f524134
fix tests failure
sweta1308 Oct 24, 2024
ef5d462
update test for toast
sweta1308 Oct 24, 2024
78c9f47
remove dummy alert bar
sweta1308 Oct 25, 2024
f3207b3
made alert fixed to top
sweta1308 Oct 25, 2024
31d7a75
fix check failing issue
sweta1308 Oct 28, 2024
0fb436c
fix activity feed playwright test issue
Ashish8689 Oct 29, 2024
a1f9b5b
Merge branch 'main' into alert-bar
sweta1308 Nov 4, 2024
5ad7cc9
Merge branch 'main' into alert-bar
sweta1308 Nov 5, 2024
cfde10c
update test
sweta1308 Nov 5, 2024
415987f
Merge branch 'main' into alert-bar
sweta1308 Nov 12, 2024
4a623e7
Merge branch 'main' into alert-bar
sweta1308 Nov 18, 2024
b436d8a
fix test issues
sweta1308 Nov 18, 2024
12c7128
Merge branch 'main' into alert-bar
sweta1308 Nov 18, 2024
939fa6d
update page layout
sweta1308 Nov 18, 2024
eedaaf6
fix sonar cloud failure
sweta1308 Nov 18, 2024
f9452fa
fix sonar cloud failure
sweta1308 Nov 18, 2024
8829ce0
fix test issues
sweta1308 Nov 18, 2024
c1da88c
Merge branch 'main' into alert-bar
sweta1308 Nov 18, 2024
383bb89
Merge branch 'main' into alert-bar
sweta1308 Nov 19, 2024
ae75bbb
resolve sonar issue
sweta1308 Nov 19, 2024
34cbcce
Merge branch 'main' into alert-bar
sweta1308 Nov 19, 2024
2543331
Merge branch 'main' into alert-bar
sweta1308 Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
sweta1308 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type AlertBarType = 'general' | 'info' | 'success' | 'warning' | 'error';

export interface AlertBarProps {
type: AlertBarType;
message: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Icon from '@ant-design/icons';
import { Alert } from 'antd';
import classNames from 'classnames';
import React, { useMemo } from 'react';
import { ReactComponent as ErrorCross } from '../../assets/svg/error-cross.svg';
import { ReactComponent as CrossIcon } from '../../assets/svg/ic-cross.svg';
import { ReactComponent as ErrorIcon } from '../../assets/svg/ic-error.svg';
import { ReactComponent as GeneralIcon } from '../../assets/svg/ic-general.svg';
import { ReactComponent as InfoIcon } from '../../assets/svg/ic-info-tag.svg';
import { ReactComponent as SuccessIcon } from '../../assets/svg/ic-success.svg';
import { ReactComponent as WarningIcon } from '../../assets/svg/ic-warning-tag.svg';
import { ReactComponent as InfoCross } from '../../assets/svg/info-cross.svg';
import { ReactComponent as SuccessCross } from '../../assets/svg/success-cross.svg';
import { ReactComponent as WarningCross } from '../../assets/svg/warning-cross.svg';
import { useAlertStore } from '../../hooks/useAlertBar';
import './alert-bar.style.less';
import { AlertBarProps } from './AlertBar.interface';

const AlertBar = ({
type = 'general',
message = '',
}: AlertBarProps): JSX.Element => {
const { resetAlert } = useAlertStore();

const {
icon: AlertIcon,
className,
crossIcon: CloseIcon,
} = useMemo(() => {
switch (type) {
case 'info':
return {
icon: InfoIcon,
className: 'info',
crossIcon: InfoCross,
};

case 'success':
return {
icon: SuccessIcon,
className: 'success',
crossIcon: SuccessCross,
};

case 'warning':
return {
icon: WarningIcon,
className: 'warning',
crossIcon: WarningCross,
};

case 'error':
return {
icon: ErrorIcon,
className: 'error',
crossIcon: ErrorCross,
};

default:
return {
Sachin-chaurasiya marked this conversation as resolved.
Show resolved Hide resolved
icon: GeneralIcon,
className: 'general',
crossIcon: CrossIcon,
};
}
}, [type]);

return (
<>
sweta1308 marked this conversation as resolved.
Show resolved Hide resolved
{type === 'general' ? (
<div className={`alert-container ${className}`}>
<div className="alert-content">
<Icon className="align-middle alert-icon" component={AlertIcon} />
<p>{message}</p>
</div>
<button className="cross-icon" onClick={resetAlert}>
<Icon className="align-middle" component={CloseIcon} />
</button>
</div>
sweta1308 marked this conversation as resolved.
Show resolved Hide resolved
) : (
<Alert
closable
showIcon
className={classNames(className, 'alert-container')}
closeIcon={<CloseIcon />}
description={message}
icon={<AlertIcon />}
type={type}
onClose={resetAlert}
/>
)}
</>
);
};

export default AlertBar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.alert-container {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
font-size: 16px;

&.ant-alert-with-description {
padding: 20px;
}

&.general {
background-color: #f6f7f9;
color: #292929;
}

&.info {
background-color: #f6f8ff;
color: #0950c5;
border: none;
border-radius: 0px;
}

&.success {
background-color: #f5fbf8;
color: #1d7c4d;
border: none;
border-radius: 0px;
}

&.warning {
background-color: #fff5eb;
color: #f59638;
border: none;
border-radius: 0px;
}

&.error {
background-color: #fcf0f1;
color: #cb2531;
border: none;
border-radius: 0px;
}

.alert-content {
display: flex;
align-items: center;
gap: 8px;
}

.alert-icon {
font-size: 25px;
}

.cross-icon {
cursor: pointer;
background-color: transparent;
border: none;
font-size: 14px;
}

.ant-alert-description {
font-size: 16px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import React, {
ReactNode,
useMemo,
} from 'react';
import { useAlertStore } from '../../hooks/useAlertBar';
import AlertBar from '../AlertBar/AlertBar';
import DocumentTitle from '../common/DocumentTitle/DocumentTitle';
import './../../styles/layout/page-layout.less';

Expand Down Expand Up @@ -60,6 +62,8 @@ const PageLayoutV1: FC<PageLayoutProp> = ({
mainContainerClassName = '',
pageContainerStyle = {},
}: PageLayoutProp) => {
const { alert } = useAlertStore();

const contentWidth = useMemo(() => {
if (leftPanel && rightPanel) {
return `calc(100% - ${leftPanelWidth + rightPanelWidth}px)`;
Expand Down Expand Up @@ -99,27 +103,36 @@ const PageLayoutV1: FC<PageLayoutProp> = ({
{leftPanel}
</Col>
)}
<Col
className={classNames(
'page-layout-v1-center p-t-sm page-layout-v1-vertical-scroll',
{
'flex justify-center': center,
},
mainContainerClassName
<Col className="w-full">
{alert && (
<Row>
<AlertBar message={alert.message} type={alert.type} />
</Row>
)}
flex={contentWidth}
offset={center ? 3 : 0}
span={center ? 18 : 24}>
{children}
<Row>
<Col
className={classNames(
'page-layout-v1-center p-t-sm page-layout-v1-vertical-scroll',
{
'flex justify-center': center,
},
mainContainerClassName
)}
flex={contentWidth}
offset={center ? 3 : 0}
span={center ? 18 : 24}>
{children}
</Col>
{rightPanel && (
<Col
className="page-layout-rightpanel page-layout-v1-vertical-scroll"
flex={rightPanelWidth + 'px'}
id="right-panelV1">
{rightPanel}
</Col>
)}
</Row>
</Col>
{rightPanel && (
<Col
className="page-layout-rightpanel page-layout-v1-vertical-scroll"
flex={rightPanelWidth + 'px'}
id="right-panelV1">
{rightPanel}
</Col>
)}
</Row>
</Fragment>
);
Expand Down
35 changes: 35 additions & 0 deletions openmetadata-ui/src/main/resources/ui/src/hooks/useAlertBar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { create } from 'zustand';
import { AlertBarType } from '../components/AlertBar/AlertBar.interface';

type AlertType = {
type: AlertBarType;
message: string;
};

interface AlertStore {
alert: AlertType | undefined;
addAlert: (alert: AlertType) => void;
resetAlert: () => void;
}

export const useAlertStore = create<AlertStore>()((set) => ({
alert: undefined,
addAlert: (alert: AlertType) => {
set({ alert });
},
resetAlert: () => {
set({ alert: undefined });
},
}));
Loading
Loading