Skip to content

Commit

Permalink
Merge pull request #32 from adobecom/MWPW-153015-cass-envs
Browse files Browse the repository at this point in the history
MWPW-153015: specify if a card collection should use non-prod CaaS on non-prod domains.
  • Loading branch information
Ben-Zahler authored Jun 20, 2024
2 parents b3ee6a4 + 2b321a8 commit 36c7a99
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class KnowledgeBaseOverview extends PartnerCards {
constructor() {
super();
this.totalPages = 0;
this.useStageCaasEndpoint = true;
}

static styles = [
Expand Down
8 changes: 5 additions & 3 deletions eds/components/PartnerCards.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLibs } from '../scripts/utils.js';
import {getLibs, prodHosts} from '../scripts/utils.js';
import { partnerCardsStyles, newsCardStyles } from './PartnerCardsStyles.js';
const miloLibs = getLibs();
const { html, LitElement, css, repeat } = await import (`${miloLibs}/deps/lit-all.min.js`);
Expand Down Expand Up @@ -75,7 +75,8 @@ export class PartnerCards extends LitElement {
selectedSortOrder: { type: Object },
selectedFilters: { type: Object },
urlSearchParams: { type: Object },
mobileView: { type: Boolean }
mobileView: { type: Boolean },
useStageCaasEndpoint: { type: Boolean }
};

constructor() {
Expand Down Expand Up @@ -200,7 +201,8 @@ export class PartnerCards extends LitElement {

async fetchData() {
try {
const api = new URL('https://www.adobe.com/chimera-api/collection?originSelection=dx-partners&draft=false&debug=true&flatFile=false&expanded=true');
const domain = `${(this.useStageCaasEndpoint && !prodHosts.includes(window.location.host)) ? 'https://14257-chimera-stage.adobeioruntime.net/api/v1/web/chimera-0.0.1' : 'https://www.adobe.com/chimera-api'}`;
const api = new URL(`${domain}/collection?originSelection=dx-partners&draft=false&debug=true&flatFile=false&expanded=true`);
const apiWithParams = this.setApiParams(api);
const response = await fetch(apiWithParams);
if (!response.ok) {
Expand Down
8 changes: 2 additions & 6 deletions eds/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@
* governing permissions and limitations under the License.
*/

import { setLibs } from './utils.js';
import {prodHosts, setLibs} from './utils.js';

// Add project-wide style path here.
const STYLES = '';

// Use 'https://milo.adobe.com/libs' if you cannot map '/libs' to milo's origin.
const LIBS = '/libs';

const prodHosts = [
'main--dx-partners--adobecom.hlx.page',
'main--dx-partners--adobecom.hlx.live',
'partners.adobe.com'
];


const imsClientId = prodHosts.includes(window.location.host) ? 'MILO_PARTNERS_PROD' : 'MILO_PARTNERS_STAGE';

Expand Down
6 changes: 6 additions & 0 deletions eds/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export const [setLibs, getLibs] = (() => {
];
})();

export const prodHosts = [
'main--dx-partners--adobecom.hlx.page',
'main--dx-partners--adobecom.hlx.live',
'partners.adobe.com'
];

/*
* ------------------------------------------------------------
* Edit above at your own risk.
Expand Down

0 comments on commit 36c7a99

Please sign in to comment.