|
|
@@ -88,8 +88,9 @@ export default class AdminCustomizeContainer extends Container {
|
|
|
this.setState({ currentHighlightJsStyleName: this.state.highlightJsCssSelectorOptions[customizeParams.styleName].name });
|
|
|
}
|
|
|
catch (err) {
|
|
|
+ this.setState({ retrieveError: err });
|
|
|
logger.error(err);
|
|
|
- toastError(new Error('Failed to fetch data'));
|
|
|
+ throw new Error('Failed to fetch data');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -237,98 +238,153 @@ export default class AdminCustomizeContainer extends Container {
|
|
|
/**
|
|
|
* Update layout
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {Array} Appearance
|
|
|
*/
|
|
|
async updateCustomizeLayoutAndTheme() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/layout-theme', {
|
|
|
- layoutType: this.state.currentLayout,
|
|
|
- themeType: this.state.currentTheme,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/layout-theme', {
|
|
|
+ layoutType: this.state.currentLayout,
|
|
|
+ themeType: this.state.currentTheme,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ layoutType: customizedParams.layoutType,
|
|
|
+ themeType: customizedParams.themeType,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update behavior
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {string} Behavior
|
|
|
*/
|
|
|
async updateCustomizeBehavior() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/behavior', {
|
|
|
- behaviorType: this.state.currentBehavior,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/behavior', {
|
|
|
+ behaviorType: this.state.currentBehavior,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ behaviorType: customizedParams.behaviorType,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update function
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {string} Functions
|
|
|
*/
|
|
|
async updateCustomizeFunction() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/function', {
|
|
|
- isEnabledTimeline: this.state.isEnabledTimeline,
|
|
|
- isSavedStatesOfTabChanges: this.state.isSavedStatesOfTabChanges,
|
|
|
- isEnabledAttachTitleHeader: this.state.isEnabledAttachTitleHeader,
|
|
|
- recentCreatedLimit: this.state.currentRecentCreatedLimit,
|
|
|
- isEnabledStaleNotification: this.state.isEnabledStaleNotification,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/function', {
|
|
|
+ isEnabledTimeline: this.state.isEnabledTimeline,
|
|
|
+ isSavedStatesOfTabChanges: this.state.isSavedStatesOfTabChanges,
|
|
|
+ isEnabledAttachTitleHeader: this.state.isEnabledAttachTitleHeader,
|
|
|
+ recentCreatedLimit: this.state.currentRecentCreatedLimit,
|
|
|
+ isEnabledStaleNotification: this.state.isEnabledStaleNotification,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ isEnabledTimeline: customizedParams.isEnabledTimeline,
|
|
|
+ isSavedStatesOfTabChanges: customizedParams.isSavedStatesOfTabChanges,
|
|
|
+ isEnabledAttachTitleHeader: customizedParams.isEnabledAttachTitleHeader,
|
|
|
+ recentCreatedLimit: customizedParams.currentRecentCreatedLimit,
|
|
|
+ isEnabledStaleNotification: customizedParams.isEnabledStaleNotification,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update code highlight
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {Array} Code highlight
|
|
|
*/
|
|
|
async updateHighlightJsStyle() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/highlight', {
|
|
|
- highlightJsStyle: this.state.currentHighlightJsStyleId,
|
|
|
- highlightJsStyleBorder: this.state.isHighlightJsStyleBorderEnabled,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/highlight', {
|
|
|
+ highlightJsStyle: this.state.currentHighlightJsStyleId,
|
|
|
+ highlightJsStyleBorder: this.state.isHighlightJsStyleBorderEnabled,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ highlightJsStyle: customizedParams.highlightJsStyle,
|
|
|
+ highlightJsStyleBorder: customizedParams.highlightJsStyleBorder,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update customTitle
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {string} Customize title
|
|
|
*/
|
|
|
async updateCustomizeTitle() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/customize-title', {
|
|
|
- customizeTitle: this.state.currentCustomizeTitle,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/customize-title', {
|
|
|
+ customizeTitle: this.state.currentCustomizeTitle,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ customizeTitle: customizedParams.customizeTitle,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update customHeader
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {string} Customize html header
|
|
|
*/
|
|
|
async updateCustomizeHeader() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/customize-header', {
|
|
|
- customizeHeader: this.state.currentCustomizeHeader,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/customize-header', {
|
|
|
+ customizeHeader: this.state.currentCustomizeHeader,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ currentCustomizeHeader: customizedParams.customizeHeader,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Update customCss
|
|
|
* @memberOf AdminCustomizeContainer
|
|
|
- * @return {string} Customize css
|
|
|
*/
|
|
|
async updateCustomizeCss() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/customize-css', {
|
|
|
- customizeCss: this.state.currentCustomizeCss,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/customize-css', {
|
|
|
+ customizeCss: this.state.currentCustomizeCss,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ currentCustomizeCss: customizedParams.customizeCss,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -337,11 +393,19 @@ export default class AdminCustomizeContainer extends Container {
|
|
|
* @return {string} Customize scripts
|
|
|
*/
|
|
|
async updateCustomizeScript() {
|
|
|
- const response = await this.appContainer.apiv3.put('/customize-setting/customize-script', {
|
|
|
- customizeScript: this.state.currentCustomizeScript,
|
|
|
- });
|
|
|
- const { customizedParams } = response.data;
|
|
|
- return customizedParams;
|
|
|
+ try {
|
|
|
+ const response = await this.appContainer.apiv3.put('/customize-setting/customize-script', {
|
|
|
+ customizeScript: this.state.currentCustomizeScript,
|
|
|
+ });
|
|
|
+ const { customizedParams } = response.data;
|
|
|
+ this.setState({
|
|
|
+ currentCustomizeScript: customizedParams.customizeScript,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(err);
|
|
|
+ throw new Error('Failed to update data');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|