mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
Merge branch 'liburdi-feature/copy_access'
This commit is contained in:
commit
dfba5ee638
File diff suppressed because one or more lines are too long
2
ui/dist/index.html
vendored
2
ui/dist/index.html
vendored
@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Certimate - Your Trusted SSL Automation Partner</title>
|
||||
<script type="module" crossorigin src="/assets/index--un-5Tw_.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DjCbudz9.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-I--T0qY3.css">
|
||||
</head>
|
||||
<body class="bg-background">
|
||||
|
@ -24,9 +24,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessAliyunForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -69,6 +71,7 @@ const AccessAliyunForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -76,10 +79,11 @@ const AccessAliyunForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
console.log(req);
|
||||
addAccess(req);
|
||||
} catch (e) {
|
||||
const err = e as ClientResponseError;
|
||||
|
@ -23,9 +23,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessCloudflareForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -65,6 +67,7 @@ const AccessCloudflareForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -72,7 +75,7 @@ const AccessCloudflareForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import AccessGodaddyFrom from "./AccessGodaddyForm";
|
||||
import AccessLocalForm from "./AccessLocalForm";
|
||||
|
||||
type TargetConfigEditProps = {
|
||||
op: "add" | "edit";
|
||||
op: "add" | "edit" | "copy";
|
||||
className?: string;
|
||||
trigger: React.ReactNode;
|
||||
data?: Access;
|
||||
@ -60,6 +60,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessTencentForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -70,6 +71,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessAliyunForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -80,6 +82,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessSSHForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -90,6 +93,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<WebhookForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -100,6 +104,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessCloudflareForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -110,6 +115,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessQiniuForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -120,6 +126,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessNamesiloForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -130,6 +137,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessGodaddyFrom
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -140,6 +148,7 @@ export function AccessEdit({
|
||||
form = (
|
||||
<AccessLocalForm
|
||||
data={data}
|
||||
op={op}
|
||||
onAfterReq={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
@ -159,7 +168,7 @@ export function AccessEdit({
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-[600px] w-full dark:text-stone-200">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{op == "add" ? t('access.add') : t('access.edit')}</DialogTitle>
|
||||
<DialogTitle>{op == "add" ? t('access.add') : op == "edit" ? t('access.edit') : t('access.copy')}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<ScrollArea className="max-h-[80vh]">
|
||||
<div className="container py-3">
|
||||
|
@ -28,9 +28,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessGodaddyFrom = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -74,6 +76,7 @@ const AccessGodaddyFrom = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -81,7 +84,7 @@ const AccessGodaddyFrom = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -27,9 +27,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessLocalForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess, reloadAccessGroups } = useConfig();
|
||||
@ -79,6 +81,7 @@ const AccessLocalForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -86,7 +89,7 @@ const AccessLocalForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
} else {
|
||||
addAccess(req);
|
||||
|
@ -23,9 +23,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessNamesiloForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -64,6 +66,7 @@ const AccessNamesiloForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -71,7 +74,7 @@ const AccessNamesiloForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -24,9 +24,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessQiniuForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -69,6 +71,7 @@ const AccessQiniuForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -76,7 +79,7 @@ const AccessQiniuForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -39,9 +39,11 @@ import { updateById } from "@/repository/access_group";
|
||||
|
||||
const AccessSSHForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const {
|
||||
@ -145,6 +147,7 @@ const AccessSSHForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -152,7 +155,7 @@ const AccessSSHForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
} else {
|
||||
addAccess(req);
|
||||
|
@ -23,9 +23,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const AccessTencentForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -68,6 +70,7 @@ const AccessTencentForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -75,7 +78,7 @@ const AccessTencentForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -23,9 +23,11 @@ import { PbErrorData } from "@/domain/base";
|
||||
|
||||
const WebhookForm = ({
|
||||
data,
|
||||
op,
|
||||
onAfterReq,
|
||||
}: {
|
||||
data?: Access;
|
||||
op: "add" | "edit" | "copy";
|
||||
onAfterReq: () => void;
|
||||
}) => {
|
||||
const { addAccess, updateAccess } = useConfig();
|
||||
@ -64,6 +66,7 @@ const WebhookForm = ({
|
||||
};
|
||||
|
||||
try {
|
||||
req.id = op == "copy" ? "" : req.id;
|
||||
const rs = await save(req);
|
||||
|
||||
onAfterReq();
|
||||
@ -71,7 +74,7 @@ const WebhookForm = ({
|
||||
req.id = rs.id;
|
||||
req.created = rs.created;
|
||||
req.updated = rs.updated;
|
||||
if (data.id) {
|
||||
if (data.id && op == "edit") {
|
||||
updateAccess(req);
|
||||
return;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
"cancel": "Cancel",
|
||||
"confirm": "Confirm",
|
||||
"edit": "Edit",
|
||||
"copy": "Copy",
|
||||
"succeed": "Successful",
|
||||
"add": "Add",
|
||||
"document": "Document",
|
||||
@ -154,6 +155,7 @@
|
||||
"access.management": "Authorization Management",
|
||||
"access.add": "Add Authorization",
|
||||
"access.edit": "Edit Authorization",
|
||||
"access.delete.confirm": "Are you sure you want to delete the deployment authorization?",
|
||||
"access.all": "All Authorizations",
|
||||
"access.list": "Authorization List",
|
||||
"access.type": "Provider",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"cancel": "取消",
|
||||
"confirm": "确认",
|
||||
"edit": "编辑",
|
||||
"copy": "复制",
|
||||
"succeed": "成功",
|
||||
"add": "新增",
|
||||
"document": "文档",
|
||||
@ -154,6 +155,8 @@
|
||||
"access.management": "授权管理",
|
||||
"access.add": "添加授权",
|
||||
"access.edit": "编辑授权",
|
||||
"access.copy": "复制授权",
|
||||
"access.delete.confirm": "确定要删除授权吗?",
|
||||
"access.all": "所有授权",
|
||||
"access.list": "授权列表",
|
||||
"access.type": "服务商",
|
||||
|
@ -12,6 +12,15 @@ import { remove } from "@/repository/access";
|
||||
import { t } from "i18next";
|
||||
import { Key } from "lucide-react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent, AlertDialogDescription, AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger
|
||||
} from "@/components/ui/alert-dialog.tsx";
|
||||
|
||||
const Access = () => {
|
||||
const { config, deleteAccess } = useConfig();
|
||||
@ -149,15 +158,45 @@ const Access = () => {
|
||||
data={access}
|
||||
/>
|
||||
<Separator orientation="vertical" className="h-4 mx-2" />
|
||||
<Button
|
||||
variant={"link"}
|
||||
className="p-0"
|
||||
<AccessEdit
|
||||
trigger={
|
||||
<Button variant={"link"} className="p-0">
|
||||
{t("copy")}
|
||||
</Button>
|
||||
}
|
||||
op="copy"
|
||||
data={access}
|
||||
/>
|
||||
<Separator orientation="vertical" className="h-4 mx-2" />
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button variant={"link"} size={"sm"}>
|
||||
{t('delete')}
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle className="dark:text-gray-200">
|
||||
{t('access.group.delete')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('access.delete.confirm')}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel className="dark:text-gray-200">
|
||||
{t('cancel')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={() => {
|
||||
handleDelete(access);
|
||||
}}
|
||||
>
|
||||
{t("delete")}
|
||||
</Button>
|
||||
{t('confirm')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
Loading…
x
Reference in New Issue
Block a user