| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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,
- };
- this.switchLayoutType = this.switchLayoutType.bind(this);
- }
- /**
- * 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 });
- }
- /**
- * 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 { customizeParams } = response.data;
- return customizeParams;
- }
- }
|