|
|
@@ -3,17 +3,34 @@ import React, { useCallback } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import { toastSuccess, toastError } from '~/client/util/apiNotification';
|
|
|
+import { apiv3Post } from '~/client/util/apiv3-client';
|
|
|
|
|
|
-import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
|
|
|
+import AdminInstallButtonRow from '../Common/AdminUpdateButtonRow';
|
|
|
// TODO: error notification (toast, loggerFactory)
|
|
|
// TODO: i18n
|
|
|
|
|
|
export const PluginInstallerForm = (): JSX.Element => {
|
|
|
const { t } = useTranslation('admin');
|
|
|
|
|
|
- const submitHandler = useCallback(async() => {
|
|
|
+ const submitHandler = useCallback(async(e) => {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ const formData = e.target.elements;
|
|
|
+
|
|
|
+ const {
|
|
|
+ 'pluginInstallerForm[url]': { value: url },
|
|
|
+ 'pluginInstallerForm[ghBranch]': { value: ghBranch },
|
|
|
+ 'pluginInstallerForm[ghTag]': { value: ghTag },
|
|
|
+ } = formData;
|
|
|
+
|
|
|
+ const pluginInstallerForm = {
|
|
|
+ url,
|
|
|
+ ghBranch,
|
|
|
+ ghTag,
|
|
|
+ };
|
|
|
+
|
|
|
try {
|
|
|
- // await adminAppContainer.updateAppSettingHandler();
|
|
|
+ await apiv3Post('/plugins-extention', { pluginInstallerForm });
|
|
|
toastSuccess(t('toaster.update_successed', { target: t('app_settings') }));
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -23,19 +40,17 @@ export const PluginInstallerForm = (): JSX.Element => {
|
|
|
}, [t]);
|
|
|
|
|
|
return (
|
|
|
- <>
|
|
|
+ <form role="form" onSubmit={submitHandler}>
|
|
|
<div className='form-group row'>
|
|
|
- <label className="text-left text-md-right col-md-3 col-form-label">Plugin URL</label>
|
|
|
- {/* <label className="text-left text-md-right col-md-3 col-form-label">{t('admin:plugins_extention.plugin_url')}</label> */}
|
|
|
+ <label className="text-left text-md-right col-md-3 col-form-label">GitHub repository URL</label>
|
|
|
<div className="col-md-6">
|
|
|
<input
|
|
|
className="form-control"
|
|
|
type="text"
|
|
|
// defaultValue={adminAppContainer.state.title || ''}
|
|
|
- // onChange={(e) => {
|
|
|
- // adminAppContainer.changeTitle(e.target.value);
|
|
|
- // }}
|
|
|
+ name="pluginInstallerForm[url]"
|
|
|
placeholder="https://github.com/weseek/growi-plugins/vibrant-dark-ui"
|
|
|
+ required
|
|
|
/>
|
|
|
<p className="form-text text-muted">Install the plugin in GROWI: Enter the URL of the plugin repository and press the Update.</p>
|
|
|
{/* <p className="form-text text-muted">{t('admin:app_setting.sitename_change')}</p> */}
|
|
|
@@ -47,10 +62,7 @@ export const PluginInstallerForm = (): JSX.Element => {
|
|
|
<input
|
|
|
className="form-control"
|
|
|
type="text"
|
|
|
- // defaultValue={adminAppContainer.state.title || ''}
|
|
|
- // onChange={(e) => {
|
|
|
- // adminAppContainer.changeTitle(e.target.value);
|
|
|
- // }}
|
|
|
+ name="pluginInstallerForm[ghBranch]"
|
|
|
placeholder="main"
|
|
|
/>
|
|
|
<p className="form-text text-muted">branch name</p>
|
|
|
@@ -62,18 +74,18 @@ export const PluginInstallerForm = (): JSX.Element => {
|
|
|
<input
|
|
|
className="form-control"
|
|
|
type="text"
|
|
|
- // defaultValue={adminAppContainer.state.title || ''}
|
|
|
- // onChange={(e) => {
|
|
|
- // adminAppContainer.changeTitle(e.target.value);
|
|
|
- // }}
|
|
|
+ name="pluginInstallerForm[ghTag]"
|
|
|
placeholder="tags"
|
|
|
/>
|
|
|
<p className="form-text text-muted">tag name</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <AdminUpdateButtonRow onClick={submitHandler} disabled={false}/>
|
|
|
- {/* <AdminUpdateButtonRow onClick={submitHandler} disabled={adminAppContainer.state.retrieveError != null} /> */}
|
|
|
- </>
|
|
|
+ <div className="row my-3">
|
|
|
+ <div className="mx-auto">
|
|
|
+ <button type="submit" className="btn btn-primary" >Install</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
);
|
|
|
};
|