Support previous API interface as well

This commit is contained in:
Paul Kronenwetter
2026-01-23 21:53:30 -05:00
parent c61a9119a7
commit 5777a5f509
5 changed files with 25 additions and 8 deletions
@@ -71,7 +71,10 @@ export default function MachineRow({
</p>
<div className="flex gap-1 flex-wrap mt-1.5">
{mapTagsToComponents(node, uiTags)}
{node.tags.map((tag) => (
{node.validTags?.map((tag) => (
<Chip key={tag} text={tag} />
))}
{node.tags?.map((tag) => (
<Chip key={tag} text={tag} />
))}
</div>
+1 -1
View File
@@ -21,7 +21,7 @@ export default function Tags({
setIsOpen,
existingTags,
}: TagsProps) {
const [tags, setTags] = useState(machine.tags);
const [tags, setTags] = useState([...machine.forcedTags, ...machine.tags]);
const [tag, setTag] = useState('tag:');
const tagIsInvalid = useMemo(() => {
return tag.length === 0 || !tag.startsWith('tag:') || tags.includes(tag);
+1 -1
View File
@@ -41,7 +41,7 @@ export async function loader({ request, params, context }: Route.LoaderArgs) {
const lookup = await context.agents?.lookup([node.nodeKey]);
const [enhancedNode] = mapNodes([node], lookup);
const tags = Array.from(
new Set([...node.tags]),
new Set([...node.tags, ...node.validTags, ...node.forcedTags]),
).sort();
return {
+3
View File
@@ -22,6 +22,9 @@ export interface Machine {
| 'REGISTER_METHOD_CLI'
| 'REGISTER_METHOD_OIDC';
forcedTags: string[];
invalidTags: string[];
validTags: string[];
tags: string[];
givenName: string;
online: boolean;
+16 -5
View File
@@ -54,9 +54,20 @@ export function mapNodes(
}
export function sortNodeTags(nodes: Machine[]): string[] {
return Array.from(
new Set(
nodes.flatMap((node) => node.tags),
),
).sort();
try {
return Array.from(
new Set(
nodes.flatMap((node) => node.tags),
),
).sort();
} catch {
return Array.from(
new Set(
nodes.flatMap(({ validTags, forcedTags }) => [
...validTags,
...forcedTags,
]),
),
).sort();
}
}