fix: YAML查看器按钮文案 '清理并编辑' → '编辑',统一简洁命名
This commit is contained in:
1 parent
a8b4af4409
commit
4bd9fa629b
14 files changed
+2146
-400
No files matched your search
@@ -69,6 +69,10 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
}
|
||||
};
|
||||
|
||||
// 视图模式:当 cleanBeforeEdit 时,只读视图也默认展示精简版(剥离 status/managedFields/uid/resourceVersion)
|
||||
// 用户可点击「原始」按钮切换回未处理的完整服务端输出
|
||||
const [showRaw, setShowRaw] = useState(false);
|
||||
|
||||
const saveYaml = async () => {
|
||||
setSaving(true);
|
||||
try {
|
||||
@@ -91,7 +95,10 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
|
||||
useEffect(() => { loadYaml(); }, []);
|
||||
|
||||
const display = editing ? editYaml : rawYaml;
|
||||
// 编辑态用 editYaml;只读态根据 effectiveClean + showRaw 决定是否清理
|
||||
const display = editing
|
||||
? editYaml
|
||||
: (effectiveClean && !showRaw ? cleanYAML(rawYaml) : rawYaml);
|
||||
|
||||
// CodeMirror 主题扩展
|
||||
const extensions = useMemo(() => [
|
||||
@@ -113,11 +120,17 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
{copied ? <Check className="h-3 w-3 mr-1 text-emerald-400" /> : <Copy className="h-3 w-3 mr-1" />}
|
||||
{copied ? '已复制' : '复制'}
|
||||
</Button>
|
||||
{effectiveClean && !editing && (
|
||||
<Button variant="outline" size="sm" className={`h-7 text-xs ${showRaw ? 'border-slate-700 text-slate-500' : 'border-emerald-700/50 text-emerald-400'}`}
|
||||
onClick={() => setShowRaw(v => !v)} title="切换 精简/原始 视图">
|
||||
<Sparkles className="h-3 w-3 mr-1" />{showRaw ? '原始' : '精简'}
|
||||
</Button>
|
||||
)}
|
||||
{!editing ? (
|
||||
<>
|
||||
{effectiveClean && (
|
||||
<Button variant="outline" size="sm" className="h-7 border-slate-700 text-slate-300 text-xs" onClick={enterEdit} title="清理 status / managedFields 等只读字段后编辑">
|
||||
<Sparkles className="h-3 w-3 mr-1 text-amber-400" />清理并编辑
|
||||
<Sparkles className="h-3 w-3 mr-1 text-amber-400" />编辑
|
||||
</Button>
|
||||
)}
|
||||
{!effectiveClean && (
|
||||
@@ -182,6 +195,12 @@ export function YamlViewer({ clusterCode, namespace, resource, name, onClose, on
|
||||
{copied ? <Check className="h-3 w-3 mr-1 text-emerald-400" /> : <Copy className="h-3 w-3 mr-1" />}
|
||||
{copied ? '已复制' : '复制'}
|
||||
</Button>
|
||||
{effectiveClean && !editing && (
|
||||
<Button variant="outline" size="sm" className={`h-8 text-xs ${showRaw ? 'border-slate-700 text-slate-500' : 'border-emerald-700/50 text-emerald-400'}`}
|
||||
onClick={() => setShowRaw(v => !v)} title="切换 精简/原始 视图">
|
||||
<Sparkles className="h-3 w-3 mr-1" />{showRaw ? '原始' : '精简'}
|
||||
</Button>
|
||||
)}
|
||||
{!editing ? (
|
||||
<>
|
||||
{effectiveClean && (
|
||||
|
||||
Reference in new issue
Block a user