Skip to content

Commit

Permalink
Enable dismissal of global notice
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Feb 16, 2023
1 parent c991412 commit bdb867a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions settings/src/components/global-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
import { Flex, Snackbar } from '@wordpress/components';
import { check } from '@wordpress/icons';

export default function GlobalNotice( { notice } ) {
export default function GlobalNotice( { notice, setNotice } ) {
if ( ! notice ) {
return;
}

const onRemove = () => {
setNotice( '' );
}

return (
<Flex justify="flex-end">
<Snackbar className="wporg-2fa__global-notice" icon={ check }>
<Snackbar
className="wporg-2fa__global-notice"
icon={ check }
explicitDismiss
onRemove={ onRemove }
>
{ notice }
</Snackbar>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion settings/src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function Main( { userId } ) {

return (
<GlobalContext.Provider value={ { clickScreenLink, userRecord, setGlobalNotice } }>
<GlobalNotice notice={ globalNotice } />
<GlobalNotice notice={ globalNotice } setNotice={ setGlobalNotice } />
{ screenContent }
</GlobalContext.Provider>
);
Expand Down

0 comments on commit bdb867a

Please sign in to comment.