Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imprv: Show modal when you delete plugin #7875

Merged
merged 28 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d5bb417
125483 create delete plugin modal
soumaeda Jul 12, 2023
050acf5
125483 show delete modal
soumaeda Jul 12, 2023
b064e96
125483 add onCancelDeletePlugin
soumaeda Jul 13, 2023
789aa44
125487 apply i18n
soumaeda Jul 13, 2023
d1dc3f5
125483 rename DeletePlugin to PluginDelete
soumaeda Jul 13, 2023
6cd6c7b
125487 remove cancel button
soumaeda Jul 13, 2023
5f4b1ee
125483 add visible cypress
soumaeda Jul 14, 2023
e27d8db
125483 merge master
soumaeda Jul 14, 2023
65eedab
125483 add getByTestId to cypress
soumaeda Jul 14, 2023
6b8832c
125283
soumaeda Jul 14, 2023
191c5c9
125483 remove if from content
soumaeda Jul 18, 2023
03c158c
125483 remove a part of classname
soumaeda Jul 18, 2023
850d457
125483 use swr to show modal
soumaeda Aug 4, 2023
a53a1f1
125483 apply common.json to delete
soumaeda Aug 4, 2023
b9893f0
125483 apply common to plugin card
soumaeda Aug 4, 2023
1e95c16
125483 use mutate in modal
soumaeda Aug 6, 2023
f6a7818
125483 delete margin
soumaeda Aug 6, 2023
7eeeee2
125483 remove extra discription
soumaeda Aug 7, 2023
4c07d2e
Merge branch 'master' into imprv/111416-125483-show-modal-when-click-…
soumaeda Aug 7, 2023
8b047d1
125483 use icon-fire on plugin delete modal
soumaeda Aug 7, 2023
af7ef49
125483 remove mutate from PlaginCard and Extention
soumaeda Aug 7, 2023
b29a725
125483 use initialStatus
soumaeda Aug 7, 2023
00e4fad
125483 reduce extra margin
soumaeda Aug 7, 2023
a77bd37
125843 hand over directly
soumaeda Aug 8, 2023
a206c4f
125483 use promise
soumaeda Aug 8, 2023
bce0ad2
125483 do not use type assertion
soumaeda Aug 8, 2023
ce10162
125483 define as promise void
soumaeda Aug 8, 2023
1cc4b16
125483 add component PluginsExtensionPageContents
soumaeda Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/app/public/static/locales/en_US/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@
"plugin_card": "Plugin Card",
"plugin_is_not_installed": "Plugin is not installed",
"install": "Install",
"delete": "Delete"
"delete": "Delete",
jam411 marked this conversation as resolved.
Show resolved Hide resolved
"confirm": "Delete plugin?"
},
"cloud_setting_management": {
"to_cloud_settings": "Open GROWI.cloud Settings"
Expand Down
3 changes: 2 additions & 1 deletion apps/app/public/static/locales/ja_JP/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@
"plugin_card": "プラグインカード",
"plugin_is_not_installed": "プラグインがインストールされていません",
"install": "インストール",
"delete": "削除"
"delete": "削除",
"confirm": "プラグインを削除しますか?"
},
"cloud_setting_management": {
"to_cloud_settings": "GROWI.cloud の管理画面へ"
Expand Down
3 changes: 2 additions & 1 deletion apps/app/public/static/locales/zh_CN/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,8 @@
"plugin_card": "Plugin Card",
"plugin_is_not_installed": "Plugin is not installed",
"install": "Install",
"delete": "Delete"
"delete": "Delete",
"confirm": "Delete plugin?"
},
"cloud_setting_management": {
"to_cloud_settings": "進入 GROWI.cloud 的管理界面"
Expand Down
jam411 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Link from 'next/link';
import { apiv3Delete, apiv3Put } from '~/client/util/apiv3-client';
import { toastSuccess, toastError } from '~/client/util/toastr';

import { PluginDeleteModal } from './PluginDeleteModal';

import styles from './PluginCard.module.scss';

type Props = {
Expand Down Expand Up @@ -69,6 +71,15 @@ export const PluginCard = (props: Props): JSX.Element => {
};

const PluginDeleteButton = (): JSX.Element => {
const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState<boolean>(false);

const onClickPluginDeleteButton = () => {
setIsDeleteConfirmModalShown(true);
};

const onCancelDeletePlugin = () => {
setIsDeleteConfirmModalShown(false);
};

const onClickPluginDeleteBtnHandler = async() => {
const reqUrl = `/plugins/${id}/remove`;
Expand All @@ -83,6 +94,7 @@ export const PluginCard = (props: Props): JSX.Element => {
}
finally {
mutate();
setIsDeleteConfirmModalShown(false);
}
};

Expand All @@ -91,10 +103,19 @@ export const PluginCard = (props: Props): JSX.Element => {
<button
type="submit"
className="btn btn-primary"
onClick={() => onClickPluginDeleteBtnHandler()}
onClick={() => onClickPluginDeleteButton()}
>
{t('plugins.delete')}
</button>
{isDeleteConfirmModalShown && (
<PluginDeleteModal
isShown={isDeleteConfirmModalShown}
name={name}
url={url}
cancelToDelete={onCancelDeletePlugin}
confirmToDelete={onClickPluginDeleteBtnHandler}
/>
)}
</div>
);
};
Expand Down
jam411 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from 'react';

import { useTranslation } from 'next-i18next';
import Link from 'next/link';
import {
Button, Modal, ModalHeader, ModalBody, ModalFooter,
} from 'reactstrap';


export type PluginDeleteModalProps = {
isShown: boolean,
name: string,
url: string,
cancelToDelete: () => void,
confirmToDelete: () => void,
}

export const PluginDeleteModal = (props: PluginDeleteModalProps): JSX.Element => {
const {
isShown, name, url, cancelToDelete, confirmToDelete,
} = props;

const { t } = useTranslation('admin');

const headerContent = () => {
return (
<span>
{t('plugins.confirm')}
</span>
);
};

const bodyContent = () => {

return (
<div className="card well mt-2 p-2">
<Link href={`${url}`} legacyBehavior>{name}</Link>
</div>
);
};

const footerContent = () => {
return (
<>
<Button color="danger" onClick={confirmToDelete}>
{t('plugins.delete')}
</Button>
</>
);
};

return (
<Modal isOpen={isShown} toggle={cancelToDelete}>
<ModalHeader tag="h4" toggle={cancelToDelete} className="bg-danger text-light">
{headerContent()}
</ModalHeader>
<ModalBody>
{bodyContent()}
</ModalBody>
<ModalFooter>
{footerContent()}
</ModalFooter>
</Modal>
);
};