Skip to content

Commit

Permalink
[MM-57081] Spacing, font and cutoff issues on Channel notifications p…
Browse files Browse the repository at this point in the history
…references modal (mattermost#26478)
  • Loading branch information
M-ZubairAhmed authored Mar 21, 2024
1 parent e43ed71 commit 959e333
Show file tree
Hide file tree
Showing 25 changed files with 607 additions and 854 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,24 @@ describe('CRT Desktop notifications', () => {
cy.visit(testChannelUrl);

cy.uiOpenChannelMenu('Notification Preferences');
cy.get('[data-testid="muteChannel"]').click().then(() => {
cy.get('.AlertBanner--app').should('be.visible');
});
cy.get('.channel-notifications-settings-modal__save-btn').should('be.visible').click();

// # Click on Mute Channel to Unmute Channel
cy.findByText('Mute channel').should('be.visible').click({force: true});

// * Verify that channel is muted alert is visible
cy.findByText('This channel is muted').should('be.visible');

// # Save the changes
cy.findByText('Save').should('be.visible').click();

// Setup notification spy
spyNotificationAs('notifySpy', 'granted');

// # Set users notification settings
cy.uiOpenChannelMenu('Notification Preferences');

// # click on Mute Channel to Unmute Channel
cy.get('[data-testid="muteChannel"]').click();
// # Click on Mute Channel to Unmute Channel
cy.findByText('Mute channel').should('be.visible').click({force: true});

// # Click "Desktop Notifications"
cy.findByText('Desktop Notifications').should('be.visible');
Expand All @@ -83,15 +88,16 @@ describe('CRT Desktop notifications', () => {
cy.get('.channel-notifications-settings-modal__body').scrollTo('center').get('#desktopNotification-none').should('be.visible').click();
cy.get('.channel-notifications-settings-modal__body').get('#desktopNotification-none').should('be.checked');

// # click on Save button
cy.get('.channel-notifications-settings-modal__save-btn').should('be.visible').click();
// # Save the changes
cy.findByText('Save').should('be.visible').click();

// # Set users notification settings
cy.uiOpenChannelMenu('Notification Preferences');
cy.get('.channel-notifications-settings-modal__body').scrollTo('center').get('#desktopNotification-none').should('be.checked');
cy.get('.channel-notifications-settings-modal__body').get('#desktopNotification-all').scrollIntoView().should('be.visible').click();

cy.get('.channel-notifications-settings-modal__save-btn').should('be.visible').click();
// # Save the changes
cy.findByText('Save').should('be.visible').click();

// # Post a root message as other user
cy.postMessageAs({sender, message: 'This is a not followed root message', channelId: testChannelId, rootId: ''}).then(({id: postId}) => {
Expand Down Expand Up @@ -137,6 +143,7 @@ describe('CRT Desktop notifications', () => {
it('MM-T4417_2 Click on sameMobileSettingsDesktop and check if additional settings still appears', () => {
cy.visit(testChannelUrl);
cy.uiOpenChannelMenu('Notification Preferences');

cy.get('.channel-notifications-settings-modal__body').scrollTo('center').get('#desktopNotification-mention').should('be.visible').click().then(() => {
cy.get('[data-testid="desktopReplyThreads"]').should('be.visible').click();
});
Expand All @@ -157,8 +164,8 @@ describe('CRT Desktop notifications', () => {

cy.get('[data-testid="autoFollowThreads"]').should('be.visible').click();

// # click on Save button
cy.get('.channel-notifications-settings-modal__save-btn').should('be.visible').click();
// # Save the changes
cy.findByText('Save').should('be.visible').click();
});

it('MM-T4417_3 Trigger notifications only on mention replies when channel setting is unchecked', () => {
Expand All @@ -168,7 +175,9 @@ describe('CRT Desktop notifications', () => {
spyNotificationAs('notifySpy', 'granted');
cy.uiOpenChannelMenu('Notification Preferences');
cy.get('.channel-notifications-settings-modal__body').scrollTo('center').get('#desktopNotification-mention').should('be.visible').click();
cy.get('.channel-notifications-settings-modal__save-btn').should('be.visible').click();

// # Save the changes
cy.findByText('Save').should('be.visible').click();

// # Post a root message as other user
cy.postMessageAs({sender, message: 'This is a not followed root message', channelId: testChannelId, rootId: ''}).then(({id: postId}) => {
Expand Down
147 changes: 0 additions & 147 deletions webapp/channels/src/components/alert_banner.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

.AlertBanner {
display: flex;
overflow: hidden;
align-items: flex-start;
padding: 14px;
border: 1px solid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {shallow} from 'enzyme';
import React from 'react';

import AlertBanner from './alert_banner';
import AlertBanner from 'components/alert_banner';

describe('Components/AlertBanner', () => {
test('should match snapshot', () => {
Expand Down
139 changes: 139 additions & 0 deletions webapp/channels/src/components/alert_banner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import classNames from 'classnames';
import type {ReactNode} from 'react';
import React, {useMemo} from 'react';
import {useIntl} from 'react-intl';

import {
AlertOutlineIcon,
CheckIcon,
CloseIcon,
InformationOutlineIcon,
} from '@mattermost/compass-icons/components';

import WithTooltip from 'components/with_tooltip';

import './alert_banner.scss';

export type ModeType = 'danger' | 'warning' | 'info' | 'success';

export type AlertBannerProps = {
id?: string;
mode: ModeType;
title?: ReactNode;
customIcon?: ReactNode;
message?: ReactNode;
children?: ReactNode;
className?: string;
hideIcon?: boolean;
actionButtonLeft?: ReactNode;
actionButtonRight?: ReactNode;
footerMessage?: ReactNode;
closeBtnTooltip?: string;
onDismiss?: () => void;
variant?: 'sys' | 'app';
}

const AlertBanner = ({
id,
mode,
title,
customIcon,
message,
className,
variant = 'sys',
onDismiss,
actionButtonLeft,
actionButtonRight,
closeBtnTooltip,
footerMessage,
hideIcon,
children,
}: AlertBannerProps) => {
const {formatMessage} = useIntl();

const bannerIcon = useMemo(() => {
if (customIcon) {
return customIcon;
}

if (mode === 'danger' || mode === 'warning') {
return <AlertOutlineIcon size={24}/>;
} else if (mode === 'success') {
return <CheckIcon size={24}/>;
}
return <InformationOutlineIcon size={24}/>;
}, [mode, customIcon]);

const dismissButton = useMemo(() => {
return (
<button
className='AlertBanner__closeButton'
aria-label={formatMessage({id: 'alert_banner.tooltipCloseBtn', defaultMessage: 'Close'})}
onClick={onDismiss}
>
<CloseIcon size={18}/>
</button>
);
}, [onDismiss]);

return (
<div
data-testid={id}
className={classNames(
'AlertBanner',
mode,
className,
`AlertBanner--${variant}`,
)}
>
{!hideIcon && (
<div className='AlertBanner__icon'>
{bannerIcon}
</div>
)}
<div className='AlertBanner__body'>
{title &&
<div className='AlertBanner__title'>
{title}
</div>
}
{message && (
<div
className={classNames({AlertBanner__message: Boolean(title)})}
>
{message}
</div>
)}
{children}
{(actionButtonLeft || actionButtonRight) && (
<div className='AlertBanner__actionButtons'>
{actionButtonLeft}
{actionButtonRight}
</div>
)}
{footerMessage && (
<div className='AlertBanner__footerMessage'>
{footerMessage}
</div>
)}
</div>
{onDismiss && closeBtnTooltip && (
<WithTooltip
id={`alertBannerTooltip_${id}`}
title={closeBtnTooltip}
placement='left'
>
{dismissButton}
</WithTooltip>
)}
{onDismiss && !closeBtnTooltip && (
dismissButton
)}
</div>
);
};

export default AlertBanner;
Loading

0 comments on commit 959e333

Please sign in to comment.