Просмотр исходного кода

mutateGrowiTheme when selecting growi theme

kaori 3 лет назад
Родитель
Сommit
bb49ad8051

+ 3 - 1
packages/app/src/components/Admin/Customize/Customize.jsx

@@ -55,7 +55,9 @@ function Customize(props) {
         <CustomizeThemeSetting />
         <CustomizeThemeSetting />
       </div>
       </div>
       <div className="mb-5">
       <div className="mb-5">
-        <CustomizeSidebarSetting />
+        {/* TODO: [resolve browser err] A component is changing an uncontrolled input to be controlled. by https://redmine.weseek.co.jp/issues/101155
+          <CustomizeSidebarSetting />
+        */}
       </div>
       </div>
       <div className="mb-5">
       <div className="mb-5">
         <CustomizeFunctionSetting />
         <CustomizeFunctionSetting />

+ 4 - 2
packages/app/src/components/Admin/Customize/CustomizeThemeOptions.jsx

@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
 
 
 import AdminCustomizeContainer from '~/client/services/AdminCustomizeContainer';
 import AdminCustomizeContainer from '~/client/services/AdminCustomizeContainer';
 import { GrowiThemes } from '~/interfaces/theme';
 import { GrowiThemes } from '~/interfaces/theme';
+import { useGrowiTheme } from '~/stores/context';
 
 
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 
 
@@ -51,6 +52,7 @@ const CustomizeThemeOptions = (props) => {
 
 
   const { adminCustomizeContainer } = props;
   const { adminCustomizeContainer } = props;
   const { t } = useTranslation();
   const { t } = useTranslation();
+  const { mutate: mutateGrowiTheme } = useGrowiTheme();
   const { currentLayout, currentTheme } = adminCustomizeContainer.state;
   const { currentLayout, currentTheme } = adminCustomizeContainer.state;
 
 
   return (
   return (
@@ -64,7 +66,7 @@ const CustomizeThemeOptions = (props) => {
               <ThemeColorBox
               <ThemeColorBox
                 key={theme.name}
                 key={theme.name}
                 isSelected={currentTheme === theme.name}
                 isSelected={currentTheme === theme.name}
-                onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
+                onSelected={() => mutateGrowiTheme(theme.name)}
                 {...theme}
                 {...theme}
               />
               />
             );
             );
@@ -80,7 +82,7 @@ const CustomizeThemeOptions = (props) => {
               <ThemeColorBox
               <ThemeColorBox
                 key={theme.name}
                 key={theme.name}
                 isSelected={currentTheme === theme.name}
                 isSelected={currentTheme === theme.name}
-                onSelected={() => adminCustomizeContainer.switchThemeType(theme.name)}
+                onSelected={() => mutateGrowiTheme(theme.name)}
                 {...theme}
                 {...theme}
               />
               />
             );
             );