-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reset options to my jetpack footer (#40943)
* Add option to reset jetpack options on My Jetpack footer for devs * changelog * Use additional menu items in admin page footer * Use existing prop for jetpack footer
- Loading branch information
1 parent
d412ede
commit bedc278
Showing
9 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/js-packages/components/changelog/add-option-for-custom-footer-items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Add option for additional custom footer elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
projects/packages/my-jetpack/_inc/data/utils/onKeyDownCallback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Used to wrap a callback function in a keydown event listener to act as a button element would | ||
const onKeyDownCallback = ( event: KeyboardEvent, callback: () => void ) => { | ||
if ( event.key === 'Enter' || event.key === ' ' ) { | ||
callback(); | ||
} | ||
}; | ||
|
||
export default onKeyDownCallback; |
32 changes: 32 additions & 0 deletions
32
projects/packages/my-jetpack/_inc/data/utils/reset-jetpack-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import restApi from '@automattic/jetpack-api'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { getMyJetpackWindowRestState } from './get-my-jetpack-window-state'; | ||
|
||
const resetJetpackOptions = async () => { | ||
const { apiRoot, apiNonce } = getMyJetpackWindowRestState(); | ||
restApi.setApiRoot( apiRoot ); | ||
restApi.setApiNonce( apiNonce ); | ||
|
||
if ( | ||
// eslint-disable-next-line no-alert | ||
window.confirm( | ||
__( 'This will reset all Jetpack options, are you sure?', 'jetpack-my-jetpack' ) | ||
) | ||
) { | ||
try { | ||
const res = await restApi.resetOptions( 'options' ); | ||
|
||
if ( res.code === 'success' ) { | ||
// eslint-disable-next-line no-alert | ||
window.alert( | ||
__( 'Options reset! Have fun messing them up again :-)', 'jetpack-my-jetpack' ) | ||
); | ||
} | ||
} catch { | ||
// eslint-disable-next-line no-alert | ||
window.alert( __( 'Options failed to reset.', 'jetpack-my-jetpack' ) ); | ||
} | ||
} | ||
}; | ||
|
||
export default resetJetpackOptions; |
4 changes: 4 additions & 0 deletions
4
projects/packages/my-jetpack/changelog/add-reset-options-to-my-jetpack-footer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Add option for devs to reset jetpack options from My Jetpack footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters