-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/content-analysis-in-sidebar' into stories/9305-…
…2-implement-openSections
- Loading branch information
Showing
15 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* global wp */ | ||
|
||
import isUndefined from "lodash/isUndefined"; | ||
|
||
/** | ||
* Checks if the data API from Gutenberg is available. | ||
* | ||
* @returns {boolean} True if the data API is available. | ||
*/ | ||
export const isGutenbergDataAvailable = () => { | ||
return ( ! isUndefined( window.wp ) && ! isUndefined( wp.data ) ); | ||
}; | ||
|
||
/** | ||
* Checks if the Gutenberg editor is being used. | ||
* | ||
* Gutenberg uses wp_add_inline_script to pass along the initial post data. | ||
* Therefor we can test if this variable exists to know if the Gutenberg editor is being used. | ||
* see: https://github.com/WordPress/gutenberg/blob/master/lib/client-assets.php#L853 | ||
* | ||
* @returns {boolean} True if the Gutenberg editor is being used. | ||
*/ | ||
export const isGutenbergPostAvailable = () => { | ||
return ! isUndefined( window._wpGutenbergPost ); | ||
}; |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
const PREFIX = "WPSEO_"; | ||
|
||
export const TOGGLE_CORNERSTONE_CONTENT = `${ PREFIX }TOGGLE_CORNERSTONE_CONTENT`; | ||
|
||
/** | ||
* An action creator for toggling whether the current item is cornerstone content or not. | ||
* | ||
* @returns {Object} The toggle cornerstone content action. | ||
*/ | ||
export const toggleCornerstoneContent = function() { | ||
return { | ||
type: TOGGLE_CORNERSTONE_CONTENT, | ||
}; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { TOGGLE_CORNERSTONE_CONTENT } from "../actions/cornerstoneContent"; | ||
|
||
const INITIAL_STATE = false; | ||
|
||
/** | ||
* A reducer for the active keyword. | ||
* | ||
* @param {boolean} state The current state of the object. | ||
* @param {Object} action The current action received. | ||
* | ||
* @returns {boolean} The state. | ||
*/ | ||
function cornerstoneContentReducer( state = INITIAL_STATE, action ) { | ||
switch( action.type ) { | ||
case TOGGLE_CORNERSTONE_CONTENT: | ||
return ! state; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export default cornerstoneContentReducer; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* global describe, it, expect */ | ||
|
||
import * as actions from "../../../src/redux/actions/cornerstoneContent"; | ||
|
||
describe( "cornerstone actions", () => { | ||
it( "toggleCornerstoneContent should return an action with the TOGGLE_CORNERSTONE_CONTENT type", () => { | ||
const expected = { | ||
type: actions.TOGGLE_CORNERSTONE_CONTENT, | ||
}; | ||
const actual = actions.toggleCornerstoneContent(); | ||
|
||
expect( actual ).toEqual( expected ); | ||
} ); | ||
} ); |
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,26 @@ | ||
/* global describe, it, expect */ | ||
|
||
import { toggleCornerstoneContent } from "../../../src/redux/actions/cornerstoneContent"; | ||
import cornerstoneContentReducer from "../../../src/redux/reducers/cornerstoneContent"; | ||
|
||
describe( "cornerstone reducers", () => { | ||
describe( "cornerstoneContentReducer on receiving the TOGGLE_CORNERSTONE_CONTENT action", () => { | ||
it( "should set isCornerstoneContent's current value to true if it was false", () => { | ||
const state = false; | ||
const action = toggleCornerstoneContent(); | ||
const expected = true; | ||
const actual = cornerstoneContentReducer( state, action ); | ||
|
||
expect( actual ).toEqual( expected ); | ||
} ); | ||
|
||
it( "should set isCornerstoneContent's current value to false if it was true", () => { | ||
const state = true; | ||
const action = toggleCornerstoneContent(); | ||
const expected = false; | ||
const actual = cornerstoneContentReducer( state, action ); | ||
|
||
expect( actual ).toEqual( expected ); | ||
} ); | ||
} ); | ||
} ); |