fix(admin): remove manual reasons and repair code creation
This commit is contained in:
@@ -8,7 +8,7 @@ import { App, Button, Form, Input, InputNumber, Modal, Select, Space, Switch, Ta
|
||||
import { useState } from "react";
|
||||
|
||||
import { adminRequestJson, type AdminIdentity } from "@/lib/admin/providers";
|
||||
import { ReasonActionModal } from "./reason-action-modal";
|
||||
import { ConfirmActionModal } from "./confirm-action-modal";
|
||||
import { formatAdminDate } from "./resource-table";
|
||||
|
||||
const { Text } = Typography;
|
||||
@@ -32,7 +32,6 @@ type FlagForm = {
|
||||
enabled: boolean;
|
||||
rolloutPercentage: number;
|
||||
configJson: string;
|
||||
reason: string;
|
||||
};
|
||||
|
||||
export default function FeatureFlagsManagement() {
|
||||
@@ -62,13 +61,11 @@ export default function FeatureFlagsManagement() {
|
||||
enabled: item.enabled,
|
||||
rolloutPercentage: item.rolloutPercentage,
|
||||
configJson: JSON.stringify(item.config, null, 2),
|
||||
reason: "",
|
||||
} : {
|
||||
flagKey: "",
|
||||
enabled: false,
|
||||
rolloutPercentage: 0,
|
||||
configJson: "{}",
|
||||
reason: "",
|
||||
});
|
||||
setOpen(true);
|
||||
}
|
||||
@@ -92,7 +89,6 @@ export default function FeatureFlagsManagement() {
|
||||
rolloutPercentage: values.rolloutPercentage,
|
||||
config,
|
||||
expectedVersion: editing?.version ?? null,
|
||||
reason: values.reason.trim(),
|
||||
}),
|
||||
});
|
||||
message.success("功能开关草稿已保存");
|
||||
@@ -105,12 +101,12 @@ export default function FeatureFlagsManagement() {
|
||||
}
|
||||
}
|
||||
|
||||
async function publish(item: FeatureFlag, reason: string) {
|
||||
async function publish(item: FeatureFlag) {
|
||||
setPublishingId(item.id);
|
||||
try {
|
||||
await adminRequestJson("/api/admin/feature-flags", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ action: "publish", id: item.id, expectedVersion: item.version, reason }),
|
||||
body: JSON.stringify({ action: "publish", id: item.id, expectedVersion: item.version }),
|
||||
});
|
||||
message.success("功能开关已发布");
|
||||
await table.tableQuery.refetch();
|
||||
@@ -154,16 +150,15 @@ export default function FeatureFlagsManagement() {
|
||||
<Form.Item name="rolloutPercentage" label="灰度百分比" rules={[{ required: true }]}><InputNumber min={0} max={100} precision={0} style={{ width: "100%" }} /></Form.Item>
|
||||
<Form.Item name="enabled" label="启用" valuePropName="checked"><Switch /></Form.Item>
|
||||
<Form.Item name="configJson" label="配置 JSON" rules={[{ required: true }]}><Input.TextArea rows={6} spellCheck={false} /></Form.Item>
|
||||
<Form.Item name="reason" label="修改原因" rules={[{ required: true }, { max: 500 }]}><Input.TextArea rows={2} /></Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
<ReasonActionModal
|
||||
<ConfirmActionModal
|
||||
open={Boolean(publishTarget)}
|
||||
title={`发布功能开关${publishTarget ? `:${publishTarget.flagKey}` : ""}`}
|
||||
okText="确认发布"
|
||||
confirmLoading={Boolean(publishingId)}
|
||||
onCancel={() => setPublishTarget(null)}
|
||||
onSubmit={(reason) => publish(publishTarget!, reason)}
|
||||
onConfirm={() => publish(publishTarget!)}
|
||||
/>
|
||||
</List>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user