Skip to content

Commit

Permalink
fix(hub-sites): ensure that we respect interpolation of site title
Browse files Browse the repository at this point in the history
affects: @esri/hub-sites

For complex reasons we were forcing the site title to be the solution title. We needed to dial back
that logic so static site names can be used.
  • Loading branch information
dbouwman committed Mar 9, 2021
1 parent efbe2c3 commit 188e88c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions packages/sites/src/create-site-model-from-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ export function createSiteModelFromTemplate(
const siteModel = interpolate(template, settings, transforms);
// Special logic for the site title
// if the title is a string, containing only numbers, then the interpolation will set it as
// a number, which causes some problems. So we stamp in the string value in few places it matters
siteModel.item.title = getProp(settings, "solution.title");
siteModel.data.values.title = getProp(settings, "solution.title");
// a number, which causes some problems... in that case, we stomp it in as a string...
if (typeof siteModel.item.title === "number") {
siteModel.item.title = getProp(settings, "solution.title");
siteModel.data.values.title = getProp(settings, "solution.title");
}

// re-attach dcat...
if (dcatConfig) {
siteModel.data.values.dcatConfig = dcatConfig;
Expand Down
8 changes: 4 additions & 4 deletions packages/sites/test/create-site-model-from-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe("createSiteModelFromTemplate", () => {
expect(createdSite.item.extent).toEqual(
settings.organization.defaultExtentBBox
);
expect(createdSite.data.values.title).toBe(settings.solution.title);
expect(createdSite.data.values.title).toBe(settings.solution.name);

expect(createdSite.item.url).toBe(
"https://unique-domain-org.hubqa.arcgis.com"
Expand Down Expand Up @@ -222,7 +222,7 @@ describe("createSiteModelFromTemplate", () => {
expect(createdSite.item.extent).toEqual(
settings.organization.defaultExtentBBox
);
expect(createdSite.data.values.title).toBe(settings.solution.title);
expect(createdSite.data.values.title).toBe(settings.solution.name);

expect(createdSite.item.url).toBe(
"https://unique-domain-org.hubqa.arcgis.com"
Expand Down Expand Up @@ -272,7 +272,7 @@ describe("createSiteModelFromTemplate", () => {
expect(createdSite.item.extent).toEqual(
settings.organization.defaultExtentBBox
);
expect(createdSite.data.values.title).toBe(settings.solution.title);
expect(createdSite.data.values.title).toBe(settings.solution.name);

expect(createdSite.item.url).toBe("http://foobar-portal-baz.com");
expect(createdSite.data.values.defaultHostname).toBe(portalSiteHostname);
Expand Down Expand Up @@ -383,7 +383,7 @@ describe("createSiteModelFromTemplate", () => {

// Verify interpolation
expect(createdSite.item.title).toBe(unicodeSettings.solution.title);
expect(createdSite.data.values.title).toBe(unicodeSettings.solution.title);
expect(createdSite.data.values.title).toBe(unicodeSettings.solution.name);

const passedDomain = ensureDomainSpy.calls.argsFor(0)[0];
expect(passedDomain).toBe(
Expand Down

0 comments on commit 188e88c

Please sign in to comment.