Skip to content

Commit 7b41d81

Browse files
committed
Support previous API interface as well
1 parent b1edb9a commit 7b41d81

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

app/routes/machines/components/machine-row.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export default function MachineRow({
7171
</p>
7272
<div className="flex gap-1 flex-wrap mt-1.5">
7373
{mapTagsToComponents(node, uiTags)}
74-
{node.tags.map((tag) => (
74+
{node.validTags?.map((tag) => (
75+
<Chip key={tag} text={tag} />
76+
))}
77+
{node.tags?.map((tag) => (
7578
<Chip key={tag} text={tag} />
7679
))}
7780
</div>

app/routes/machines/dialogs/tags.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function Tags({
2121
setIsOpen,
2222
existingTags,
2323
}: TagsProps) {
24-
const [tags, setTags] = useState(machine.tags);
24+
const [tags, setTags] = useState([...machine.forcedTags, ...machine.tags]);
2525
const [tag, setTag] = useState('tag:');
2626
const tagIsInvalid = useMemo(() => {
2727
return tag.length === 0 || !tag.startsWith('tag:') || tags.includes(tag);

app/routes/machines/machine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function loader({ request, params, context }: Route.LoaderArgs) {
4141
const lookup = await context.agents?.lookup([node.nodeKey]);
4242
const [enhancedNode] = mapNodes([node], lookup);
4343
const tags = Array.from(
44-
new Set([...node.tags]),
44+
new Set([...node.tags, ...node.validTags, ...node.forcedTags]),
4545
).sort();
4646

4747
return {

app/types/Machine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export interface Machine {
2222
| 'REGISTER_METHOD_CLI'
2323
| 'REGISTER_METHOD_OIDC';
2424

25+
forcedTags: string[];
26+
invalidTags: string[];
27+
validTags: string[];
2528
tags: string[];
2629
givenName: string;
2730
online: boolean;

app/utils/node-info.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,20 @@ export function mapNodes(
5454
}
5555

5656
export function sortNodeTags(nodes: Machine[]): string[] {
57-
return Array.from(
58-
new Set(
59-
nodes.flatMap((node) => node.tags),
60-
),
61-
).sort();
57+
try {
58+
return Array.from(
59+
new Set(
60+
nodes.flatMap((node) => node.tags),
61+
),
62+
).sort();
63+
} catch {
64+
return Array.from(
65+
new Set(
66+
nodes.flatMap(({ validTags, forcedTags }) => [
67+
...validTags,
68+
...forcedTags,
69+
]),
70+
),
71+
).sort();
72+
}
6273
}

0 commit comments

Comments
 (0)