|
@@ -17,9 +17,12 @@ import EditorContainer from '~/client/services/EditorContainer';
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
import GrantSelector from './SavePageControls/GrantSelector';
|
|
import GrantSelector from './SavePageControls/GrantSelector';
|
|
|
|
|
|
|
|
|
|
+import { getOptionsToSave } from '~/client/util/editor';
|
|
|
|
|
+
|
|
|
// TODO: remove this when omitting unstated is completed
|
|
// TODO: remove this when omitting unstated is completed
|
|
|
import { useEditorMode } from '~/stores/ui';
|
|
import { useEditorMode } from '~/stores/ui';
|
|
|
-import { useIsEditable } from '~/stores/context';
|
|
|
|
|
|
|
+import { useIsEditable, useSlackChannels } from '~/stores/context';
|
|
|
|
|
+import { useIsSlackEnabled } from '~/stores/editor';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:SavePageControls');
|
|
const logger = loggerFactory('growi:SavePageControls');
|
|
|
|
|
|
|
@@ -43,13 +46,16 @@ class SavePageControls extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async save() {
|
|
async save() {
|
|
|
- const { pageContainer, editorContainer } = this.props;
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ isSlackEnabled, slackChannels, pageContainer, editorContainer,
|
|
|
|
|
+ } = this.props;
|
|
|
// disable unsaved warning
|
|
// disable unsaved warning
|
|
|
editorContainer.disableUnsavedWarning();
|
|
editorContainer.disableUnsavedWarning();
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// save
|
|
// save
|
|
|
- await pageContainer.saveAndReload(editorContainer.getCurrentOptionsToSave(), this.props.editorMode);
|
|
|
|
|
|
|
+ const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, editorContainer);
|
|
|
|
|
+ await pageContainer.saveAndReload(optionsToSave, this.props.editorMode);
|
|
|
}
|
|
}
|
|
|
catch (error) {
|
|
catch (error) {
|
|
|
logger.error('failed to save', error);
|
|
logger.error('failed to save', error);
|
|
@@ -58,11 +64,14 @@ class SavePageControls extends React.Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
saveAndOverwriteScopesOfDescendants() {
|
|
saveAndOverwriteScopesOfDescendants() {
|
|
|
- const { pageContainer, editorContainer } = this.props;
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ isSlackEnabled, slackChannels, pageContainer, editorContainer,
|
|
|
|
|
+ } = this.props;
|
|
|
// disable unsaved warning
|
|
// disable unsaved warning
|
|
|
editorContainer.disableUnsavedWarning();
|
|
editorContainer.disableUnsavedWarning();
|
|
|
// save
|
|
// save
|
|
|
- const optionsToSave = Object.assign(editorContainer.getCurrentOptionsToSave(), {
|
|
|
|
|
|
|
+ const currentOptionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, editorContainer);
|
|
|
|
|
+ const optionsToSave = Object.assign(currentOptionsToSave, {
|
|
|
overwriteScopesOfDescendants: true,
|
|
overwriteScopesOfDescendants: true,
|
|
|
});
|
|
});
|
|
|
pageContainer.saveAndReload(optionsToSave, this.props.editorMode);
|
|
pageContainer.saveAndReload(optionsToSave, this.props.editorMode);
|
|
@@ -117,6 +126,8 @@ const SavePageControlsHOCWrapper = withUnstatedContainers(SavePageControls, [App
|
|
|
const SavePageControlsWrapper = (props) => {
|
|
const SavePageControlsWrapper = (props) => {
|
|
|
const { data: isEditable } = useIsEditable();
|
|
const { data: isEditable } = useIsEditable();
|
|
|
const { data: editorMode } = useEditorMode();
|
|
const { data: editorMode } = useEditorMode();
|
|
|
|
|
+ const { data: isSlackEnabled } = useIsSlackEnabled();
|
|
|
|
|
+ const { data: slackChannels } = useSlackChannels();
|
|
|
|
|
|
|
|
if (isEditable == null || editorMode == null) {
|
|
if (isEditable == null || editorMode == null) {
|
|
|
return null;
|
|
return null;
|
|
@@ -126,7 +137,14 @@ const SavePageControlsWrapper = (props) => {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return <SavePageControlsHOCWrapper {...props} editorMode={editorMode} />;
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ <SavePageControlsHOCWrapper
|
|
|
|
|
+ {...props}
|
|
|
|
|
+ editorMode={editorMode}
|
|
|
|
|
+ isSlackEnabled={isSlackEnabled}
|
|
|
|
|
+ slackChannels={slackChannels}
|
|
|
|
|
+ />
|
|
|
|
|
+ );
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
SavePageControls.propTypes = {
|
|
SavePageControls.propTypes = {
|
|
@@ -138,6 +156,8 @@ SavePageControls.propTypes = {
|
|
|
|
|
|
|
|
// TODO: remove this when omitting unstated is completed
|
|
// TODO: remove this when omitting unstated is completed
|
|
|
editorMode: PropTypes.string.isRequired,
|
|
editorMode: PropTypes.string.isRequired,
|
|
|
|
|
+ isSlackEnabled: PropTypes.bool.isRequired,
|
|
|
|
|
+ slackChannels: PropTypes.string.isRequired,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default withTranslation()(SavePageControlsWrapper);
|
|
export default withTranslation()(SavePageControlsWrapper);
|