diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2db5a1ef..caca6e33 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,4 +75,8 @@ stages: clearFolder: true deployFolder: '' region: us-east-2 - cfDistributionId: $(cfDistributionId) \ No newline at end of file + appDeployVariables: + __VUE_APP_CONSUMER_CF_DISTRO__: $(__VUE_APP_CONSUMER_CF_DISTRO__) + __VUE_APP_CURRENT_ENVIRONMENT__: $(__VUE_APP_CURRENT_ENVIRONMENT__) + cfDistributionId: $(cfDistributionId) + \ No newline at end of file diff --git a/src/helpers/cms-content-helper.js b/src/helpers/cms-content-helper.js index cc9769eb..5dd0c87f 100644 --- a/src/helpers/cms-content-helper.js +++ b/src/helpers/cms-content-helper.js @@ -1,7 +1,8 @@ -import { dynamicStrings } from "../constants/dynamic-strings"; +import { dynamicStrings } from "@/constants/dynamic-strings"; +import { useMainStore } from '@/store'; export function fetchCmsContentForPage(issPage) { - return this.mainStore.getPageData(issPage) + return useMainStore().getPageData(issPage) .then((response) => { const pageDataFromCms = {}; @@ -95,7 +96,7 @@ function mapStringToState(str) { for (const match of globalStateMatches) { // Reset store state for each match. - let storeState = this.mainStore.state; + let storeState = useMainStore().state; for (const s of match[2].split(".")) { if (storeState[s] != undefined) { diff --git a/src/helpers/layout-helper.js b/src/helpers/layout-helper.js new file mode 100644 index 00000000..a7a31119 --- /dev/null +++ b/src/helpers/layout-helper.js @@ -0,0 +1,28 @@ +export function settleAllPromises(promiseResultMap) { + // Pull our keys out of the promise 'table' + const promiseNames = Object.entries(promiseResultMap); + + return Promise.allSettled( + promiseNames.map((e) => e[1]).map((n) => n.promise) + ).then((results) => { + const resultMap = {}; + + // Build a map of the results + for (let i = 0; i < results.length; ++i) { + const promiseName = promiseNames[i][1].resultKey; + + // Some Promises like the cms content call don't have a 'data' field + // when returned, so other promises do. Map the results to the object + // so that the object is the return data. + + if (results[i]?.value?.data === undefined) { + resultMap[promiseName] = results[i]?.value; + } else { + resultMap[promiseName] = results[i]?.value?.data; + } + } + + return resultMap; + }); + } + \ No newline at end of file diff --git a/src/helpers/layout-helper.spec.js b/src/helpers/layout-helper.spec.js new file mode 100644 index 00000000..d7181075 --- /dev/null +++ b/src/helpers/layout-helper.spec.js @@ -0,0 +1,25 @@ +import { settleAllPromises } from "@/helpers/layout-helper"; + +it("layout-helper: Should settle all promises and return mapped promise results", () => { + // Arrange + const mockPromiseOne = Promise.resolve({ data: "test-data" }); + const mockPromiseTwo = Promise.resolve({ data: "test-data-two" }); + + const promiseResultMap = [ + { + resultKey: "MockResultOne", + promise: mockPromiseOne, + }, + { + resultKey: "MockResultTwo", + promise: mockPromiseTwo, + }, + ]; + + // Act + settleAllPromises(promiseResultMap).then((results) => { + // Assert + expect(results.MockResultOne).toEqual("test-data"); + expect(results.MockResultTwo).toEqual("test-data-two"); + }); +}); diff --git a/src/layouts/vehicle-year/vehicle-year.vue b/src/layouts/vehicle-year/vehicle-year.vue index e5d0c243..e8fcbdfb 100644 --- a/src/layouts/vehicle-year/vehicle-year.vue +++ b/src/layouts/vehicle-year/vehicle-year.vue @@ -12,10 +12,30 @@