-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Adds an is-busy state to the save button of the widgets page #16019
Conversation
const [ isSaving, setIsSaving ] = useState( false ); | ||
const { saveWidgetAreas } = useDispatch( 'core/edit-widgets' ); | ||
const onClick = useCallback( async () => { | ||
setIsSaving( true ); |
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.
This made me wonder if we'd need a isPerforming
selector for actions similar to the isResolving
one we have for resolvers. cc @aduth
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.
I like this idea but wonder why not also name it isResolving
since, to me, having an entity saved is a 'resolution'.
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.
This made me wonder if we'd need a
isPerforming
selector for actions similar to theisResolving
one we have for resolvers. cc @aduth
Built-in? Or as a pattern?
Generally I'd like if these could actually be resolvers, so we're not setting any state, the state is reflected by the selection of the existing isResolving
on the widgets save resolution.
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.
I was thinking built-in similarily to resolvers but for actions. Technically speaking resolvers and actions are the exact same thing right now (in terms of code), the only different is that one get triggered when you call a selector, the other when you call an action :)
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.
Specifically: #15029 |
const { saveWidgetAreas } = useDispatch( 'core/edit-widgets' ); | ||
const onClick = useCallback( async () => { | ||
setIsSaving( true ); | ||
await saveWidgetAreas(); |
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.
I did not realize this is a thing we could be doing now... and I'm not sure how I feel about it 😅
const [ isSaving, setIsSaving ] = useState( false ); | ||
const { saveWidgetAreas } = useDispatch( 'core/edit-widgets' ); | ||
const onClick = useCallback( async () => { | ||
setIsSaving( true ); |
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.
This made me wonder if we'd need a
isPerforming
selector for actions similar to theisResolving
one we have for resolvers. cc @aduth
Built-in? Or as a pattern?
Generally I'd like if these could actually be resolvers, so we're not setting any state, the state is reflected by the selection of the existing isResolving
on the widgets save resolution.
This PR just updates the save button of the widgets screen to apply the
is-busy
andaria-disabled
states when the widgets are being saved.I also extracted the button to its own component. Notice that the design of the busy state is not great at the moment but this is not specific to the widgets screen and is tracked separately.
I also wanted to add "snackbar notifications" to the save success action but decided to that separately?