diff --git a/backend/example_scripts/icmp-drop-requirements.txt b/backend/example_scripts/icmp_drop-requirements.txt
similarity index 100%
rename from backend/example_scripts/icmp-drop-requirements.txt
rename to backend/example_scripts/icmp_drop-requirements.txt
diff --git a/frontend/src/components/ScriptManager.tsx b/frontend/src/components/ScriptManager.tsx
index 0ec9cf4..583cf37 100644
--- a/frontend/src/components/ScriptManager.tsx
+++ b/frontend/src/components/ScriptManager.tsx
@@ -10,6 +10,7 @@ import {
UploadOutlined,
} from '@ant-design/icons';
import {
+ Badge,
Button,
Checkbox,
Col,
@@ -484,6 +485,12 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
setAddReqModalVisible(true);
}, []);
+ const renderStatus = useCallback((isActive: boolean) => {
+ return ;
+ }, []);
+
+ const isScriptActive = useCallback((record: ScriptWithStatus) => record.mappings.some((mapping) => mapping.active), []);
+
const saveAddRequirements = useCallback(async () => {
if (!addReqTarget) return;
let payload: File | Blob | null = null;
@@ -529,7 +536,18 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
title: 'Name',
dataIndex: 'name',
key: 'name',
- render: (text) => {text},
+ render: (_: unknown, record: ScriptWithStatus) => (
+
+ {record.name}
+ {record.is_protected_example ? : null}
+
+ ),
+ },
+ {
+ title: 'Status',
+ key: 'status',
+ width: 120,
+ render: (_: unknown, record: ScriptWithStatus) => renderStatus(isScriptActive(record)),
},
{
title: 'Path',
@@ -540,7 +558,7 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
{
title: 'Requirements',
key: 'requirements',
- render: (_: any, record: ScriptWithStatus) =>
+ render: (_: unknown, record: ScriptWithStatus) =>
record.requirements_exists ? (
handleDownloadRequirements(record.name)}
icon={}
/>
- handleEditRequirements(record.name)}
- icon={}
- />
- handleDeleteRequirements(record.name)}
- icon={}
- />
+ {!record.requirements_is_protected_example ? (
+ handleEditRequirements(record.name)}
+ icon={}
+ />
+ ) : null}
+ {!record.requirements_is_protected_example ? (
+ handleDeleteRequirements(record.name)}
+ icon={}
+ />
+ ) : null}
) : (
- openAddRequirements(record.name)}
- icon={}
- />
+ {!record.is_protected_example ? (
+ openAddRequirements(record.name)}
+ icon={}
+ />
+ ) : (
+ Protected
+ )}
),
},
@@ -574,18 +600,20 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
title: 'Actions',
key: 'actions',
width: 240,
- render: (_: any, record: ScriptWithStatus) => (
+ render: (_: unknown, record: ScriptWithStatus) => (
handleDownload(record.name)}
icon={}
/>
- openInEditorFromServer(record.name)}
- icon={}
- />
+ {!record.is_protected_example ? (
+ openInEditorFromServer(record.name)}
+ icon={}
+ />
+ ) : null}
{
@@ -594,17 +622,28 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
}}
icon={}
/>
- handleDelete(record.name)}>
-
- } />
-
-
+ {!record.is_protected_example ? (
+ handleDelete(record.name)}>
+
+ } />
+
+
+ ) : null}
),
},
],
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [],
+ [
+ handleDelete,
+ handleDeleteRequirements,
+ handleDownload,
+ handleDownloadRequirements,
+ handleEditRequirements,
+ isScriptActive,
+ openAddRequirements,
+ openInEditorFromServer,
+ renderStatus,
+ ],
);
const nestedColumns = useMemo(
@@ -621,7 +660,12 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
key: 'qnum',
render: (q: number | null) => (q == null ? '-' : q),
},
- { title: 'Active', dataIndex: 'active', key: 'active', render: (a: boolean) => (a ? 'yes' : 'no') },
+ {
+ title: 'Status',
+ dataIndex: 'active',
+ key: 'active',
+ render: (active: boolean) => renderStatus(active),
+ },
{ title: 'Extra', dataIndex: ['parsed', 'extra'], key: 'extra', render: (e: string | null) => e || '-' },
{
title: 'ExecStart',
@@ -645,7 +689,7 @@ export default function ScriptsManager({ onOpenInEditor }: { onOpenInEditor?: (c
),
},
],
- [handleDisableInstance],
+ [handleDisableInstance, renderStatus],
);
const expandable = useMemo(
diff --git a/frontend/src/types/scripting.ts b/frontend/src/types/scripting.ts
index d3cbb99..78ce97f 100644
--- a/frontend/src/types/scripting.ts
+++ b/frontend/src/types/scripting.ts
@@ -31,6 +31,8 @@ export type StatusForNameResponse = {
export type ScriptWithStatus = ScriptInfo & {
mappings: UnitMapping[];
requirements_exists: boolean;
+ is_protected_example: boolean;
+ requirements_is_protected_example: boolean;
};
export type ScriptUploadResponse = ScriptInfo & {