Skip to content

Commit

Permalink
Support custom icons with oldNames
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Sep 9, 2024
1 parent 67c37bf commit a807257
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/survey-core/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,20 @@ function wrapUrlForBackgroundImage(url: string): string {
return !!url ? ["url(", url, ")"].join("") : "";
}

//new-name: old-name
const renamedIcons = {
"folder": "chooseFile"
};

function getIconNameFromProxy(iconName: string): string {
if (!iconName) return iconName;
var proxyName = (<any>settings.customIcons)[iconName];
if(!proxyName) {
const oldName = renamedIcons[iconName];
if(!!oldName) {
proxyName = (<any>settings.customIcons)[oldName];
}
}
return !!proxyName ? proxyName : iconName;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/survey-core/tests/components/actionbartests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ QUnit.test(
}
);

QUnit.test(
"Support old customIcons names in svg, function getIconNameFromProxy",
(assert) => {
settings.customIcons["chooseFile"] = "new-chooseFile";
assert.equal(getIconNameFromProxy("chooseFile"), "new-chooseFile");
assert.equal(getIconNameFromProxy("folder"), "new-chooseFile");
assert.equal(getIconNameFromProxy("folder-new"), "folder-new");
delete settings.customIcons["chooseFile"];
}
);

QUnit.test(
"isVisible",
(assert) => {
Expand Down

0 comments on commit a807257

Please sign in to comment.