-
Notifications
You must be signed in to change notification settings - Fork 297
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
Issue / 9284 Refactor AuthError Error Notification to Use New Notifications Datastore #9818
Changes from 9 commits
a86e4ca
1b433fd
9982b6a
d7dce24
1a4919a
1307e04
48ce5b8
660d1ae
92ee5ca
58d5451
d3fb110
f82c01a
226b8dd
918f070
3256d8d
478005d
3455ac6
102dbd6
f66e775
c329711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* AuthError Component Stories. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import WithRegistrySetup from '../../../../tests/js/WithRegistrySetup'; | ||
import { provideUserAuthentication } from '../../../../tests/js/utils'; | ||
import { CORE_USER } from '../../googlesitekit/datastore/user/constants'; | ||
import AuthError from './AuthError'; | ||
import { withNotificationComponentProps } from '../../googlesitekit/notifications/util/component-props'; | ||
|
||
const NotificationWithComponentProps = | ||
withNotificationComponentProps( 'auth-error' )( AuthError ); | ||
|
||
function Template() { | ||
return <NotificationWithComponentProps />; | ||
} | ||
|
||
export const AuthenticationError = Template.bind( {} ); | ||
AuthenticationError.storyName = 'AuthError'; | ||
AuthenticationError.args = { | ||
setupRegistry: ( registry ) => { | ||
provideUserAuthentication( registry ); | ||
|
||
const authError = { | ||
code: 'missing_delegation_consent', | ||
status: 401, | ||
message: | ||
'Looks like your site is not allowed access to Google account data and can’t display stats in the dashboard.', | ||
data: { | ||
reconnectURL: 'https://example.com/', | ||
}, | ||
}; | ||
|
||
registry.dispatch( CORE_USER ).setAuthError( authError ); | ||
}, | ||
}; | ||
AuthenticationError.scenario = { | ||
label: 'Components/Notifications/Banners/AuthError', | ||
aaemnnosttv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
export default { | ||
title: 'Components/Notifications/Banners', | ||
decorators: [ | ||
( Story, { args } ) => { | ||
const setupRegistry = ( registry ) => { | ||
args.setupRegistry( registry ); | ||
}; | ||
|
||
return ( | ||
<WithRegistrySetup func={ setupRegistry }> | ||
<Story /> | ||
</WithRegistrySetup> | ||
); | ||
}, | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -46,6 +46,7 @@ import { | |||||||||||
import { isZeroReport } from '../../modules/analytics-4/utils'; | ||||||||||||
import { MODULES_SEARCH_CONSOLE } from '../../modules/search-console/datastore/constants'; | ||||||||||||
import { READ_SCOPE as TAGMANAGER_READ_SCOPE } from '../../modules/tagmanager/datastore/constants'; | ||||||||||||
import AuthError from '../../components/notifications/AuthError'; | ||||||||||||
import UnsatisfiedScopesAlert from '../../components/notifications/UnsatisfiedScopesAlert'; | ||||||||||||
import UnsatisfiedScopesAlertGTE from '../../components/notifications/UnsatisfiedScopesAlertGTE'; | ||||||||||||
import GatheringDataNotification from '../../components/notifications/GatheringDataNotification'; | ||||||||||||
|
@@ -566,6 +567,29 @@ export const DEFAULT_NOTIFICATIONS = { | |||||||||||
); | ||||||||||||
}, | ||||||||||||
}, | ||||||||||||
'auth-error': { | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's group errors together, this one should go more up, just after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @zutigrm , this has been moved in my latest commits. |
||||||||||||
Component: AuthError, | ||||||||||||
priority: 130, | ||||||||||||
areaSlug: NOTIFICATION_AREAS.ERRORS, | ||||||||||||
viewContexts: [ | ||||||||||||
VIEW_CONTEXT_MAIN_DASHBOARD, | ||||||||||||
VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY, | ||||||||||||
VIEW_CONTEXT_ENTITY_DASHBOARD, | ||||||||||||
VIEW_CONTEXT_ENTITY_DASHBOARD_VIEW_ONLY, | ||||||||||||
VIEW_CONTEXT_SETTINGS, | ||||||||||||
], | ||||||||||||
checkRequirements: async ( { select, resolveSelect } ) => { | ||||||||||||
await Promise.all( [ | ||||||||||||
// The getAuthError() selector relies on the resolution of getAuthentication(). | ||||||||||||
resolveSelect( CORE_USER ).getAuthentication(), | ||||||||||||
] ); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @zutigrm , this has been change to a single resolve in my latest commits. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zutigrm this actually wasn't needed. See #9818 (comment) |
||||||||||||
|
||||||||||||
const error = select( CORE_USER ).getAuthError(); | ||||||||||||
|
||||||||||||
return !! error; | ||||||||||||
}, | ||||||||||||
isDismissible: false, | ||||||||||||
}, | ||||||||||||
}; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this file contains only one scenario data provided here covers the
default
one, we can move this down to the main export, above theargs.setupRegistry( registry );
or instead, since we do not expect more stories, and this can be added in the future if there is a need to expand on scenarios. So this scenario does not need to pass any arguments as they will be handled in the defaul exportThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zutigrm , this has been moved into the default export in my latest commits.