Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions frontend/src/locale/src/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Pfad Hinzufügen"
},
"action.clone": {
"defaultMessage": "Klonen"
},
"action.close": {
"defaultMessage": "Schließen"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"action.allow": {
"defaultMessage": "Allow"
},
"action.clone": {
"defaultMessage": "Clone"
},
"action.close": {
"defaultMessage": "Close"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"action.allow": {
"defaultMessage": "Permitir"
},
"action.clone": {
"defaultMessage": "Clonar"
},
"action.close": {
"defaultMessage": "Cerrar"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Aggiungi Percorso"
},
"action.clone": {
"defaultMessage": "Clona"
},
"action.close": {
"defaultMessage": "Chiudi"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "場所を追加"
},
"action.clone": {
"defaultMessage": "複製"
},
"action.close": {
"defaultMessage": "閉じる"
},
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/locale/src/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Locatie Toevoegen"
},
"action.clone": {
"defaultMessage": "Klonen"
},
"action.close": {
"defaultMessage": "Sluiten"
},
Expand Down Expand Up @@ -644,4 +647,4 @@
"users": {
"defaultMessage": "Gebruikers"
}
}
}
3 changes: 3 additions & 0 deletions frontend/src/locale/src/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Dodaj lokalizację"
},
"action.clone": {
"defaultMessage": "Klonuj"
},
"action.close": {
"defaultMessage": "Zamknij"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Добавить маршрут"
},
"action.clone": {
"defaultMessage": "Клонировать"
},
"action.close": {
"defaultMessage": "Закрыть"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Pridať umiestnenie"
},
"action.clone": {
"defaultMessage": "Klonovať"
},
"action.close": {
"defaultMessage": "Zavrieť"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "Thêm Vị trí"
},
"action.clone": {
"defaultMessage": "Nhân bản"
},
"action.close": {
"defaultMessage": "Đóng"
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/locale/src/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
"action.add-location": {
"defaultMessage": "添加路径规则(Location)"
},
"action.clone": {
"defaultMessage": "克隆"
},
"action.close": {
"defaultMessage": "关闭"
},
Expand Down
16 changes: 9 additions & 7 deletions frontend/src/modals/ProxyHostModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import { MANAGE, PROXY_HOSTS } from "src/modules/Permissions";
import { validateNumber, validateString } from "src/modules/Validations";
import { showObjectSuccess } from "src/notifications";

const showProxyHostModal = (id: number | "new") => {
EasyModal.show(ProxyHostModal, { id });
};

interface Props extends InnerModalProps {
id: number | "new";
isClone?: boolean;
}
const ProxyHostModal = EasyModal.create(({ id, visible, remove }: Props) => {

const ProxyHostModal = EasyModal.create(({ id, isClone = false, visible, remove }: Props) => {
const { data: currentUser, isLoading: userIsLoading, error: userError } = useUser("me");
const { data, isLoading, error } = useProxyHost(id);
const { mutate: setProxyHost } = useSetProxyHost();
Expand All @@ -42,7 +40,7 @@ const ProxyHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
setErrorMsg(null);

const { ...payload } = {
id: id === "new" ? undefined : id,
id: id === "new" || isClone ? undefined : id,
...values,
};

Expand Down Expand Up @@ -99,7 +97,7 @@ const ProxyHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
<Form>
<Modal.Header closeButton>
<Modal.Title>
<T id={data?.id ? "object.edit" : "object.add"} tData={{ object: "proxy-host" }} />
<T id={isClone ? "object.add" : data?.id ? "object.edit" : "object.add"} tData={{ object: "proxy-host" }} />
</Modal.Title>
</Modal.Header>
<Modal.Body className="p-0">
Expand Down Expand Up @@ -373,4 +371,8 @@ const ProxyHostModal = EasyModal.create(({ id, visible, remove }: Props) => {
);
});

const showProxyHostModal = (id: number | "new", isClone = false) => {
EasyModal.show(ProxyHostModal, { id, isClone } as Omit<Props, "visible" | "remove">);
};

export { showProxyHostModal };
18 changes: 15 additions & 3 deletions frontend/src/pages/Nginx/ProxyHosts/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconDotsVertical, IconEdit, IconPower, IconTrash } from "@tabler/icons-react";
import { IconCopy, IconDotsVertical, IconEdit, IconPower, IconTrash } from "@tabler/icons-react";
import { createColumnHelper, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import { useMemo } from "react";
import type { ProxyHost } from "src/api/backend";
Expand All @@ -20,11 +20,12 @@ interface Props {
isFiltered?: boolean;
isFetching?: boolean;
onEdit?: (id: number) => void;
onClone?: (id: number) => void;
onDelete?: (id: number) => void;
onDisableToggle?: (id: number, enabled: boolean) => void;
onNew?: () => void;
}
export default function Table({ data, isFetching, onEdit, onDelete, onDisableToggle, onNew, isFiltered }: Props) {
export default function Table({ data, isFetching, onEdit, onClone, onDelete, onDisableToggle, onNew, isFiltered }: Props) {
const columnHelper = createColumnHelper<ProxyHost>();
const columns = useMemo(
() => [
Expand Down Expand Up @@ -107,6 +108,17 @@ export default function Table({ data, isFetching, onEdit, onDelete, onDisableTog
<IconEdit size={16} />
<T id="action.edit" />
</a>
<a
className="dropdown-item"
href="#"
onClick={(e) => {
e.preventDefault();
onClone?.(info.row.original.id);
}}
>
<IconCopy size={16} />
<T id="action.clone" />
</a>
<HasPermission section={PROXY_HOSTS} permission={MANAGE} hideError>
<a
className="dropdown-item"
Expand Down Expand Up @@ -141,7 +153,7 @@ export default function Table({ data, isFetching, onEdit, onDelete, onDisableTog
},
}),
],
[columnHelper, onEdit, onDisableToggle, onDelete],
[columnHelper, onEdit, onClone, onDisableToggle, onDelete],
);

const tableInstance = useReactTable<ProxyHost>({
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Nginx/ProxyHosts/TableWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default function TableWrapper() {
isFiltered={!!search}
isFetching={isFetching}
onEdit={(id: number) => showProxyHostModal(id)}
onClone={(id: number) => showProxyHostModal(id, true)}
onDelete={(id: number) =>
showDeleteConfirmModal({
title: <T id="object.delete" tData={{ object: "proxy-host" }} />,
Expand Down