Skip to content

Commit 777c299

Browse files
committed
DEV: add migration of deprecated icon names to svg_icons site setting, also rename setting to lowercase of svg_icons
1 parent 5ade671 commit 777c299

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

migrations/settings/0002-migrate-from-deprecated-icon-names.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
export default function migrate(settings) {
2-
const oldSetting = settings.get("header_links");
2+
const oldHeaderLinksSetting = settings.get("header_links");
33

4-
if (!oldSetting) {
5-
return settings;
4+
if (oldHeaderLinksSetting) {
5+
const newHeaderLinksSetting = oldHeaderLinksSetting.map((link) => {
6+
if (link.icon) {
7+
link.icon = convertIconName(link.icon);
8+
}
9+
return link;
10+
});
11+
12+
settings.set("header_links", newHeaderLinksSetting);
613
}
714

8-
const newSetting = oldSetting.map((link) => {
9-
if (link.icon) {
10-
link.icon = convertIconName(link.icon);
11-
}
12-
return link;
13-
});
15+
const oldSvgIconsSetting = settings.get("Svg_icons");
16+
if (oldSvgIconsSetting) {
17+
const newSvgIconsSetting = oldSvgIconsSetting
18+
.split("|")
19+
.map(convertIconName)
20+
.join("|");
21+
22+
settings.set("svg_icons", newSvgIconsSetting);
23+
}
1424

15-
settings.set("header_links", newSetting);
1625
return settings;
1726
}
1827

settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_whitespace:
22
type: bool
33
default: false
4-
Svg_icons:
4+
svg_icons:
55
type: "list"
66
list_type: "compact"
77
default: "fab-facebook|fab-twitter"

test/unit/migrations/settings/0002-migrate-from-deprecated-icon-names-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module(
3737
target: "blank",
3838
},
3939
],
40+
Svg_icons: "fab-facebook|fab-twitter|fab fa-cog|user-friends",
4041
})
4142
);
4243

@@ -74,6 +75,7 @@ module(
7475
target: "blank",
7576
},
7677
],
78+
svg_icons: "fab-facebook|fab-twitter|fab-gear|user-group",
7779
})
7880
);
7981

0 commit comments

Comments
 (0)