newspack-components 2.0.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/copy-styles.js +1 -1
- package/dist/cjs/accordion/index.js +46 -0
- package/dist/cjs/accordion/style.scss +27 -0
- package/dist/cjs/action-card/index.js +72 -40
- package/dist/cjs/action-card/style.scss +143 -41
- package/dist/cjs/autocomplete-tokenfield/index.js +13 -41
- package/dist/cjs/autocomplete-tokenfield/style.scss +6 -6
- package/dist/cjs/autocomplete-with-suggestions/index.js +33 -53
- package/dist/cjs/autocomplete-with-suggestions/style.scss +27 -27
- package/dist/cjs/button/index.js +1 -20
- package/dist/cjs/button/style.scss +3 -344
- package/dist/cjs/button-card/index.js +11 -15
- package/dist/cjs/button-card/style.scss +65 -35
- package/dist/cjs/card/index.js +4 -9
- package/dist/cjs/card/style.scss +47 -63
- package/dist/cjs/category-autocomplete/index.js +66 -47
- package/dist/cjs/category-autocomplete/style.scss +20 -24
- package/dist/cjs/color-picker/index.js +16 -48
- package/dist/cjs/color-picker/style.scss +20 -163
- package/dist/cjs/consts.js +5 -3
- package/dist/cjs/custom-select-control/index.js +1 -9
- package/dist/cjs/custom-select-control/style.scss +14 -45
- package/dist/cjs/date-range-picker/index.js +1 -10
- package/dist/cjs/date-range-picker/style.scss +12 -12
- package/dist/cjs/footer/index.js +24 -22
- package/dist/cjs/footer/style.scss +13 -14
- package/dist/cjs/form-token-field/index.js +3 -11
- package/dist/cjs/form-token-field/style.scss +9 -105
- package/dist/cjs/global-notices/index.js +3 -9
- package/dist/cjs/grid/index.js +1 -8
- package/dist/cjs/grid/style.scss +19 -6
- package/dist/cjs/handoff/index.js +15 -24
- package/dist/cjs/handoff-message/index.js +50 -0
- package/dist/cjs/hooks/index.js +1 -7
- package/dist/cjs/hooks/useObjectState.js +7 -13
- package/dist/cjs/hooks/useObjectState.test.js +0 -14
- package/dist/cjs/hooks/useOnClickOutside.js +3 -6
- package/dist/cjs/hooks/usePrompt.js +1 -13
- package/dist/cjs/image-upload/index.js +22 -20
- package/dist/cjs/image-upload/index.test.js +0 -5
- package/dist/cjs/image-upload/style.scss +12 -17
- package/dist/cjs/index.js +31 -93
- package/dist/cjs/info-button/index.js +3 -11
- package/dist/cjs/info-button/style.scss +1 -3
- package/dist/cjs/modal/index.js +1 -12
- package/dist/cjs/modal/style.scss +20 -132
- package/dist/cjs/newspack-icon/index.js +5 -11
- package/dist/cjs/newspack-icon/style.scss +17 -2
- package/dist/cjs/newspack-logo/index.js +1 -9
- package/dist/cjs/newspack-logo/style.scss +3 -3
- package/dist/cjs/notice/index.js +8 -16
- package/dist/cjs/notice/style.scss +60 -19
- package/dist/cjs/patrons-logo/index.js +3 -11
- package/dist/cjs/plugin-installer/index.js +37 -37
- package/dist/cjs/plugin-installer/style.scss +5 -5
- package/dist/cjs/plugin-settings/SettingsSection.js +71 -59
- package/dist/cjs/plugin-settings/index.js +71 -50
- package/dist/cjs/plugin-settings/style.scss +7 -0
- package/dist/cjs/plugin-toggle/index.js +60 -32
- package/dist/cjs/plugin-toggle/style.scss +2 -2
- package/dist/cjs/popover/index.js +1 -11
- package/dist/cjs/popover/style.scss +20 -17
- package/dist/cjs/position-control/index.js +113 -0
- package/dist/cjs/position-control/style.scss +66 -0
- package/dist/cjs/progress-bar/index.js +2 -9
- package/dist/cjs/progress-bar/index.test.js +2 -7
- package/dist/cjs/progress-bar/style.scss +4 -4
- package/dist/cjs/proxied-imports/router.js +0 -3
- package/dist/cjs/radio-control/index.js +1 -11
- package/dist/cjs/radio-control/style.scss +10 -11
- package/dist/cjs/section-header/index.js +47 -19
- package/dist/cjs/section-header/style.scss +22 -1
- package/dist/cjs/select-control/ButtonGroupControl.js +11 -20
- package/dist/cjs/select-control/GroupedSelectControl.js +42 -45
- package/dist/cjs/select-control/index.js +6 -14
- package/dist/cjs/select-control/style.scss +47 -88
- package/dist/cjs/settings/MinMaxSetting.js +6 -8
- package/dist/cjs/settings/SettingsCard.js +9 -8
- package/dist/cjs/settings/SettingsSection.js +5 -8
- package/dist/cjs/settings/index.js +0 -6
- package/dist/cjs/settings/style.scss +32 -4
- package/dist/cjs/steps-list/index.js +52 -0
- package/dist/cjs/steps-list/style.scss +11 -0
- package/dist/cjs/steps-list-item/index.js +56 -0
- package/dist/cjs/steps-list-item/style.scss +47 -0
- package/dist/cjs/style-card/index.js +15 -18
- package/dist/cjs/style-card/style.scss +19 -18
- package/dist/cjs/style.scss +43 -0
- package/dist/cjs/tabbed-navigation/index.js +27 -31
- package/dist/cjs/tabbed-navigation/style.scss +58 -37
- package/dist/cjs/text-control/index.js +6 -19
- package/dist/cjs/text-control/style.scss +0 -126
- package/dist/cjs/utils/index.js +10 -5
- package/dist/cjs/waiting/index.js +9 -33
- package/dist/cjs/waiting/style.scss +9 -20
- package/dist/cjs/web-preview/index.js +30 -57
- package/dist/cjs/web-preview/style.scss +41 -34
- package/dist/cjs/with-wizard/index.js +55 -33
- package/dist/cjs/with-wizard/style.scss +77 -124
- package/dist/cjs/with-wizard-screen/index.js +28 -38
- package/dist/cjs/with-wizard-screen/style.scss +75 -125
- package/dist/cjs/wizard/components/WizardError.js +74 -0
- package/dist/cjs/wizard/index.js +131 -0
- package/dist/cjs/wizard/store/index.js +165 -0
- package/dist/cjs/wizard/store/utils.js +26 -0
- package/dist/cjs/wizard/style.scss +148 -0
- package/dist/esm/accordion/index.js +38 -0
- package/dist/esm/accordion/style.scss +27 -0
- package/dist/esm/action-card/index.js +75 -37
- package/dist/esm/action-card/style.scss +143 -41
- package/dist/esm/autocomplete-tokenfield/index.js +14 -37
- package/dist/esm/autocomplete-tokenfield/style.scss +6 -6
- package/dist/esm/autocomplete-with-suggestions/index.js +31 -43
- package/dist/esm/autocomplete-with-suggestions/style.scss +27 -27
- package/dist/esm/button/index.js +2 -14
- package/dist/esm/button/style.scss +3 -344
- package/dist/esm/button-card/index.js +12 -11
- package/dist/esm/button-card/style.scss +65 -35
- package/dist/esm/card/index.js +5 -6
- package/dist/esm/card/style.scss +47 -63
- package/dist/esm/category-autocomplete/index.js +68 -41
- package/dist/esm/category-autocomplete/style.scss +20 -24
- package/dist/esm/color-picker/index.js +17 -38
- package/dist/esm/color-picker/style.scss +20 -163
- package/dist/esm/consts.js +3 -2
- package/dist/esm/custom-select-control/index.js +2 -5
- package/dist/esm/custom-select-control/style.scss +14 -45
- package/dist/esm/date-range-picker/index.js +1 -3
- package/dist/esm/date-range-picker/style.scss +12 -12
- package/dist/esm/footer/index.js +22 -16
- package/dist/esm/footer/style.scss +13 -14
- package/dist/esm/form-token-field/index.js +4 -7
- package/dist/esm/form-token-field/style.scss +9 -105
- package/dist/esm/global-notices/index.js +3 -7
- package/dist/esm/grid/index.js +2 -5
- package/dist/esm/grid/style.scss +19 -6
- package/dist/esm/handoff/index.js +10 -21
- package/dist/esm/handoff-message/index.js +45 -0
- package/dist/esm/hooks/index.js +0 -2
- package/dist/esm/hooks/useObjectState.js +3 -8
- package/dist/esm/hooks/useObjectState.test.js +0 -3
- package/dist/esm/hooks/useOnClickOutside.js +2 -5
- package/dist/esm/hooks/usePrompt.js +1 -8
- package/dist/esm/image-upload/index.js +18 -17
- package/dist/esm/image-upload/style.scss +12 -17
- package/dist/esm/index.js +7 -8
- package/dist/esm/info-button/index.js +4 -6
- package/dist/esm/info-button/style.scss +1 -3
- package/dist/esm/modal/index.js +2 -8
- package/dist/esm/modal/style.scss +20 -132
- package/dist/esm/newspack-icon/index.js +6 -7
- package/dist/esm/newspack-icon/style.scss +17 -2
- package/dist/esm/newspack-logo/index.js +2 -5
- package/dist/esm/newspack-logo/style.scss +3 -3
- package/dist/esm/notice/index.js +11 -10
- package/dist/esm/notice/style.scss +60 -19
- package/dist/esm/patrons-logo/index.js +3 -5
- package/dist/esm/plugin-installer/index.js +37 -40
- package/dist/esm/plugin-installer/style.scss +5 -5
- package/dist/esm/plugin-settings/SettingsSection.js +71 -56
- package/dist/esm/plugin-settings/index.js +70 -52
- package/dist/esm/plugin-settings/style.scss +7 -0
- package/dist/esm/plugin-toggle/index.js +59 -34
- package/dist/esm/plugin-toggle/style.scss +2 -2
- package/dist/esm/popover/index.js +3 -6
- package/dist/esm/popover/style.scss +20 -17
- package/dist/esm/position-control/index.js +109 -0
- package/dist/esm/position-control/style.scss +66 -0
- package/dist/esm/progress-bar/index.js +2 -7
- package/dist/esm/progress-bar/index.test.js +2 -1
- package/dist/esm/progress-bar/style.scss +4 -4
- package/dist/esm/proxied-imports/router.js +1 -0
- package/dist/esm/radio-control/index.js +3 -6
- package/dist/esm/radio-control/style.scss +10 -11
- package/dist/esm/section-header/index.js +47 -16
- package/dist/esm/section-header/style.scss +22 -1
- package/dist/esm/select-control/ButtonGroupControl.js +12 -14
- package/dist/esm/select-control/GroupedSelectControl.js +38 -36
- package/dist/esm/select-control/index.js +7 -8
- package/dist/esm/select-control/style.scss +47 -88
- package/dist/esm/settings/MinMaxSetting.js +4 -5
- package/dist/esm/settings/SettingsCard.js +9 -5
- package/dist/esm/settings/SettingsSection.js +5 -7
- package/dist/esm/settings/style.scss +32 -4
- package/dist/esm/steps-list/index.js +43 -0
- package/dist/esm/steps-list/style.scss +11 -0
- package/dist/esm/steps-list-item/index.js +48 -0
- package/dist/esm/steps-list-item/style.scss +47 -0
- package/dist/esm/style-card/index.js +13 -13
- package/dist/esm/style-card/style.scss +19 -18
- package/dist/esm/style.scss +43 -0
- package/dist/esm/tabbed-navigation/index.js +30 -28
- package/dist/esm/tabbed-navigation/style.scss +58 -37
- package/dist/esm/text-control/index.js +2 -12
- package/dist/esm/text-control/style.scss +0 -126
- package/dist/esm/utils/index.js +9 -3
- package/dist/esm/waiting/index.js +11 -27
- package/dist/esm/waiting/style.scss +9 -20
- package/dist/esm/web-preview/index.js +21 -49
- package/dist/esm/web-preview/style.scss +41 -34
- package/dist/esm/with-wizard/index.js +53 -36
- package/dist/esm/with-wizard/style.scss +77 -124
- package/dist/esm/with-wizard-screen/index.js +26 -32
- package/dist/esm/with-wizard-screen/style.scss +75 -125
- package/dist/esm/wizard/components/WizardError.js +69 -0
- package/dist/esm/wizard/index.js +126 -0
- package/dist/esm/wizard/store/index.js +155 -0
- package/dist/esm/wizard/store/utils.js +17 -0
- package/dist/esm/wizard/style.scss +148 -0
- package/package.json +4 -4
- package/src/accordion/index.js +32 -0
- package/src/accordion/style.scss +27 -0
- package/src/action-card/index.js +70 -25
- package/src/action-card/style.scss +143 -41
- package/src/autocomplete-tokenfield/index.js +1 -1
- package/src/autocomplete-tokenfield/style.scss +6 -6
- package/src/autocomplete-with-suggestions/index.js +4 -2
- package/src/autocomplete-with-suggestions/style.scss +27 -27
- package/src/button/index.js +2 -9
- package/src/button/style.scss +3 -344
- package/src/button-card/index.js +19 -5
- package/src/button-card/style.scss +65 -35
- package/src/card/index.js +4 -0
- package/src/card/style.scss +47 -63
- package/src/category-autocomplete/index.js +53 -18
- package/src/category-autocomplete/style.scss +20 -24
- package/src/color-picker/index.js +16 -22
- package/src/color-picker/style.scss +20 -163
- package/src/consts.js +2 -1
- package/src/custom-select-control/style.scss +14 -45
- package/src/date-range-picker/style.scss +12 -12
- package/src/footer/index.js +20 -9
- package/src/footer/style.scss +13 -14
- package/src/form-token-field/index.js +3 -8
- package/src/form-token-field/style.scss +9 -105
- package/src/global-notices/index.js +1 -1
- package/src/grid/style.scss +19 -6
- package/src/handoff/index.js +10 -15
- package/src/handoff-message/index.js +39 -0
- package/src/hooks/useObjectState.js +2 -1
- package/src/image-upload/index.js +9 -3
- package/src/image-upload/style.scss +12 -17
- package/src/index.js +7 -7
- package/src/info-button/style.scss +1 -3
- package/src/modal/index.js +2 -5
- package/src/modal/style.scss +20 -132
- package/src/newspack-icon/index.js +7 -2
- package/src/newspack-icon/style.scss +17 -2
- package/src/newspack-logo/style.scss +3 -3
- package/src/notice/index.js +9 -1
- package/src/notice/style.scss +60 -19
- package/src/plugin-installer/index.js +17 -4
- package/src/plugin-installer/style.scss +5 -5
- package/src/plugin-settings/SettingsSection.js +59 -27
- package/src/plugin-settings/index.js +29 -8
- package/src/plugin-settings/style.scss +7 -0
- package/src/plugin-toggle/index.js +37 -12
- package/src/plugin-toggle/style.scss +2 -2
- package/src/popover/style.scss +20 -17
- package/src/position-control/index.js +122 -0
- package/src/position-control/style.scss +66 -0
- package/src/progress-bar/style.scss +4 -4
- package/src/radio-control/style.scss +10 -11
- package/src/section-header/index.js +41 -5
- package/src/section-header/style.scss +22 -1
- package/src/select-control/ButtonGroupControl.js +15 -5
- package/src/select-control/GroupedSelectControl.js +28 -25
- package/src/select-control/index.js +6 -3
- package/src/select-control/style.scss +47 -88
- package/src/settings/MinMaxSetting.js +2 -1
- package/src/settings/SettingsCard.js +9 -7
- package/src/settings/SettingsSection.js +4 -4
- package/src/settings/style.scss +32 -4
- package/src/steps-list/index.js +39 -0
- package/src/steps-list/style.scss +11 -0
- package/src/steps-list-item/index.js +40 -0
- package/src/steps-list-item/style.scss +47 -0
- package/src/style-card/index.js +16 -27
- package/src/style-card/style.scss +19 -18
- package/src/style.scss +43 -0
- package/src/tabbed-navigation/index.js +20 -24
- package/src/tabbed-navigation/style.scss +58 -37
- package/src/text-control/index.js +1 -2
- package/src/text-control/style.scss +0 -126
- package/src/utils/index.js +9 -0
- package/src/waiting/index.js +7 -18
- package/src/waiting/style.scss +9 -20
- package/src/web-preview/index.js +13 -34
- package/src/web-preview/style.scss +41 -34
- package/src/with-wizard/index.js +7 -5
- package/src/with-wizard/style.scss +77 -124
- package/src/with-wizard-screen/index.js +17 -17
- package/src/with-wizard-screen/style.scss +75 -125
- package/src/wizard/components/WizardError.js +57 -0
- package/src/wizard/index.js +145 -0
- package/src/wizard/store/index.js +132 -0
- package/src/wizard/store/utils.js +16 -0
- package/dist/cjs/wizard-pagination/index.js +0 -71
- package/dist/cjs/wizard-pagination/style.scss +0 -74
- package/dist/esm/wizard-pagination/index.js +0 -57
- package/dist/esm/wizard-pagination/style.scss +0 -74
- package/src/button-group/index.js +0 -35
- package/src/button-group/style.scss +0 -73
- package/src/checkbox-control/index.js +0 -38
- package/src/checkbox-control/style.scss +0 -78
- package/src/preview-box/index.js +0 -18
- package/src/preview-box/style.scss +0 -18
- package/src/textarea-control/index.js +0 -32
- package/src/textarea-control/style.scss +0 -76
- package/src/toggle-control/index.js +0 -38
- package/src/toggle-control/style.scss +0 -74
- package/src/toggle-group/index.js +0 -43
- package/src/toggle-group/style.scss +0 -28
- package/src/wizard-pagination/index.js +0 -59
- package/src/wizard-pagination/style.scss +0 -74
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* External dependencies
|
|
5
4
|
*/
|
|
6
5
|
import classnames from 'classnames';
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
import apiFetch from '@wordpress/api-fetch';
|
|
12
11
|
import { Component, Fragment } from '@wordpress/element';
|
|
13
12
|
import { __ as alias__ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
17
|
const __ = alias__;
|
|
19
18
|
import { SectionHeader, Notice } from '../';
|
|
20
19
|
import SettingsSection from './SettingsSection';
|
|
21
20
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
22
21
|
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
23
|
-
|
|
24
22
|
class PluginSettings extends Component {
|
|
25
23
|
constructor() {
|
|
26
24
|
super(...arguments);
|
|
27
|
-
|
|
28
25
|
_defineProperty(this, "fetchSettings", () => {
|
|
29
26
|
const {
|
|
30
|
-
|
|
27
|
+
afterFetch,
|
|
28
|
+
pluginSlug,
|
|
29
|
+
isWizard
|
|
31
30
|
} = this.props;
|
|
32
31
|
this.setState({
|
|
33
32
|
inFlight: true
|
|
34
33
|
});
|
|
35
34
|
apiFetch({
|
|
36
|
-
path: `/${pluginSlug}/v1/settings`
|
|
35
|
+
path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`
|
|
37
36
|
}).then(settings => {
|
|
38
37
|
this.setState({
|
|
39
38
|
settings,
|
|
40
39
|
error: null
|
|
41
40
|
});
|
|
41
|
+
if ('function' === typeof afterFetch) {
|
|
42
|
+
afterFetch(settings);
|
|
43
|
+
}
|
|
42
44
|
}).catch(error => {
|
|
43
45
|
this.setState({
|
|
44
46
|
error
|
|
@@ -49,16 +51,12 @@ class PluginSettings extends Component {
|
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
53
|
});
|
|
52
|
-
|
|
53
54
|
_defineProperty(this, "getSettingsValues", sectionKey => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return ((_this$state$settings$ = this.state.settings[sectionKey]) === null || _this$state$settings$ === void 0 ? void 0 : _this$state$settings$.reduce((map, setting) => {
|
|
55
|
+
return this.state.settings[sectionKey]?.reduce((map, setting) => {
|
|
57
56
|
map[setting.key] = setting.value;
|
|
58
57
|
return map;
|
|
59
|
-
}, {})
|
|
58
|
+
}, {}) || {};
|
|
60
59
|
});
|
|
61
|
-
|
|
62
60
|
_defineProperty(this, "handleSettingChange", sectionKey => (key, value) => {
|
|
63
61
|
const sectionSettings = [...this.state.settings[sectionKey]];
|
|
64
62
|
sectionSettings.forEach(setting => {
|
|
@@ -67,21 +65,23 @@ class PluginSettings extends Component {
|
|
|
67
65
|
}
|
|
68
66
|
});
|
|
69
67
|
this.setState({
|
|
70
|
-
settings: {
|
|
68
|
+
settings: {
|
|
69
|
+
...this.state.settings,
|
|
71
70
|
[sectionKey]: sectionSettings
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
73
|
});
|
|
75
|
-
|
|
76
74
|
_defineProperty(this, "handleSectionUpdate", sectionKey => data => {
|
|
77
75
|
const {
|
|
78
|
-
|
|
76
|
+
afterUpdate,
|
|
77
|
+
pluginSlug,
|
|
78
|
+
isWizard
|
|
79
79
|
} = this.props;
|
|
80
80
|
this.setState({
|
|
81
81
|
inFlight: true
|
|
82
82
|
});
|
|
83
83
|
apiFetch({
|
|
84
|
-
path: `/${pluginSlug}/v1/settings`,
|
|
84
|
+
path: isWizard ? `/newspack/v1/wizard/${pluginSlug}/settings` : `/${pluginSlug}/v1/settings`,
|
|
85
85
|
method: 'POST',
|
|
86
86
|
data: {
|
|
87
87
|
section: sectionKey,
|
|
@@ -89,9 +89,15 @@ class PluginSettings extends Component {
|
|
|
89
89
|
}
|
|
90
90
|
}).then(settings => {
|
|
91
91
|
this.setState({
|
|
92
|
-
settings
|
|
92
|
+
settings: {
|
|
93
|
+
...this.state.settings,
|
|
94
|
+
[sectionKey]: settings[sectionKey]
|
|
95
|
+
},
|
|
93
96
|
error: null
|
|
94
97
|
});
|
|
98
|
+
if ('function' === typeof afterUpdate) {
|
|
99
|
+
afterUpdate(settings);
|
|
100
|
+
}
|
|
95
101
|
}).catch(error => {
|
|
96
102
|
this.setState({
|
|
97
103
|
error
|
|
@@ -102,64 +108,76 @@ class PluginSettings extends Component {
|
|
|
102
108
|
});
|
|
103
109
|
});
|
|
104
110
|
});
|
|
105
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Get the section setting containing section information.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} sectionKey The section name.
|
|
115
|
+
* @return {Object} The section setting.
|
|
116
|
+
*/
|
|
106
117
|
_defineProperty(this, "getSectionInfo", sectionKey => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return (_this$state$settings$2 = this.state.settings[sectionKey]) === null || _this$state$settings$2 === void 0 ? void 0 : _this$state$settings$2.find(setting => !setting.key || setting.key === 'active');
|
|
118
|
+
return this.state.settings[sectionKey]?.find(setting => !setting.key || setting.key === 'active');
|
|
110
119
|
});
|
|
111
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Get the section title.
|
|
122
|
+
*
|
|
123
|
+
* @param {string} sectionKey The section name.
|
|
124
|
+
* @return {string} The section title.
|
|
125
|
+
*/
|
|
112
126
|
_defineProperty(this, "getSectionTitle", sectionKey => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return (_this$getSectionInfo = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo === void 0 ? void 0 : _this$getSectionInfo.description;
|
|
127
|
+
return this.getSectionInfo(sectionKey)?.description;
|
|
116
128
|
});
|
|
117
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Get the section description.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} sectionKey The section name.
|
|
133
|
+
* @return {string} The section description.
|
|
134
|
+
*/
|
|
118
135
|
_defineProperty(this, "getSectionDescription", sectionKey => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return (_this$getSectionInfo2 = this.getSectionInfo(sectionKey)) === null || _this$getSectionInfo2 === void 0 ? void 0 : _this$getSectionInfo2.help;
|
|
136
|
+
return this.getSectionInfo(sectionKey)?.help;
|
|
122
137
|
});
|
|
123
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Get whether a section is active.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} sectionKey The section name.
|
|
142
|
+
* @return {?boolean} Whether the section is active or not. Null if the section is not found or does not support activation.
|
|
143
|
+
*/
|
|
124
144
|
_defineProperty(this, "isSectionActive", sectionKey => {
|
|
125
|
-
var _settings$sectionKey;
|
|
126
|
-
|
|
127
145
|
const {
|
|
128
146
|
settings
|
|
129
147
|
} = this.state;
|
|
130
|
-
const activation =
|
|
131
|
-
|
|
148
|
+
const activation = settings[sectionKey]?.find(setting => setting.key === 'active');
|
|
132
149
|
if (!activation) {
|
|
133
150
|
return null;
|
|
134
151
|
}
|
|
135
|
-
|
|
136
152
|
return activation.value;
|
|
137
153
|
});
|
|
138
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Get list of section field settings.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} sectionKey The section name.
|
|
158
|
+
* @return {?Array} List of section fields.
|
|
159
|
+
*/
|
|
139
160
|
_defineProperty(this, "getSectionFields", sectionKey => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return (_this$state$settings$3 = this.state.settings[sectionKey]) === null || _this$state$settings$3 === void 0 ? void 0 : _this$state$settings$3.filter(setting => setting.key && setting.key !== 'active');
|
|
161
|
+
return this.state.settings[sectionKey]?.filter(setting => setting.key && setting.key !== 'active');
|
|
143
162
|
});
|
|
144
|
-
|
|
145
163
|
this.state = {
|
|
146
164
|
inFlight: false,
|
|
147
165
|
settings: {},
|
|
148
166
|
error: null
|
|
149
167
|
};
|
|
150
168
|
}
|
|
151
|
-
|
|
152
169
|
componentDidMount() {
|
|
153
170
|
this.fetchSettings();
|
|
154
171
|
}
|
|
155
|
-
|
|
156
172
|
/**
|
|
157
173
|
* Render.
|
|
158
174
|
*/
|
|
159
175
|
render() {
|
|
160
176
|
const {
|
|
161
177
|
title,
|
|
162
|
-
description
|
|
178
|
+
description,
|
|
179
|
+
hasGreyHeader,
|
|
180
|
+
children
|
|
163
181
|
} = this.props;
|
|
164
182
|
const {
|
|
165
183
|
settings,
|
|
@@ -167,31 +185,31 @@ class PluginSettings extends Component {
|
|
|
167
185
|
error
|
|
168
186
|
} = this.state;
|
|
169
187
|
return _jsxs(Fragment, {
|
|
170
|
-
children: [_jsx(SectionHeader, {
|
|
188
|
+
children: [title && _jsx(SectionHeader, {
|
|
171
189
|
title: title,
|
|
172
190
|
description: description
|
|
173
191
|
}), error && _jsx(Notice, {
|
|
174
192
|
isError: true,
|
|
175
193
|
noticeText: error.message
|
|
176
|
-
}),
|
|
177
|
-
className: classnames({
|
|
194
|
+
}), _jsxs("div", {
|
|
195
|
+
className: classnames('newspack-plugin-settings', {
|
|
178
196
|
'newspack-wizard-section__is-loading': inFlight && !Object.keys(settings).length
|
|
179
197
|
}),
|
|
180
|
-
children: Object.keys(settings).map(sectionKey => _jsx(SettingsSection, {
|
|
198
|
+
children: [Object.keys(settings).map(sectionKey => _jsx(SettingsSection, {
|
|
181
199
|
disabled: inFlight,
|
|
200
|
+
sectionKey: sectionKey,
|
|
182
201
|
title: this.getSectionTitle(sectionKey),
|
|
183
202
|
description: this.getSectionDescription(sectionKey),
|
|
184
203
|
active: this.isSectionActive(sectionKey),
|
|
185
204
|
fields: this.getSectionFields(sectionKey),
|
|
186
205
|
onChange: this.handleSettingChange(sectionKey),
|
|
187
|
-
onUpdate: this.handleSectionUpdate(sectionKey)
|
|
188
|
-
|
|
206
|
+
onUpdate: this.handleSectionUpdate(sectionKey),
|
|
207
|
+
hasGreyHeader: hasGreyHeader
|
|
208
|
+
}, sectionKey)), children]
|
|
189
209
|
})]
|
|
190
210
|
});
|
|
191
211
|
}
|
|
192
|
-
|
|
193
212
|
}
|
|
194
|
-
|
|
195
213
|
PluginSettings.defaultProps = {
|
|
196
214
|
title: __('General Settings', 'newspack')
|
|
197
215
|
};
|
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* WordPress dependencies.
|
|
5
4
|
*/
|
|
6
5
|
import apiFetch from '@wordpress/api-fetch';
|
|
7
6
|
import { Component, Fragment } from '@wordpress/element';
|
|
8
7
|
import { __ as alias__ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
12
|
const __ = alias__;
|
|
14
13
|
import { ActionCard, Waiting } from '../';
|
|
15
14
|
import './style.scss';
|
|
15
|
+
|
|
16
16
|
/**
|
|
17
17
|
* Plugin toggle group component.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
20
|
import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
22
|
-
|
|
23
21
|
class PluginToggle extends Component {
|
|
24
22
|
constructor() {
|
|
25
23
|
super(...arguments);
|
|
26
|
-
|
|
27
24
|
_defineProperty(this, "state", {
|
|
28
25
|
pluginInfo: {}
|
|
29
26
|
});
|
|
30
|
-
|
|
31
27
|
_defineProperty(this, "componentDidMount", () => {
|
|
32
28
|
this.retrievePluginInfo();
|
|
33
29
|
});
|
|
34
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve complete data about Newspack plugins.
|
|
32
|
+
*/
|
|
35
33
|
_defineProperty(this, "retrievePluginInfo", () => {
|
|
36
34
|
return new Promise(() => {
|
|
37
35
|
apiFetch({
|
|
@@ -41,7 +39,9 @@ class PluginToggle extends Component {
|
|
|
41
39
|
}));
|
|
42
40
|
});
|
|
43
41
|
});
|
|
44
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Install/activate or remove a plugin.
|
|
44
|
+
*/
|
|
45
45
|
_defineProperty(this, "managePlugin", (plugin, value) => {
|
|
46
46
|
const {
|
|
47
47
|
plugins
|
|
@@ -55,8 +55,10 @@ class PluginToggle extends Component {
|
|
|
55
55
|
method: 'post'
|
|
56
56
|
};
|
|
57
57
|
this.setState({
|
|
58
|
-
pluginInfo: {
|
|
59
|
-
|
|
58
|
+
pluginInfo: {
|
|
59
|
+
...pluginInfo,
|
|
60
|
+
[plugin]: {
|
|
61
|
+
...pluginInfo[plugin],
|
|
60
62
|
inFlight: action
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -70,34 +72,50 @@ class PluginToggle extends Component {
|
|
|
70
72
|
pluginInfo: currentPluginInfo
|
|
71
73
|
} = _ref;
|
|
72
74
|
return {
|
|
73
|
-
pluginInfo: {
|
|
75
|
+
pluginInfo: {
|
|
76
|
+
...currentPluginInfo,
|
|
74
77
|
[plugin]: response
|
|
75
78
|
}
|
|
76
79
|
};
|
|
77
80
|
}, () => shouldRefreshAfterUpdate && location.reload());
|
|
81
|
+
}).catch(e => {
|
|
82
|
+
this.setState({
|
|
83
|
+
pluginInfo: {
|
|
84
|
+
...pluginInfo,
|
|
85
|
+
[plugin]: {
|
|
86
|
+
...pluginInfo[plugin],
|
|
87
|
+
error: e.message || __('There was an error managing this plugin.', 'newspack')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
78
91
|
});
|
|
79
92
|
});
|
|
80
93
|
});
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Prepare plugins data for render. Change all keys to camelCase, merge API-fetched data with prop.
|
|
96
|
+
*/
|
|
97
|
+
_defineProperty(this, "prepareDataForRender", (pluginsFromProps, pluginsFromAPI) => Object.keys(pluginsFromProps).map(pluginSlug => pluginsFromAPI[pluginSlug] ? Object.keys(pluginsFromAPI[pluginSlug]).reduce((accumulator, key) => ({
|
|
98
|
+
...accumulator,
|
|
83
99
|
[key.charAt(0).toLowerCase() + key.slice(1)]: pluginsFromAPI[pluginSlug][key]
|
|
84
100
|
}), {}) : {}).map(plugin => Object.assign(plugin, pluginsFromProps[plugin.slug])));
|
|
85
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Generate a classname for the ActionCard based on plugin state. Applies 'in-flight' class if an API is underway and 'loading' if the plugin data is not yet available.
|
|
103
|
+
*/
|
|
86
104
|
_defineProperty(this, "classNameForPlugin", plugin => {
|
|
87
105
|
const {
|
|
88
106
|
status,
|
|
89
107
|
inFlight
|
|
90
108
|
} = plugin;
|
|
91
|
-
|
|
92
109
|
if (inFlight) {
|
|
93
110
|
return 'in-flight';
|
|
94
111
|
}
|
|
95
|
-
|
|
96
112
|
if (!status) {
|
|
97
113
|
return 'loading';
|
|
98
114
|
}
|
|
99
115
|
});
|
|
100
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Generate the ActionCard action text for a plugin.
|
|
118
|
+
*/
|
|
101
119
|
_defineProperty(this, "actionTextForPlugin", plugin => {
|
|
102
120
|
const {
|
|
103
121
|
actionText,
|
|
@@ -105,8 +123,8 @@ class PluginToggle extends Component {
|
|
|
105
123
|
href,
|
|
106
124
|
inFlight,
|
|
107
125
|
name
|
|
108
|
-
} = plugin;
|
|
109
|
-
|
|
126
|
+
} = plugin;
|
|
127
|
+
// Show spinner when plugin data is unavailable, or when an API call is in flight.
|
|
110
128
|
if ('configure' === inFlight) {
|
|
111
129
|
return _jsxs(Fragment, {
|
|
112
130
|
children: [__('Installing…', 'newspack'), " ", _jsx(Waiting, {
|
|
@@ -114,7 +132,6 @@ class PluginToggle extends Component {
|
|
|
114
132
|
})]
|
|
115
133
|
});
|
|
116
134
|
}
|
|
117
|
-
|
|
118
135
|
if ('deactivate' === inFlight) {
|
|
119
136
|
return _jsxs(Fragment, {
|
|
120
137
|
children: [__('Deactivating…', 'newspack'), " ", _jsx(Waiting, {
|
|
@@ -122,25 +139,36 @@ class PluginToggle extends Component {
|
|
|
122
139
|
})]
|
|
123
140
|
});
|
|
124
141
|
}
|
|
125
|
-
|
|
126
142
|
if (!name) {
|
|
127
143
|
return _jsxs(Fragment, {
|
|
128
144
|
children: [__('Loading…', 'newspack'), " ", _jsx(Waiting, {
|
|
129
145
|
isRight: true
|
|
130
146
|
})]
|
|
131
147
|
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
148
|
+
}
|
|
149
|
+
// No action button at all if the plugin isn't installed and active.
|
|
135
150
|
if (!this.isPluginInstalledAndActive(plugin)) {
|
|
136
151
|
return null;
|
|
137
152
|
}
|
|
138
|
-
|
|
139
153
|
if (href || editPath) {
|
|
140
154
|
return actionText ? actionText : __('Configure', 'newspack');
|
|
141
155
|
}
|
|
142
156
|
});
|
|
143
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Get error message for this plugin.
|
|
159
|
+
*/
|
|
160
|
+
_defineProperty(this, "errorForPlugin", plugin => {
|
|
161
|
+
const {
|
|
162
|
+
slug
|
|
163
|
+
} = plugin;
|
|
164
|
+
const {
|
|
165
|
+
pluginInfo
|
|
166
|
+
} = this.state;
|
|
167
|
+
return pluginInfo[slug]?.error || null;
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* Get installation/activation status for a plugin.
|
|
171
|
+
*/
|
|
144
172
|
_defineProperty(this, "isPluginInstalledAndActive", plugin => {
|
|
145
173
|
const {
|
|
146
174
|
status
|
|
@@ -148,7 +176,6 @@ class PluginToggle extends Component {
|
|
|
148
176
|
return status === 'active';
|
|
149
177
|
});
|
|
150
178
|
}
|
|
151
|
-
|
|
152
179
|
/**
|
|
153
180
|
* Render.
|
|
154
181
|
*/
|
|
@@ -169,6 +196,7 @@ class PluginToggle extends Component {
|
|
|
169
196
|
} = plugin;
|
|
170
197
|
const pluginStatus = this.isPluginInstalledAndActive(plugin);
|
|
171
198
|
const handoff = !href && pluginStatus && editPath ? slug : null;
|
|
199
|
+
const error = this.errorForPlugin(plugin);
|
|
172
200
|
return _jsx(ActionCard, {
|
|
173
201
|
className: this.classNameForPlugin(plugin),
|
|
174
202
|
title: name,
|
|
@@ -178,15 +206,12 @@ class PluginToggle extends Component {
|
|
|
178
206
|
href: href,
|
|
179
207
|
toggle: true,
|
|
180
208
|
toggleChecked: this.isPluginInstalledAndActive(plugin),
|
|
181
|
-
toggleOnChange: value => this.managePlugin(slug, value)
|
|
209
|
+
toggleOnChange: value => this.managePlugin(slug, value),
|
|
210
|
+
notification: error,
|
|
211
|
+
notificationHTML: error,
|
|
212
|
+
notificationLevel: "error"
|
|
182
213
|
}, index);
|
|
183
214
|
});
|
|
184
215
|
}
|
|
185
|
-
/**
|
|
186
|
-
* Prepare plugins data for render. Change all keys to camelCase, merge API-fetched data with prop.
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
216
|
}
|
|
191
|
-
|
|
192
217
|
export default PluginToggle;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Plugin Toggle
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@
|
|
5
|
+
@use '~@wordpress/base-styles/colors' as wp-colors;
|
|
6
6
|
|
|
7
7
|
.newspack-action-card {
|
|
8
8
|
&.in-flight,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
.newspack-action-card__region-right {
|
|
13
13
|
.newspack-button {
|
|
14
|
-
color:
|
|
14
|
+
color: wp-colors.$gray-700;
|
|
15
15
|
pointer-events: none;
|
|
16
16
|
text-decoration: none;
|
|
17
17
|
}
|
|
@@ -3,22 +3,21 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Popover as BaseComponent } from '@wordpress/components';
|
|
5
5
|
import { Component } from '@wordpress/element';
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
10
|
import './style.scss';
|
|
11
|
+
|
|
11
12
|
/**
|
|
12
13
|
* External dependencies
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
import classnames from 'classnames';
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* Popover
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
20
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
21
|
-
|
|
22
21
|
class Popover extends Component {
|
|
23
22
|
/**
|
|
24
23
|
* Render
|
|
@@ -35,9 +34,7 @@ class Popover extends Component {
|
|
|
35
34
|
...otherProps
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
Popover.defaultProps = {
|
|
42
39
|
padding: false
|
|
43
40
|
};
|
|
@@ -2,48 +2,47 @@
|
|
|
2
2
|
* Popover
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
@
|
|
6
|
-
@
|
|
5
|
+
@use '../../../shared/scss/colors';
|
|
6
|
+
@use '~@wordpress/base-styles/colors' as wp-colors;
|
|
7
7
|
|
|
8
8
|
.newspack-popover {
|
|
9
9
|
.components-popover__content {
|
|
10
|
-
border: 1px solid $gray-300;
|
|
11
|
-
border-radius: 3px;
|
|
12
|
-
box-shadow: 0 4px 8px rgba( black, 0.08 );
|
|
13
10
|
min-width: 238px;
|
|
14
11
|
|
|
15
12
|
.newspack-button {
|
|
16
|
-
color:
|
|
13
|
+
color: wp-colors.$gray-700;
|
|
17
14
|
display: flex;
|
|
18
15
|
font-weight: normal;
|
|
19
16
|
padding: 6px 8px;
|
|
20
17
|
|
|
21
18
|
&:hover {
|
|
19
|
+
color: colors.$primary-500;
|
|
20
|
+
|
|
22
21
|
.components-menu-items__item-icon {
|
|
23
|
-
fill:
|
|
22
|
+
fill: currentcolor;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
&:focus:not( :disabled ) {
|
|
28
|
-
box-shadow: inset 0 0 0 2px
|
|
27
|
+
box-shadow: inset 0 0 0 2px colors.$primary-500;
|
|
29
28
|
position: relative;
|
|
30
29
|
z-index: 1;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
&.is-link {
|
|
34
|
-
border-radius:
|
|
33
|
+
border-radius: 2px;
|
|
35
34
|
padding: 6px 8px;
|
|
36
35
|
text-decoration: none;
|
|
37
36
|
|
|
38
37
|
&:not( .is-destructive ) {
|
|
39
|
-
color:
|
|
38
|
+
color: wp-colors.$gray-700;
|
|
40
39
|
|
|
41
40
|
&:active,
|
|
42
41
|
&:active:enabled,
|
|
43
42
|
&:focus,
|
|
44
43
|
&:focus:enabled &:hover,
|
|
45
|
-
&:not( :disabled
|
|
46
|
-
color:
|
|
44
|
+
&:not( :disabled, [aria-disabled='true'], .is-default ):hover {
|
|
45
|
+
color: colors.$primary-500;
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -53,8 +52,12 @@
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
&.is-destructive:not( :focus ) {
|
|
56
|
+
box-shadow: none !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
56
59
|
.components-menu-items__item-icon {
|
|
57
|
-
fill:
|
|
60
|
+
fill: wp-colors.$gray-900;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
.components-menu-item__item {
|
|
@@ -64,7 +67,7 @@
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
.components-menu-group__label {
|
|
67
|
-
color:
|
|
70
|
+
color: wp-colors.$gray-900;
|
|
68
71
|
font-size: 12px;
|
|
69
72
|
font-weight: bold;
|
|
70
73
|
line-height: 16px;
|
|
@@ -86,8 +89,8 @@
|
|
|
86
89
|
min-height: 36px;
|
|
87
90
|
|
|
88
91
|
&:focus ~ div.components-input-control__backdrop {
|
|
89
|
-
border-color:
|
|
90
|
-
box-shadow: inset 0 0 0 1px
|
|
92
|
+
border-color: colors.$primary-500;
|
|
93
|
+
box-shadow: inset 0 0 0 1px colors.$primary-500;
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -129,7 +132,7 @@
|
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
&:not( .is-without-arrow )::before {
|
|
132
|
-
border-color:
|
|
135
|
+
border-color: wp-colors.$gray-300;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
&.is-from-bottom {
|