| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- import { Container } from 'unstated';
- /**
- * Service container for admin customize setting page (Customize.jsx)
- * @extends {Container} unstated Container
- */
- export default class AdminCustomizeContainer extends Container {
- constructor(appContainer) {
- super();
- this.appContainer = appContainer;
- this.state = {
- currentTheme: appContainer.config.themeType,
- currentLayout: appContainer.config.layoutType,
- currentBehavior: appContainer.config.behaviorType,
- isEnabledTimeline: appContainer.config.isEnabledTimeline,
- isSavedStatesOfTabChanges: appContainer.config.isSavedStatesOfTabChanges,
- isEnabledAttachTitleHeader: appContainer.config.isEnabledAttachTitleHeader,
- currentRecentCreatedLimit: appContainer.config.recentCreatedLimit,
- };
- }
- /**
- * Workaround for the mangling in production build to break constructor.name
- */
- static getClassName() {
- return 'AdminCustomizeContainer';
- }
- /**
- * Switch layoutType
- */
- switchLayoutType(lauoutName) {
- this.setState({ currentLayout: lauoutName });
- }
- /**
- * Switch themeType
- */
- switchThemeType(themeName) {
- // can't choose theme when kibela
- if (this.state.currentLayout === 'kibela') {
- return;
- }
- this.setState({ currentTheme: themeName });
- }
- /**
- * Switch behaviorType
- */
- switchBehaviorType(behaviorName) {
- this.setState({ currentBehavior: behaviorName });
- }
- /**
- * Switch enabledTimeLine
- */
- switchEnableTimeline() {
- this.setState({ isEnabledTimeline: !this.state.isEnabledTimeline });
- }
- /**
- * Switch savedStatesOfTabChanges
- */
- switchSavedStatesOfTabChanges() {
- this.setState({ isSavedStatesOfTabChanges: !this.state.isSavedStatesOfTabChanges });
- }
- /**
- * Switch enabledAttachTitleHeader
- */
- switchEnabledAttachTitleHeader() {
- this.setState({ isEnabledAttachTitleHeader: !this.state.isEnabledAttachTitleHeader });
- }
- /**
- * Switch recentCreatedLimit
- */
- switchRecentCreatedLimit(value) {
- this.setState({ currentRecentCreatedLimit: value });
- }
- /**
- * Update layout
- * @memberOf AdminCustomizeContainer
- * @return {Array} Appearance
- */
- async updateCustomizeLayoutAndTheme() {
- const response = await this.appContainer.apiv3.put('/customize-setting/layoutTheme', {
- layoutType: this.state.currentLayout,
- themeType: this.state.currentTheme,
- });
- const { customizedParams } = response.data;
- return customizedParams;
- }
- /**
- * 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;
- }
- /**
- * Update function
- * @memberOf AdminCustomizeContainer
- * @return {string} Functions
- */
- async updateCustomizeFunction() {
- // TODO GW-506 create apiV3
- }
- }
|