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

ref: Use better constant values for copyState (AdminHome)

Mxchaeltrxn 4 лет назад
Родитель
Сommit
b2b1c389e3

+ 9 - 5
packages/app/src/client/services/AdminHomeContainer.js

@@ -18,18 +18,22 @@ export default class AdminHomeContainer extends Container {
 
 
     this.appContainer = appContainer;
     this.appContainer = appContainer;
 
 
+    this.copyStateValues = {
+      DEFAULT: 'default',
+      DONE: 'done',
+    };
+    this.timer = null;
+
     this.state = {
     this.state = {
       retrieveError: null,
       retrieveError: null,
       growiVersion: '',
       growiVersion: '',
       nodeVersion: '',
       nodeVersion: '',
       npmVersion: '',
       npmVersion: '',
       yarnVersion: '',
       yarnVersion: '',
-      copyState: 'default',
+      copyState: this.copyStateValues.DEFAULT,
       installedPlugins: [],
       installedPlugins: [],
     };
     };
 
 
-    this.timer = null;
-
   }
   }
 
 
   /**
   /**
@@ -73,13 +77,13 @@ export default class AdminHomeContainer extends Container {
   onCopyBugReport() {
   onCopyBugReport() {
     this.setState(prevState => ({
     this.setState(prevState => ({
       ...prevState,
       ...prevState,
-      copyState: 'done',
+      copyState: this.copyStateValues.DONE,
     }));
     }));
 
 
     this.timer = setTimeout(() => {
     this.timer = setTimeout(() => {
       this.setState(prevState => ({
       this.setState(prevState => ({
         ...prevState,
         ...prevState,
-        copyState: 'default',
+        copyState: this.copyStateValues.DEFAULT,
       }));
       }));
     }, 500);
     }, 500);
   }
   }

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

@@ -71,7 +71,9 @@ class AdminHome extends React.Component {
             <p>
             <p>
               <CopyToClipboard text={adminHomeContainer.generatePrefilledBugReport()} onCopy={() => adminHomeContainer.onCopyBugReport()}>
               <CopyToClipboard text={adminHomeContainer.generatePrefilledBugReport()} onCopy={() => adminHomeContainer.onCopyBugReport()}>
                 <button type="button" className="btn btn-primary">
                 <button type="button" className="btn btn-primary">
-                  {adminHomeContainer.state.copyState === 'default' ? t('admin:admin_top:copy_bug_report:default') : t('admin:admin_top:copy_bug_report:done')}
+                  {adminHomeContainer.state.copyState === adminHomeContainer.copyStateValues.DEFAULT
+                    ? t('admin:admin_top:copy_bug_report:default')
+                    : t('admin:admin_top:copy_bug_report:done')}
                 </button>
                 </button>
               </CopyToClipboard>{' '}
               </CopyToClipboard>{' '}
               {/* eslint-disable-next-line react/no-danger */}
               {/* eslint-disable-next-line react/no-danger */}