Skip to content

Commit 9cdbf7f

Browse files
committed
Added restrictions on select and title value
1 parent cb8f8eb commit 9cdbf7f

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/utils/constructNewContents.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ export const constructNewContents = (
2121
color_schema_unit_key: string
2222
) => {
2323
const newContents: string[] = [];
24-
2524
for (const [category, category_info] of categories_map) {
2625
const content = [
2726
`<h3><img height="20px" src="https://img.shields.io/badge/${qs.escape(
2827
category
2928
)}-${ColorMap[category_info.color]}"/></h3>`
3029
];
31-
category_info.items.forEach((item) =>
30+
category_info.items.forEach((item) => {
31+
const title = item.title && item.title[0][0];
32+
if (!title)
33+
throw new Error(`Each row must have value in the Name column`);
3234
content.push(
33-
`<span><img src="https://img.shields.io/badge/-${qs.escape(
34-
item.title[0][0]
35-
)}-${
35+
`<span><img src="https://img.shields.io/badge/-${qs.escape(title)}-${
3636
item[color_schema_unit_key]?.[0][0] ?? 'black'
37-
}?style=flat-square&amp;logo=${qs.escape(item.title[0][0])}" alt="${
38-
item.title[0][0]
39-
}"/></span>`
40-
)
41-
);
37+
}?style=flat-square&amp;logo=${qs.escape(
38+
title
39+
)}" alt="${title}"/></span>`
40+
);
41+
});
4242
newContents.push(...content, '<hr>');
4343
}
4444
return newContents;

src/utils/getSchemaEntries.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ export const getSchemaEntries = (schema: Schema) => {
55
const schema_entries = Object.entries(schema),
66
category_schema_entry = schema_entries.find(
77
([, schema_entry_value]) =>
8-
schema_entry_value.type === 'multi_select' &&
8+
schema_entry_value.type === 'select' &&
99
schema_entry_value.name === 'Category'
1010
) as [string, MultiSelectSchemaUnit],
11+
name_schema_entry = schema_entries.find(
12+
([, schema_entry_value]) =>
13+
schema_entry_value.type === 'title' &&
14+
schema_entry_value.name === 'Name'
15+
) as [string, MultiSelectSchemaUnit],
1116
color_schema_entry = schema_entries.find(
1217
([, schema_entry_value]) =>
1318
schema_entry_value.type === 'text' &&
@@ -22,5 +27,13 @@ export const getSchemaEntries = (schema: Schema) => {
2227
core.setFailed(
2328
"Couldn't find Color named text type column in the database"
2429
);
25-
return [category_schema_entry, color_schema_entry] as const;
30+
if (!name_schema_entry)
31+
core.setFailed(
32+
"Couldn't find Name named title type column in the database"
33+
);
34+
return [
35+
category_schema_entry,
36+
color_schema_entry,
37+
name_schema_entry
38+
] as const;
2639
};

0 commit comments

Comments
 (0)