harukatokutake 6 лет назад
Родитель
Сommit
0f2d6800e3

+ 3 - 18
src/client/js/components/Admin/Users/GiveAdminForm.jsx

@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
-import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 class AdminMenuForm extends React.Component {
 
@@ -18,25 +17,11 @@ class AdminMenuForm extends React.Component {
   }
 
   render() {
-    const { t, user } = this.props;
-    const me = this.props.appContainer.me;
+    const { t } = this.props;
 
     return (
-      <form onSubmit={this.handleSubmit}>
-        <div id="giveAdminForm" className="collapse">
-          <div className="form-group">
-            <label htmlFor="name">{ t('user_group_management.group_name') }</label>
-            <textarea
-              id="name"
-              name="name"
-              className="form-control"
-              placeholder={t('user_group_management.group_example')}
-              value={this.state.name}
-              onChange={this.handleChange}
-            >
-            </textarea>
-          </div>
-        </div>
+      <form className="px-4" action="/admin/user/{{ sUser._id.toString() }}/makeAdmin" method="post">
+        <i className="icon-fw icon-magic-wand"></i>{ t('user_management.give_admin_access') }
       </form>
     );
   }

+ 0 - 4
src/client/js/components/Admin/Users/PasswordResetModal.jsx

@@ -34,10 +34,6 @@ class PasswordResetModal extends React.Component {
 
     return (
       <div>
-        <div onClick={this.isShow}>
-          <i className="icon-fw icon-key"></i>
-          { t('user_management.reset_password') }
-        </div>
         <Modal show={this.state.isOpenModal} onHide={this.onHide}>
           <Modal.Header className="modal-header" closeButton>
             <Modal.Title>

+ 17 - 35
src/client/js/components/Admin/Users/RemoveAdminForm.jsx

@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
-import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 class AdminMenuForm extends React.Component {
 
@@ -22,47 +21,30 @@ class AdminMenuForm extends React.Component {
     const me = this.props.appContainer.me;
 
     return (
-      <Fragment>
-          <p>
-            {user.username !== me
-              ? (
-                <a data-toggle="collapse" href="#removeAdminForm">
-                  <i className="icon-fw icon-user-unfollow mb-2"></i> { t('user_management.remove_admin_access') }
-                </a>
-
-              )
-              : (
-                <div className="mx-4">
-                  <i className="icon-fw icon-user-unfollow mb-2"></i>{ t('user_management.remove_admin_access') }
-                  <p className="alert alert-danger">{ t('user_management.cannot_remove') }</p>
-                </div>
-              )
-            }
-          </p>
-          <form onSubmit={this.handleSubmit}>
-            <div id="removeAdminForm" className="collapse">
-              <div className="form-group">
-                <label htmlFor="name">{ t('user_group_management.group_name') }</label>
-                <textarea
-                  id="name"
-                  name="name"
-                  className="form-control"
-                  placeholder={t('user_group_management.group_example')}
-                  value={this.state.name}
-                  onChange={this.handleChange}
-                >
-                </textarea>
-              </div>
+      <div className="px-4">
+        {user.username !== me
+          ? (
+            <form action="/admin/user/+ {user._id} +/removeFromAdmin" method="post">
+              <i className="icon-fw icon-user-unfollow mb-2"></i> { t('user_management.remove_admin_access') }
+            </form>
+
+          )
+          : (
+            <div>
+              <i className="icon-fw icon-user-unfollow mb-2"></i>{ t('user_management.remove_admin_access') }
+              <p className="alert alert-danger">{ t('user_management.cannot_remove') }</p>
             </div>
-          </form>
+          )
+        }
+      </div>
     );
   }
 
 }
 
 /**
- * Wrapper component for using unstated
- */
+* Wrapper component for using unstated
+*/
 const AdminMenuFormWrapper = (props) => {
   return createSubscribedElement(AdminMenuForm, props, [AppContainer]);
 };

+ 23 - 5
src/client/js/components/Admin/Users/StatusActivateForm.jsx

@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
-import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 class StatusActivateForm extends React.Component {
 
@@ -18,10 +17,29 @@ class StatusActivateForm extends React.Component {
   }
 
   render() {
-    const { t, user }= this.props;
-    const me = this.props.appContainer.me;
-
-    return ();
+    const { t, user } = this.props;
+
+    return (
+      <div className="px-4">
+        {user.status === 1
+          ? (
+            <form action="/admin/user/{{ sUserId }}/activate" method="post">
+              <i className="icon-fw icon-user-following"></i> { t('user_management.accept') }
+            </form>
+          )
+          : (
+            <div>
+              <form action="/admin/user/{{ sUserId }}/activate" method="post">
+                <i className="icon-fw icon-action-redo"></i> { t('Undo') }
+              </form>
+              <form action="/admin/user/{{ sUserId }}/remove" method="post">
+                <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
+              </form>
+            </div>
+          )
+        }
+      </div>
+    );
   }
 
 }

+ 18 - 3
src/client/js/components/Admin/Users/StatusSuspendedForm.jsx

@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
-import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 class StatusSuspendedForm extends React.Component {
 
@@ -18,10 +17,26 @@ class StatusSuspendedForm extends React.Component {
   }
 
   render() {
-    const { t, user }= this.props;
+    const { t, user } = this.props;
     const me = this.props.appContainer.me;
 
-    return ();
+    return (
+      <div className="px-4">
+        {user.username !== me
+          ? (
+            <form id="form_suspend_user" action="/admin/user/{{ sUserId }}/suspend" method="post">
+              <i className="icon-fw icon-ban"></i>{ t('user_management.deactivate_account') }
+            </form>
+          )
+          : (
+            <div>
+              <i className="icon-fw icon-ban mb-2"></i>{ t('user_management.deactivate_account') }
+              <p className="alert alert-danger">{ t('user_management.your_own') }</p>
+            </div>
+          )
+        }
+      </div>
+    );
   }
 
 }

+ 3 - 51
src/client/js/components/Admin/Users/UserMenu.jsx

@@ -5,7 +5,7 @@ import { withTranslation } from 'react-i18next';
 import PasswordResetModal from './PasswordResetModal';
 import StatusActivateForm from './StatusActivateForm';
 import StatusSuspendedForm from './StatusSuspendedForm';
-import RemoveUserForm from './RemoveUserForm';
+import RemoveUserForm from './UserRemoveForm';
 import RemoveAdminForm from './RemoveAdminForm';
 import GiveAdminForm from './GiveAdminForm';
 
@@ -18,55 +18,6 @@ class UserMenu extends React.Component {
   render() {
     const { t, user } = this.props;
 
-    // let contentOfStatus;
-    // let adminMenu;
-
-    // if (user.status === 1) {
-    //   contentOfStatus = (
-    //     <a className="mx-4" onClick={this.activateUser}>
-    //       <i className="icon-fw icon-user-following"></i> { t('user_management.accept') }
-    //     </a>
-    //   );
-    // }
-    // if (user.status === 2) {
-    //   contentOfStatus = (
-    //     user.username !== me
-    //       ? (
-    //         <a onClick={this.susupendUser}>
-    //           <i className="icon-fw icon-ban"></i>{ t('user_management.deactivate_account') }
-    //         </a>
-    //       )
-    //       : (
-    //         <div className="mx-4">
-    //           <i className="icon-fw icon-ban mb-2"></i>{ t('user_management.deactivate_account') }
-    //           <p className="alert alert-danger">{ t('user_management.your_own') }</p>
-    //         </div>
-    //       )
-    //   );
-    // }
-    // if (user.status === 3) {
-    //   contentOfStatus = (
-    //     <div>
-    //       <a className="mx-4" onClick={this.activateUser}>
-    //         <i className="icon-fw icon-action-redo"></i> { t('Undo') }
-    //       </a>
-    //       {/* label は同じだけど、こっちは論理削除 */}
-    //       <a className="mx-4" onClick={this.removeUser}>
-    //         <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
-    //       </a>
-    //     </div>
-    //   );
-    // }
-    // if (user.status === 1 || user.status === 5) {
-    //   contentOfStatus = (
-    //     <li className="dropdown-button">
-    //       <a className="mx-4" onClick={this.removeUser}>
-    //         <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
-    //       </a>
-    //     </li>
-    //   );
-    // }
-
     return (
       <Fragment>
         <div className="btn-group admin-user-menu">
@@ -76,7 +27,8 @@ class UserMenu extends React.Component {
           <ul className="dropdown-menu" role="menu">
             <li className="dropdown-header">{ t('user_management.edit_menu') }</li>
             <li>
-              <a>
+              <a onClick={this.isShow}>
+                <i className="icon-fw icon-key"></i>{ t('user_management.reset_password') }
                 <PasswordResetModal user={user} />
               </a>
             </li>

+ 6 - 4
src/client/js/components/Admin/Users/UserRemoveForm.jsx

@@ -4,7 +4,6 @@ import { withTranslation } from 'react-i18next';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
 import AppContainer from '../../../services/AppContainer';
-import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 class UserRemoveForm extends React.Component {
 
@@ -18,10 +17,13 @@ class UserRemoveForm extends React.Component {
   }
 
   render() {
-    const { t, user }= this.props;
-    const me = this.props.appContainer.me;
+    const { t } = this.props;
 
-    return ();
+    return (
+      <form className="px-4" id="form_remove_{{ sUserId }}" action="/admin/user/{{ sUserId }}/remove" method="post">
+        <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
+      </form>
+    );
   }
 
 }