2
0
Эх сурвалжийг харах

improve the way to switch isRomUserAllowedToComment

WNomunomu 1 жил өмнө
parent
commit
7e746eedb8

+ 4 - 4
apps/app/src/client/components/Admin/Security/SecuritySetting.jsx

@@ -526,15 +526,15 @@ class SecuritySetting extends React.Component {
                 aria-expanded="true"
               >
                 <span className="float-start">
-                  {isRomUserAllowedToComment === true && t('security_settings.rom_users_comment.deny')}
-                  {isRomUserAllowedToComment === false && t('security_settings.rom_users_comment.accept')}
+                  {isRomUserAllowedToComment === true && t('security_settings.rom_users_comment.accept')}
+                  {isRomUserAllowedToComment === false && t('security_settings.rom_users_comment.deny')}
                 </span>
               </button>
               <div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
-                <button className="dropdown-item" type="button" onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment() }}>
+                <button className="dropdown-item" type="button" onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment(false) }}>
                   {t('security_settings.rom_users_comment.deny')}
                 </button>
-                <button className="dropdown-item" type="button" onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment() }}>
+                <button className="dropdown-item" type="button" onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment(true) }}>
                   {t('security_settings.rom_users_comment.accept')}
                 </button>
               </div>

+ 3 - 3
apps/app/src/client/services/AdminGeneralSecurityContainer.js

@@ -223,10 +223,10 @@ export default class AdminGeneralSecurityContainer extends Container {
   }
 
   /**
-   * Switch isForceDeleteUserHomepageOnUserDeletion
+   * switch isRomUserAllowedToComment
    */
-  switchIsRomUserAllowedToComment() {
-    this.setState({ isRomUserAllowedToComment: !this.state.isRomUserAllowedToComment });
+  switchIsRomUserAllowedToComment(bool) {
+    this.setState({ isRomUserAllowedToComment: bool });
   }
 
 

+ 1 - 1
apps/app/src/server/middlewares/exclude-read-only-user.ts

@@ -27,7 +27,7 @@ export const excludeReadOnlyUser = (req: Request, res: Response & { apiv3Err },
   return next();
 };
 
-const excludeReadOnlyUserWhenCommentNotAllowed = (req: Request, res: Response & { apiv3Err }, next: () => NextFunction): NextFunction => {
+export const excludeReadOnlyUserWhenCommentNotAllowed = (req: Request, res: Response & { apiv3Err }, next: () => NextFunction): NextFunction => {
   const user = req.user;
 
   const isRomUserAllowedToComment = configManager.getConfig('crowi', 'security:isRomUserAllowedToComment');