Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: hide icons #18162

Merged
merged 5 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Umbraco.Web.UI.Client/devops/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

const icon = {
name: iconDef.name,
legacy: iconDef.legacy,
legacy: iconDef.legacy, // TODO: Deprecated, remove in v.17.
hidden: iconDef.legacy ?? iconDef.internal,

Check warning on line 50 in src/Umbraco.Web.UI.Client/devops/icons/index.js

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ Getting worse: Complex Method

collectDictionaryIcons already has high cyclomatic complexity, and now it increases in Lines of Code from 73 to 74. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
fileName: iconFileName,
svg,
output: `${iconsOutputDirectory}/${iconFileName}.ts`,
Expand Down Expand Up @@ -137,9 +138,11 @@

// Only append not already defined icons:
if (!icons.find((x) => x.name === iconName)) {
// remove legacy for v.17 (Deprecated)
const icon = {
name: iconName,
legacy: true,
hidden: true,
fileName: iconFileName,
svg,
output: `${iconsOutputDirectory}/${iconFileName}.ts`,
Expand Down Expand Up @@ -172,11 +175,13 @@
const JSPath = `${moduleDirectory}/icons.ts`;

const iconDescriptors = icons.map((icon) => {
// remove legacy for v.17 (Deprecated)
return `{
name: "${icon.name}",
${icon.legacy ? 'legacy: true,' : ''}
${icon.hidden ? 'hidden: true,' : ''}
path: () => import("./icons/${icon.fileName}.js"),
}`.replace(/\t/g, ''); // Regex removes white space [NL]
}`.replace(/\t/g, '').replace(/^\s*[\r\n]/gm, ''); // Regex removes white space [NL] // + regex that removes empty lines. [NL]
});

const content = `export default [${iconDescriptors.join(',')}];`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@
{
"name": "icon-document-dashed-line",
"file": "file.svg",
"missing": "TODO:"
"missing": "TODO: Legacy until se have made a custom",
"legacy": true
},
{
"name": "icon-document",
Expand Down Expand Up @@ -2360,6 +2361,11 @@
},
{
"name": "icon-umb-manifest",
"file": "puzzle.svg",
"internal": true
},
{
"name": "icon-puzzle-piece",
"file": "puzzle.svg"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class UmbIconRegistryContext extends UmbContextBase<UmbIconRegistryContex
#manifestMap = new Map();
#icons = new UmbArrayState<UmbIconDefinition>([], (x) => x.name);
readonly icons = this.#icons.asObservable();
readonly approvedIcons = this.#icons.asObservablePart((icons) => icons.filter((x) => x.legacy !== true));
readonly approvedIcons = this.#icons.asObservablePart((icons) => icons.filter((x) => x.hidden !== true));

constructor(host: UmbControllerHost) {
super(host, UMB_ICON_REGISTRY_CONTEXT);
Expand Down
Loading
Loading