diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.github/workflows/run-nala.yml b/.github/workflows/run-nala.yml index 03dcbb7..960fc1e 100644 --- a/.github/workflows/run-nala.yml +++ b/.github/workflows/run-nala.yml @@ -24,3 +24,4 @@ jobs: prRepo: ${{ github.event.pull_request.head.repo.name }} prBranch: ${{ github.event.pull_request.head.ref }} prBaseBranch: ${{ github.event.pull_request.base.ref }} + HLX_API_KEY: ${{ secrets.HLX_API_KEY }} diff --git a/eds/blocks/knowledge-base-overview/KnowledgeBaseOverview.js b/eds/blocks/knowledge-base-overview/KnowledgeBaseOverview.js index ec82dfa..f5305ca 100644 --- a/eds/blocks/knowledge-base-overview/KnowledgeBaseOverview.js +++ b/eds/blocks/knowledge-base-overview/KnowledgeBaseOverview.js @@ -1,93 +1,3 @@ -import { getLibs } from '../../scripts/utils.js'; -import { numericPaginationStyles } from '../../components/PartnerCardsStyles.js'; import PartnerCardsWithDateFilter from '../../components/PartnerCardsWithDateFilter.js'; -const miloLibs = getLibs(); -const { html, css, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`); - -export default class KnowledgeBaseOverview extends PartnerCardsWithDateFilter { - static properties = { - ...PartnerCardsWithDateFilter.properties, - totalPages: { type: Number }, - }; - - constructor() { - super(); - this.totalPages = 0; - this.useStageCaasEndpoint = true; - } - - static styles = [ - PartnerCardsWithDateFilter.styles, - css`${numericPaginationStyles}`, - ]; - - get paginationList() { - if (!this.cards.length) return; - - const min = 1; - this.totalPages = Math.ceil(this.cards.length / this.cardsPerPage); - - const pagesNumArray = Array.from({ length: this.totalPages }, (_, i) => i + min); - return html`${repeat( - pagesNumArray, - (pageNum) => pageNum, - (pageNum) => html``, - )}`; - } - - get pagination() { - return html` -
- - ${this.paginationList} - -
- `; - } - - get cardsCounter() { - const lastElOrderNum = super.cardsCounter; - const { orderNum: firstElOrderNum } = this.paginatedCards[0]; - return `${firstElOrderNum} - ${lastElOrderNum}`; - } - - handleActions() { - super.handleActions(); - this.updatePaginatedCards(); - } - - updatePaginatedCards() { - const startIndex = (this.paginationCounter - 1) * this.cardsPerPage; - const endIndex = this.paginationCounter * this.cardsPerPage; - this.paginatedCards = this.cards.slice(startIndex, endIndex); - } - - handlePageNum(pageNum) { - if (this.paginationCounter !== pageNum) { - this.paginationCounter = pageNum; - this.handleActions(); - } - } - - handlePrevPage() { - if (this.paginationCounter > 1) { - this.paginationCounter -= 1; - this.handleActions(); - } - } - - handleNextPage() { - if (this.paginationCounter < this.totalPages) { - this.paginationCounter += 1; - this.handleActions(); - } - } -} +export default class KnowledgeBaseOverview extends PartnerCardsWithDateFilter {} diff --git a/eds/blocks/knowledge-base-overview/knowledge-base-overview.js b/eds/blocks/knowledge-base-overview/knowledge-base-overview.js index 240bd68..6a95a5a 100644 --- a/eds/blocks/knowledge-base-overview/knowledge-base-overview.js +++ b/eds/blocks/knowledge-base-overview/knowledge-base-overview.js @@ -1,4 +1,5 @@ -import { getLibs, replaceText, getConfig, populateLocalizedTextFromListItems } from '../../scripts/utils.js'; +import { getCaasUrl, getLibs } from '../../scripts/utils.js'; +import { replaceText, getConfig, populateLocalizedTextFromListItems } from '../utils/utils.js'; import KnowledgeBaseOverview from './KnowledgeBaseOverview.js'; function declareKnowledgeBaseOverview() { @@ -33,6 +34,7 @@ export default async function init(el) { '{{last-6-months}}': 'Last 6 months', '{{next}}': 'Next', '{{next-page}}': 'Next Page', + '{{load-more}}': 'Load more', '{{no-results-description}}': 'Try checking your spelling or broadening your search.', '{{no-results-title}}': 'No Results Found', '{{of}}': 'Of', @@ -69,13 +71,20 @@ export default async function init(el) { ], }; + const block = { + el, + name: 'knowledge-base-overview', + collectionTag: '"caas:adobe-partners/collections/knowledge-base"', + ietf: config.locale.ietf + } + const blockData = { localizedText, tableData: el.children, dateFilter, cardsPerPage: 12, - ietf: config.locale.ietf, - collectionTags: '"caas:adobe-partners/collections/knowledge-base"', + pagination: 'default', + caasUrl: getCaasUrl(block) }; const app = document.createElement('knowledge-base-overview'); diff --git a/eds/blocks/partner-news/PartnerNews.js b/eds/blocks/partner-news/PartnerNews.js index e2a11e5..e9fb6d0 100644 --- a/eds/blocks/partner-news/PartnerNews.js +++ b/eds/blocks/partner-news/PartnerNews.js @@ -1,35 +1,3 @@ -import { getLibs } from '../../scripts/utils.js'; -import { loadMorePaginationStyles } from '../../components/PartnerCardsStyles.js'; import PartnerCardsWithDateFilter from '../../components/PartnerCardsWithDateFilter.js'; -const miloLibs = getLibs(); -const { html, css } = await import(`${miloLibs}/deps/lit-all.min.js`); - -export default class PartnerNews extends PartnerCardsWithDateFilter { - static styles = [ - PartnerCardsWithDateFilter.styles, - css`${loadMorePaginationStyles}`, - ]; - - get pagination() { - if (this.cards.length === this.paginatedCards.length) { - return ''; - } - return html``; - } - - handleActions() { - super.handleActions(); - this.updatePaginatedCards(); - } - - updatePaginatedCards() { - const countPages = this.paginationCounter * this.cardsPerPage; - this.paginatedCards = this.cards.slice(0, countPages); - } - - handleLoadMore() { - this.paginationCounter += 1; - this.handleActions(); - } -} +export default class PartnerNews extends PartnerCardsWithDateFilter {} diff --git a/eds/blocks/partner-news/partner-news.js b/eds/blocks/partner-news/partner-news.js index 05e2f61..c9a55f7 100644 --- a/eds/blocks/partner-news/partner-news.js +++ b/eds/blocks/partner-news/partner-news.js @@ -1,4 +1,5 @@ -import { getLibs, replaceText, getConfig, populateLocalizedTextFromListItems } from '../../scripts/utils.js'; +import { getCaasUrl, getLibs } from '../../scripts/utils.js'; +import { replaceText, getConfig, populateLocalizedTextFromListItems } from '../utils/utils.js'; import PartnerNews from './PartnerNews.js'; function declarePartnerNews() { @@ -32,10 +33,15 @@ export default async function init(el) { '{{filters}}': 'Filters', '{{last-90-days}}': 'Last 90 days', '{{load-more}}': 'Load more', + '{{next}}': 'Next', + '{{next-page}}': 'Next Page', '{{no-results-description}}': 'Try checking your spelling or broadening your search.', '{{no-results-title}}': 'No Results Found', '{{of}}': 'Of', + '{{page}}': 'Page', + '{{prev}}': 'Prev', '{{previous-month}}': 'Previous month', + '{{previous-page}}': 'Previous Page', '{{results}}': 'Results', '{{search}}': 'Search', '{{show-all}}': 'Show all', @@ -65,13 +71,20 @@ export default async function init(el) { ], }; + const block = { + el, + name: 'partner-news', + collectionTag: '"caas:adobe-partners/collections/news"', + ietf: config.locale.ietf + } + const blockData = { localizedText, tableData: el.children, dateFilter, cardsPerPage: 12, - ietf: config.locale.ietf, - collectionTags: '"caas:adobe-partners/collections/news"', + pagination: 'load-more', + caasUrl: getCaasUrl(block) }; const app = document.createElement('partner-news'); diff --git a/eds/blocks/utils/utils.js b/eds/blocks/utils/utils.js new file mode 100644 index 0000000..2c2c0f5 --- /dev/null +++ b/eds/blocks/utils/utils.js @@ -0,0 +1,20 @@ +import { setLibs } from '../../scripts/utils.js'; + +const miloLibs = setLibs('/libs'); + +const { createTag, localizeLink, getConfig } = await import(`${miloLibs}/utils/utils.js`); + +export { createTag, localizeLink, getConfig }; +const { replaceText } = await import(`${miloLibs}/features/placeholders.js`); +export { replaceText }; + +export function populateLocalizedTextFromListItems(el, localizedText) { + const liList = Array.from(el.querySelectorAll('li')); + liList.forEach((liEl) => { + const liInnerText = liEl.innerText; + if (!liInnerText) return; + let liContent = liInnerText.trim().toLowerCase().replace(/ /g, '-'); + if (liContent.endsWith('_default')) liContent = liContent.slice(0, -8); + localizedText[`{{${liContent}}}`] = liContent; + }); +} diff --git a/eds/components/NewsCard.js b/eds/components/NewsCard.js deleted file mode 100644 index 362fe88..0000000 --- a/eds/components/NewsCard.js +++ /dev/null @@ -1,44 +0,0 @@ -import { newsCardStyles } from './PartnerCardsStyles.js'; -import { formatDate, getLibs } from '../scripts/utils.js'; - -const miloLibs = getLibs(); -const { html, LitElement } = await import(`${miloLibs}/deps/lit-all.min.js`); - -class NewsCard extends LitElement { - static properties = { data: { type: Object } }; - - static styles = newsCardStyles; - - transformCardUrl(url) { - if (!url) { - console.error('URL is null or undefined'); - return ''; - } - if (window.location.host === 'partners.adobe.com') { - return url; - } - const newUrl = new URL(url); - newUrl.protocol = window.location.protocol; - newUrl.host = window.location.host; - return newUrl; - } - - render() { - return html` -
-
-
-
-

${this.data.contentArea?.title !== 'card-metadata' ? this.data.contentArea?.title : ''}

-

${this.data.contentArea?.description}

-
- -
-
- `; - } -} -customElements.define('news-card', NewsCard); diff --git a/eds/components/PartnerCards.js b/eds/components/PartnerCards.js index 0488c8f..a7c3c69 100644 --- a/eds/components/PartnerCards.js +++ b/eds/components/PartnerCards.js @@ -1,17 +1,27 @@ -import { getLibs, prodHosts } from '../scripts/utils.js'; -import { partnerCardsStyles } from './PartnerCardsStyles.js'; -import './NewsCard.js'; +import { + getLibs, +} from '../scripts/utils.js'; +import { + partnerCardsStyles, + partnerCardsLoadMoreStyles, + partnerCardsPaginationStyles, +} from './PartnerCardsStyles.js'; +import './SinglePartnerCard.js'; const miloLibs = getLibs(); const { html, LitElement, css, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`); export default class PartnerCards extends LitElement { - static styles = css` - ${partnerCardsStyles} - #search { + static caasUrl; + + static styles = [ + partnerCardsStyles, + partnerCardsLoadMoreStyles, + partnerCardsPaginationStyles, + css`#search { width: 100%; - } - `; + }`, + ]; static properties = { blockData: { type: Object }, @@ -19,11 +29,12 @@ export default class PartnerCards extends LitElement { paginatedCards: { type: Array }, searchTerm: { type: String }, paginationCounter: { type: Number }, + totalPages: { type: Number }, selectedSortOrder: { type: Object }, selectedFilters: { type: Object }, urlSearchParams: { type: Object }, mobileView: { type: Boolean }, - useStageCaasEndpoint: { type: Boolean }, + fetchedData: { type: Boolean }, }; constructor() { @@ -33,12 +44,13 @@ export default class PartnerCards extends LitElement { this.paginatedCards = []; this.searchTerm = ''; this.paginationCounter = 1; + this.totalPages = 0; this.cardsPerPage = 12; this.selectedSortOrder = {}; this.selectedFilters = {}; this.urlSearchParams = {}; - this.collectionTags = []; - this.hasResponseData = false; + this.hasResponseData = true; + this.fetchedData = false; this.mobileView = window.innerWidth <= 1200; this.updateView = this.updateView.bind(this); } @@ -58,12 +70,8 @@ export default class PartnerCards extends LitElement { default: {}, items: [], }, - language: '', - country: '', }; - this.collectionTags = [this.blockData.collectionTags]; - const blockDataActions = { title: (cols) => { const [titleEl] = cols; @@ -72,7 +80,12 @@ export default class PartnerCards extends LitElement { filter: (cols) => { const [filterKeyEl, filterTagsKeysEl] = cols; const filterKey = filterKeyEl.innerText.trim().toLowerCase().replace(/ /g, '-'); - const filterTagsKeys = Array.from(filterTagsKeysEl.querySelectorAll('li'), (li) => li.innerText.trim().toLowerCase().replace(/ /g, '-')); + + const filterTagsKeys = []; + filterTagsKeysEl.querySelectorAll('li').forEach((li) => { + const key = li.innerText.trim().toLowerCase().replace(/ /g, '-'); + if (key !== '') filterTagsKeys.push(key); + }); if (!filterKey || !filterTagsKeys.length) return; @@ -90,7 +103,14 @@ export default class PartnerCards extends LitElement { }, sort: (cols) => { const [sortKeysEl] = cols; - const sortKeys = Array.from(sortKeysEl.querySelectorAll('li'), (li) => li.innerText.trim().toLowerCase().replace(/ /g, '-')); + + const sortKeys = []; + sortKeysEl.querySelectorAll('li').forEach((li) => { + const key = li.innerText.trim().toLowerCase().replace(/ /g, '-'); + if (key !== '') sortKeys.push(key); + }); + + if (!sortKeys.length) return; const sortItems = sortKeys.map((sortKey) => { const key = sortKey.endsWith('_default') ? sortKey.slice(0, -8) : sortKey; @@ -98,9 +118,11 @@ export default class PartnerCards extends LitElement { return { key, value }; }); - const defaultKey = sortKeys.find((key) => key.endsWith('_default')).slice(0, -8) || sortKeys[0]; - const defaultValue = sortItems.find((e) => e.key === defaultKey).value; - this.blockData.sort = { items: sortItems, default: { key: defaultKey, value: defaultValue } }; + const defaultKey = sortKeys.find((key) => key.endsWith('_default')); + const finalDefaultKey = defaultKey ? defaultKey.slice(0, -8) : sortKeys[0]; + const defaultValue = sortItems.find((e) => e.key === finalDefaultKey).value; + // eslint-disable-next-line max-len + this.blockData.sort = { items: sortItems, default: { key: finalDefaultKey, value: defaultValue } }; }, 'cards-per-page': (cols) => { const [cardsPerPageEl] = cols; @@ -108,10 +130,10 @@ export default class PartnerCards extends LitElement { const cardsPerPageNum = parseInt(cardsPerPageStr, 10); if (cardsPerPageNum) this.blockData.cardsPerPage = cardsPerPageNum; }, - 'collection-tags': (cols) => { - const [collectionTagsEl] = cols; - const collectionTags = Array.from(collectionTagsEl.querySelectorAll('li'), (li) => `"${li.innerText.trim().toLowerCase()}"`); - this.collectionTags = [...this.collectionTags, ...collectionTags]; + pagination: (cols) => { + const [paginationEl] = cols; + const paginationType = paginationEl.innerText.trim(); + if (paginationType) this.blockData.pagination = paginationType.toLowerCase().replace(/ /g, '-'); }, }; @@ -122,10 +144,6 @@ export default class PartnerCards extends LitElement { const colsContent = cols.slice(1); if (blockDataActions[rowTitle]) blockDataActions[rowTitle](colsContent); }); - - const [language, country] = this.blockData.ietf.split('-'); - this.blockData.language = language; - this.blockData.country = country; } updateView() { @@ -142,22 +160,30 @@ export default class PartnerCards extends LitElement { this.handleActions(); } + // eslint-disable-next-line class-methods-use-this additionalFirstUpdated() {} async fetchData() { try { - 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); + let apiData; + + setTimeout(() => { + this.hasResponseData = !!apiData?.cards; + this.fetchedData = true; + }, 5); + + const response = await fetch(this.blockData.caasUrl); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } - const apiData = await response.json(); + apiData = await response.json(); + const cardsEvent = new Event('partner-cards-loaded'); + document.dispatchEvent(cardsEvent); if (apiData?.cards) { if (window.location.hostname === 'partners.adobe.com') { apiData.cards = apiData.cards.filter((card) => !card.contentArea.url?.includes('/drafts/')); } + // eslint-disable-next-line no-return-assign apiData.cards.forEach((card, index) => card.orderNum = index + 1); this.allCards = apiData.cards; this.cards = apiData.cards; @@ -169,67 +195,8 @@ export default class PartnerCards extends LitElement { } } - setApiParams(api) { - const complexQueryParams = this.getComplexQueryParams(); - if (complexQueryParams) api.searchParams.set('complexQuery', complexQueryParams); - - const { language, country } = this.blockData; - if (language && country) { - api.searchParams.set('language', language); - api.searchParams.set('country', country); - } - - return api.toString(); - } - - getComplexQueryParams() { - const portal = this.getProgramType(window.location.pathname); - let partnerLevelParams; - - if (portal) { - const portalCollectionTag = `"caas:adobe-partners/${portal}"`; - if (!this.collectionTags.length || !this.collectionTags.includes(portalCollectionTag)) { - this.collectionTags = [...this.collectionTags, portalCollectionTag]; - } - - partnerLevelParams = this.getPartnerLevelParams(portal); - } - - if (!this.collectionTags.length) return; - - const collectionTagsStr = this.collectionTags.filter((e) => e.length).join('+AND+'); - return partnerLevelParams ? `((${collectionTagsStr}))+AND+${partnerLevelParams}` : `((${collectionTagsStr}))`; - } - - getPartnerLevelParams(portal) { - try { - const publicTag = `(("caas:adobe-partners/${portal}/partner-level/public"))`; - const cookies = document.cookie.split(';').map((cookie) => cookie.trim()); - const partnerDataCookie = cookies.find((cookie) => cookie.startsWith('partner_data=')); - if (!partnerDataCookie) return publicTag; - - const cookieValue = JSON.parse(decodeURIComponent(partnerDataCookie.substring(('partner_data=').length).toLowerCase())); - if (cookieValue && cookieValue[portal]) { - const cookieLevel = cookieValue[portal].level; - if (cookieLevel) return `(("caas:adobe-partners/${portal}/partner-level/${cookieLevel}")+OR+("caas:adobe-partners/${portal}/partner-level/public"))`; - } - return publicTag; - } catch (error) { - console.error('Error parsing partner data object:', error); - return ''; - } - } - - getProgramType(path) { - switch (true) { - case /solutionpartners/.test(path): return 'spp'; - case /technologypartners/.test(path): return 'tpp'; - case /channelpartners/.test(path): return 'cpp'; - default: return ''; - } - } - initUrlSearchParams() { + // eslint-disable-next-line no-restricted-globals const { search } = location || window.location; this.urlSearchParams = new URLSearchParams(search); @@ -259,9 +226,11 @@ export default class PartnerCards extends LitElement { return html`${repeat( this.paginatedCards, (card) => card.id, - (card) => html``, + (card) => html``, )}`; } + + // eslint-disable-next-line getter-return consistent-return return html`
${this.blockData.localizedText['{{no-results-title}}']}

${this.blockData.localizedText['{{no-results-description}}']}

@@ -271,6 +240,7 @@ export default class PartnerCards extends LitElement { get sortItems() { if (!this.blockData.sort.items.length) return; + // eslint-disable-next-line consistent-return return html`${repeat( this.blockData.sort.items, (item) => item.key, @@ -283,21 +253,65 @@ export default class PartnerCards extends LitElement { )}`; } - get pagination() {} + // eslint-disable-next-line class-methods-use-this,no-empty-function,getter-return + get pagination() { + if (this.blockData.pagination === 'load-more') return this.loadMorePagination; + return this.defaultPagination; + } + + get loadMorePagination() { + if (this.cards.length === this.paginatedCards.length) return ''; + return html``; + } + + get defaultPagination() { + return html` +
+ + ${this.paginationList} + +
+ `; + } + + get paginationList() { + if (!this.cards.length) return; + + const min = 1; + this.totalPages = Math.ceil(this.cards.length / this.cardsPerPage); + + const pagesNumArray = Array.from({ length: this.totalPages }, (_, i) => i + min); + // eslint-disable-next-line consistent-return + return html`${repeat( + pagesNumArray, + (pageNum) => pageNum, + (pageNum) => html``, + )}`; + } get cardsCounter() { - if (!this.paginatedCards.length) { - return 0; - } + const { length } = this.paginatedCards; + if (!length) return 0; - const lastIndex = this.paginatedCards.length - 1; - const { orderNum: lastElOrderNum } = this.paginatedCards[lastIndex]; - return lastElOrderNum; + const { orderNum: lastElOrderNum } = this.paginatedCards[length - 1]; + + if (this.blockData.pagination === 'load-more') return lastElOrderNum; + + const { orderNum: firstElOrderNum } = this.paginatedCards[0]; + return `${firstElOrderNum} - ${lastElOrderNum}`; } get filters() { if (!this.blockData.filters.length) return; + // eslint-disable-next-line consistent-return return html`${repeat( this.blockData.filters, (filter) => filter.key, @@ -309,7 +323,7 @@ export default class PartnerCards extends LitElement {
`; + /* eslint-enable indent */ }, )}`; } @@ -389,6 +406,7 @@ export default class PartnerCards extends LitElement { `, )}`; + // eslint-disable-next-line consistent-return return { htmlContent, tagsCount: extractedTags.length }; } @@ -413,6 +431,7 @@ export default class PartnerCards extends LitElement { element.classList.toggle('expanded'); } + // eslint-disable-next-line class-methods-use-this toggleFilter(clickedFilter) { clickedFilter.classList.toggle('expanded'); } @@ -432,28 +451,33 @@ export default class PartnerCards extends LitElement { if (this.blockData.sort.items.length) this.handleSortAction(); if (this.blockData.filters.length) this.handleFilterAction(); this.additionalActions(); + // eslint-disable-next-line no-return-assign this.cards.forEach((card, index) => card.orderNum = index + 1); + this.updatePaginatedCards(); } + // eslint-disable-next-line class-methods-use-this additionalActions() {} handleResetActions() { this.searchTerm = ''; this.selectedFilters = {}; this.blockData.filters.forEach((filter) => { + // eslint-disable-next-line no-return-assign filter.tags.forEach((tag) => tag.checked = false); this.urlSearchParams.delete(filter.key); }); - this.urlSearchParams.delete('filters'); this.additionalResetActions(); this.paginationCounter = 1; this.handleActions(); - this.handleUrlSearchParams(); + if (this.blockData.filters.length) this.handleUrlSearchParams(); } + // eslint-disable-next-line class-methods-use-this additionalResetActions() {} handleSearchAction() { + // eslint-disable-next-line max-len this.cards = this.allCards.filter((card) => card.contentArea?.title.toLowerCase().includes(this.searchTerm) || card.contentArea?.description.toLowerCase().includes(this.searchTerm)); } @@ -496,10 +520,13 @@ export default class PartnerCards extends LitElement { if ('id' in firstObj && 'version' in firstObj) { cardArbitraryArr = cardArbitraryArr.slice(1); } + // eslint-disable-next-line consistent-return return selectedFiltersKeys.every((key) => cardArbitraryArr.some((arbitraryTag) => { + if (!arbitraryTag.value || !arbitraryTag.key) return false; const arbitraryTagKeyStr = arbitraryTag.key.trim().toLowerCase().replaceAll(' ', '-'); const arbitraryTagValueStr = arbitraryTag.value.trim().toLowerCase().replaceAll(' ', '-'); if (key === arbitraryTagKeyStr) { + // eslint-disable-next-line max-len return this.selectedFilters[key].some((selectedTag) => selectedTag.key === arbitraryTagValueStr); } return false; @@ -562,6 +589,7 @@ export default class PartnerCards extends LitElement { tag.checked = false; const { key: tagKey, parentKey: filterKey } = tag; + // eslint-disable-next-line max-len const updatedFilterTags = [...this.selectedFilters[filterKey]].filter((filterTag) => filterTag.key !== tagKey); if (updatedFilterTags.length) { @@ -591,6 +619,7 @@ export default class PartnerCards extends LitElement { this.blockData.filters.forEach((filter) => { if (filter.key === filterKey) { + // eslint-disable-next-line no-return-assign filter.tags.forEach((tag) => tag.checked = false); } }); @@ -615,13 +644,48 @@ export default class PartnerCards extends LitElement { }; } + updatePaginatedCards() { + const endIndex = this.paginationCounter * this.cardsPerPage; + const startIndex = this.blockData.pagination === 'load-more' ? 0 : (this.paginationCounter - 1) * this.cardsPerPage; + this.paginatedCards = this.cards.slice(startIndex, endIndex); + } + + handleLoadMore() { + this.paginationCounter += 1; + this.handleActions(); + } + + handlePageNum(pageNum) { + if (this.paginationCounter !== pageNum) { + this.paginationCounter = pageNum; + this.handleActions(); + } + } + + handlePrevPage() { + if (this.paginationCounter > 1) { + this.paginationCounter -= 1; + this.handleActions(); + } + } + + handleNextPage() { + if (this.paginationCounter < this.totalPages) { + this.paginationCounter += 1; + this.handleActions(); + } + } + disconnectedCallback() { super.disconnectedCallback(); window.removeEventListener('resize', this.updateView); } + /* eslint-disable indent */ render() { return html` + ${this.fetchedData + ? html`
@@ -653,25 +717,23 @@ export default class PartnerCards extends LitElement {
${this.mobileView - ? html ` + ? html` ` : '' } - ${this.blockData.sort.items.length - ? html `
+ ${this.blockData.sort.items.length + ? html`
${this.sortItems} @@ -695,7 +757,7 @@ export default class PartnerCards extends LitElement {
${this.cards.length ? html` -
+
${this.pagination} ${this.cardsCounter} ${this.blockData.localizedText['{{of}}']} ${this.cards.length} ${this.blockData.localizedText['{{results}}']}
@@ -703,10 +765,10 @@ export default class PartnerCards extends LitElement { : '' }
-
+
` : ''} - ${this.mobileView - ? html ` + ${this.mobileView && this.fetchedData + ? html`
@@ -730,4 +792,5 @@ export default class PartnerCards extends LitElement { } `; } + /* eslint-enable indent */ } diff --git a/eds/components/PartnerCardsStyles.js b/eds/components/PartnerCardsStyles.js index 4762dd7..d6b5790 100644 --- a/eds/components/PartnerCardsStyles.js +++ b/eds/components/PartnerCardsStyles.js @@ -436,7 +436,7 @@ export const partnerCardsStyles = css` display: block; right: 0; top: 30px; - z-index: 10; + z-index: 1; background-color: #fff; border-radius: 5px; border: 1px solid #eaeaea; @@ -537,66 +537,7 @@ export const partnerCardsStyles = css` .pagination-wrapper > * { padding: 5px 0; } - - .pagination-wrapper .pagination-pages-list button { - border: none; - background-color: transparent; - } - - .pagination-wrapper .page-btn { - position: relative; - min-width: 32px; - min-height: 32px; - max-width: 70px; - padding: 8px 10px; - font-size: .875rem; - line-height: .875rem; - color: #4b4b4b; - word-break: break-word; - text-align: center; - white-space: nowrap; - text-overflow: ellipsis; - border-radius: 16px; - overflow: hidden; - } - - .pagination-wrapper .pagination-prev-btn { - padding-right: 10px; - font-weight: 700; - } - - .pagination-wrapper .pagination-next-btn { - padding-left: 10px; - font-weight: 700; - } - - .pagination-wrapper .pagination-prev-btn:hover, - .pagination-wrapper .pagination-next-btn:hover, - .pagination-wrapper .page-btn:hover { - cursor: pointer; - text-decoration: underline; - transition: all .3s; - } - - .pagination-wrapper .pagination-prev-btn.disabled, - .pagination-wrapper .pagination-prev-btn.disabled:hover, - .pagination-wrapper .pagination-next-btn.disabled, - .pagination-wrapper .pagination-next-btn.disabled:hover, - .pagination-wrapper .page-btn.selected:hover { - text-decoration: none; - cursor: default; - } - - .pagination-wrapper .pagination-prev-btn.disabled, - .pagination-wrapper .pagination-next-btn.disabled { - color: #9d9d9d; - } - - .pagination-wrapper .page-btn.selected { - background-color: #e5e5e5; - border-radius: 50%; - } - + .pagination-wrapper .pagination-total-results { font-weight: 700; text-transform: lowercase; @@ -616,7 +557,7 @@ export const partnerCardsStyles = css` @media screen and (max-width: 1200px) { .all-filters-wrapper-mobile.open { position: fixed; - z-index: 10; + z-index: 10000000; display: flex; flex-direction: column; width: 100%; @@ -897,13 +838,149 @@ export const partnerCardsStyles = css` } `; -export const newsCardStyles = css` +export const partnerCardsLoadMoreStyles = css` + .pagination-wrapper.pagination-wrapper-load-more { + justify-content: center; + flex-direction: column-reverse; + } + + .pagination-wrapper-load-more .load-more-btn { + display: flex; + justify-content: center; + align-items: center; + font-size: .875rem; + line-height: 1.063rem; + font-weight: 700; + min-width: 60px; + max-width: 100%; + height: 32px; + max-height: 32px; + padding-left: 14px; + padding-right: 14px; + color: #222222; + border: 2px solid #222222; + border-radius: 16px; + background-color: #ffffff00; + cursor: pointer; + transition: border-color .3s ease-in-out,background-color .3s ease-in-out; + } + + .pagination-wrapper-load-more .load-more-btn:hover { + text-decoration: none; + border-color: #222222; + background-color: #222222; + color: #ffffff; + } +`; + +export const partnerCardsPaginationStyles = css` + .pagination-wrapper.pagination-wrapper-default { + flex-wrap: wrap; + justify-content: space-between; + } + + @media screen and (max-width: 1200px) { + .pagination-wrapper.pagination-wrapper-default { + justify-content: center; + } + } + + .pagination-wrapper-default .pagination-pages-list button { + border: none; + background-color: transparent; + } + + .pagination-wrapper-default .page-btn { + position: relative; + min-width: 32px; + min-height: 32px; + max-width: 70px; + padding: 8px 10px; + font-size: .875rem; + line-height: .875rem; + color: #4b4b4b; + word-break: break-word; + text-align: center; + white-space: nowrap; + text-overflow: ellipsis; + border-radius: 16px; + overflow: hidden; + } + + .pagination-wrapper-default .pagination-prev-btn { + padding-right: 10px; + font-weight: 700; + } + + .pagination-wrapper-default .pagination-next-btn { + padding-left: 10px; + font-weight: 700; + } + + .pagination-wrapper-default .pagination-prev-btn:hover, + .pagination-wrapper-default .pagination-next-btn:hover, + .pagination-wrapper-default .page-btn:hover { + cursor: pointer; + text-decoration: underline; + transition: all .3s; + } + + .pagination-wrapper-default .pagination-prev-btn.disabled, + .pagination-wrapper-default .pagination-prev-btn.disabled:hover, + .pagination-wrapper-default .pagination-next-btn.disabled, + .pagination-wrapper-default .pagination-next-btn.disabled:hover, + .pagination-wrapper-default .page-btn.selected:hover { + text-decoration: none; + cursor: default; + } + + .pagination-wrapper-default .pagination-prev-btn.disabled, + .pagination-wrapper-default .pagination-next-btn.disabled { + color: #9d9d9d; + } + + .pagination-wrapper-default .page-btn.selected { + background-color: #e5e5e5; + border-radius: 50%; + } +`; + +export const partnerCardsDateFilterStyles = css` + .date-filter-tag { + background-color: transparent; + border: none; + padding: 0 6px; + height: 32px; + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; + cursor: pointer; + } + + .date-filter-tag-label { + width: calc(100% - 12px); + font-size: .875rem; + line-height: 1.3; + text-align: left; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + } + + .date-filter-tag-checkmark { + color: ${blueColor}; + width: 12px; + height: 12px; + } +`; - .news-card * { +export const singlePartnerCardStyles = css` + .single-partner-card * { box-sizing: border-box; } - .news-card { + .single-partner-card { display: flex; flex-direction: column; background-color: #fff; @@ -914,12 +991,12 @@ export const newsCardStyles = css` height: 400px; } - .news-card:hover { + .single-partner-card:hover { box-shadow: 0 3px 6px 0 rgba(0,0,0,.16); transition: box-shadow .3s ease-in-out; } - .news-card .card-header { + .single-partner-card .card-header { min-height: 192px; max-height: 192px; background-color: #323232; @@ -931,11 +1008,11 @@ export const newsCardStyles = css` position: relative; } - .news-card:hover .card-header:after { + .single-partner-card:hover .card-header:after { opacity: 1; } - .news-card .card-header:after { + .single-partner-card .card-header:after { position: absolute; content: ""; top: 0; @@ -949,7 +1026,7 @@ export const newsCardStyles = css` transition: opacity .3s ease-in-out; } - .news-card .card-content { + .single-partner-card .card-content { display: flex; flex-direction: column; justify-content: space-between; @@ -958,7 +1035,7 @@ export const newsCardStyles = css` height: 100%; } - .news-card .card-title { + .single-partner-card .card-title { color: #323232; font-size: 1.125rem; font-weight: 700; @@ -972,7 +1049,7 @@ export const newsCardStyles = css` -webkit-line-clamp: 2; } - .news-card .card-description { + .single-partner-card .card-description { color: #505050; font-size: .875rem; line-height: 1.3125rem; @@ -986,13 +1063,13 @@ export const newsCardStyles = css` -webkit-line-clamp: 3; } - .news-card .card-footer { + .single-partner-card .card-footer { display: flex; justify-content: space-between; align-items: center; } - .news-card .card-btn { + .single-partner-card .card-btn { display: flex; justify-content: center; align-items: center; @@ -1015,14 +1092,14 @@ export const newsCardStyles = css` transition: border-color .3s ease-in-out,background-color .3s ease-in-out; } - .news-card .card-btn:hover { + .single-partner-card .card-btn:hover { text-decoration: none; border-color: #222222; background-color: #222222; color: #ffffff; } - .news-card .card-date { + .single-partner-card .card-date { color: #747474; font-size: .875rem; line-height: 1.3125rem; @@ -1031,81 +1108,3 @@ export const newsCardStyles = css` padding: 0; } `; - -export const loadMorePaginationStyles = css` - .pagination-wrapper { - justify-content: center; - flex-direction: column-reverse; - } - - .pagination-wrapper .load-more-btn { - display: flex; - justify-content: center; - align-items: center; - font-size: .875rem; - line-height: 1.063rem; - font-weight: 700; - min-width: 60px; - max-width: 100%; - height: 32px; - max-height: 32px; - padding-left: 14px; - padding-right: 14px; - color: #222222; - border: 2px solid #222222; - border-radius: 16px; - background-color: #ffffff00; - cursor: pointer; - transition: border-color .3s ease-in-out,background-color .3s ease-in-out; - } - - .pagination-wrapper .load-more-btn:hover { - text-decoration: none; - border-color: #222222; - background-color: #222222; - color: #ffffff; - } -`; - -export const numericPaginationStyles = css` - .pagination-wrapper { - flex-wrap: wrap; - justify-content: space-between; - } - - @media screen and (max-width: 1200px) { - .pagination-wrapper { - justify-content: center; - } - } -`; - -export const dateFilterStyles = css` - .date-filter-tag { - background-color: transparent; - border: none; - padding: 0 6px; - height: 32px; - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - cursor: pointer; - } - - .date-filter-tag-label { - width: calc(100% - 12px); - font-size: .875rem; - line-height: 1.3; - text-align: left; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - } - - .date-filter-tag-checkmark { - color: ${blueColor}; - width: 12px; - height: 12px; - } -`; diff --git a/eds/components/PartnerCardsWithDateFilter.js b/eds/components/PartnerCardsWithDateFilter.js index 1df0427..5bb11a5 100644 --- a/eds/components/PartnerCardsWithDateFilter.js +++ b/eds/components/PartnerCardsWithDateFilter.js @@ -1,5 +1,5 @@ import { getLibs } from '../scripts/utils.js'; -import { dateFilterStyles } from './PartnerCardsStyles.js'; +import { partnerCardsDateFilterStyles } from './PartnerCardsStyles.js'; import PartnerCards from './PartnerCards.js'; const miloLibs = getLibs(); @@ -8,7 +8,7 @@ const { html, css, repeat } = await import(`${miloLibs}/deps/lit-all.min.js`); export default class PartnerCardsWithDateFilter extends PartnerCards { static styles = [ PartnerCards.styles, - css`${dateFilterStyles}`, + css`${partnerCardsDateFilterStyles}`, ]; static properties = { @@ -59,6 +59,7 @@ export default class PartnerCardsWithDateFilter extends PartnerCards { get dateFilterMobile() { const { dateFilter: filter } = this.blockData; + /* eslint-disable indent */ return html`
@@ -96,6 +97,7 @@ export default class PartnerCardsWithDateFilter extends PartnerCards {
`; + /* eslint-enable indent */ } get filtersMobile() { @@ -122,6 +124,7 @@ export default class PartnerCardsWithDateFilter extends PartnerCards { tagsCount += 1; } + // eslint-disable-next-line consistent-return return { htmlContent, tagsCount }; } @@ -130,6 +133,7 @@ export default class PartnerCardsWithDateFilter extends PartnerCards { const { tags } = filter; + // eslint-disable-next-line consistent-return return html`${repeat( tags, (tag) => tag.key, @@ -155,6 +159,7 @@ export default class PartnerCardsWithDateFilter extends PartnerCards { this.initDateTags(tags); } else { this.selectedDateFilter = tag; + // eslint-disable-next-line no-return-assign tags.forEach((filterTag) => filterTag.checked = filterTag.key === tag.key); } diff --git a/eds/components/SinglePartnerCard.js b/eds/components/SinglePartnerCard.js new file mode 100644 index 0000000..2b84690 --- /dev/null +++ b/eds/components/SinglePartnerCard.js @@ -0,0 +1,72 @@ +import { singlePartnerCardStyles } from './PartnerCardsStyles.js'; +import { formatDate, getLibs, prodHosts } from '../scripts/utils.js'; + +const miloLibs = getLibs(); +const { html, LitElement } = await import(`${miloLibs}/deps/lit-all.min.js`); + +const DEFAULT_BACKGROUND_IMAGE_PATH = '/content/dam/solution/en/images/card-collection/sample_default.png'; +const KB_TAG = 'caas:adobe-partners/collections/knowledge-base'; + +class SinglePartnerCard extends LitElement { + static properties = { data: { type: Object } }; + + static styles = singlePartnerCardStyles; + + // eslint-disable-next-line class-methods-use-this + transformCardUrl(url) { + if (!url) { + console.error('URL is null or undefined'); + return ''; + } + if (window.location.host === 'partners.adobe.com') { + return url; + } + const newUrl = new URL(url); + newUrl.protocol = window.location.protocol; + newUrl.host = window.location.host; + return newUrl; + } + + get imageUrl() { + const isKB = this.data?.tags.some((tag) => tag.id === KB_TAG); + return isKB ? this.data.styles?.backgroundImage : `${new URL(this.data.styles?.backgroundImage).pathname}?width=400&format=webp&optimize=small`; + } + + checkBackgroundImage(element) { + const url = this.imageUrl; + const img = new Image(); + + const isProd = prodHosts.includes(window.location.host); + const defaultBackgroundImageOrigin = `https://partners.${isProd ? '' : 'stage.'}adobe.com`; + const defaultBackgroundImageUrl = `${defaultBackgroundImageOrigin}${DEFAULT_BACKGROUND_IMAGE_PATH}`; + + img.onerror = () => { + element.style.backgroundImage = `url(${defaultBackgroundImageUrl})`; + }; + + img.src = url; + } + + firstUpdated() { + this.checkBackgroundImage(this.shadowRoot.querySelector('.card-header')); + } + + render() { + return html` +
+
+
+
+

${this.data.contentArea?.title !== 'card-metadata' ? this.data.contentArea?.title : ''}

+

${this.data.contentArea?.description}

+
+ +
+
+ `; + } +} +customElements.define('single-partner-card', SinglePartnerCard); diff --git a/eds/scripts/scripts.js b/eds/scripts/scripts.js index 873d207..390ef7f 100644 --- a/eds/scripts/scripts.js +++ b/eds/scripts/scripts.js @@ -10,7 +10,8 @@ * governing permissions and limitations under the License. */ -import {prodHosts, setLibs} from './utils.js'; +import { prodHosts, setLibs, preloadResources } from './utils.js'; +// import PartnerNews from '../blocks/partner-news/PartnerNews.js'; // Add project-wide style path here. const STYLES = ''; @@ -18,8 +19,6 @@ const STYLES = ''; // Use 'https://milo.adobe.com/libs' if you cannot map '/libs' to milo's origin. const LIBS = '/libs'; - - const imsClientId = prodHosts.includes(window.location.host) ? 'MILO_PARTNERS_PROD' : 'MILO_PARTNERS_STAGE'; // Add any config options. @@ -68,6 +67,8 @@ const miloLibs = setLibs(LIBS); }()); (async function loadPage() { + await preloadResources(CONFIG.locales, miloLibs); + const { loadArea, setConfig } = await import(`${miloLibs}/utils/utils.js`); setConfig({ ...CONFIG, miloLibs }); diff --git a/eds/scripts/utils.js b/eds/scripts/utils.js index e3f41f8..941e232 100644 --- a/eds/scripts/utils.js +++ b/eds/scripts/utils.js @@ -44,22 +44,12 @@ export const prodHosts = [ * ------------------------------------------------------------ */ -export async function useMiloSample() { - const { createTag } = await import(`${getLibs()}/utils/utils.js`); -} - -const miloLibs = setLibs('/libs'); - -const { createTag, localizeLink, getConfig } = await import(`${miloLibs}/utils/utils.js`); -export { createTag, localizeLink, getConfig }; - -const { replaceText } = await import(`${miloLibs}/features/placeholders.js`); -export { replaceText }; - export function populateLocalizedTextFromListItems(el, localizedText) { const liList = Array.from(el.querySelectorAll('li')); liList.forEach((liEl) => { - let liContent = liEl.innerText.trim().toLowerCase().replace(/ /g, '-'); + const liInnerText = liEl.innerText; + if (!liInnerText) return; + let liContent = liInnerText.trim().toLowerCase().replace(/ /g, '-'); if (liContent.endsWith('_default')) liContent = liContent.slice(0, -8); localizedText[`{{${liContent}}}`] = liContent; }); @@ -76,5 +66,169 @@ export function formatDate(cardDate) { }; const formattedDate = dateObject.toLocaleString('en-US', options); + // eslint-disable-next-line consistent-return return formattedDate; } + +export function getLocale(locales, pathname = window.location.pathname) { + if (!locales) { + return { ietf: 'en-US', tk: 'hah7vzn.css', prefix: '' }; + } + const LANGSTORE = 'langstore'; + const split = pathname.split('/'); + const localeString = split[1]; + const locale = locales[localeString] || locales['']; + if (localeString === LANGSTORE) { + locale.prefix = `/${localeString}/${split[2]}`; + if ( + Object.values(locales) + .find((loc) => loc.ietf?.startsWith(split[2]))?.dir === 'rtl' + ) locale.dir = 'rtl'; + return locale; + } + const isUS = locale.ietf === 'en-US'; + locale.prefix = isUS ? '' : `/${localeString}`; + locale.region = isUS ? 'us' : localeString.split('_')[0]; + return locale; +} + +function preload(url) { + const preloadLink = document.createElement('link'); + preloadLink.rel = 'preload'; + preloadLink.as = 'fetch'; + preloadLink.crossOrigin = true; + preloadLink.href = url; + document.head.appendChild(preloadLink); +} + +function preloadPlaceholders(locale) { + const placeholderUrl = `${locale.prefix}/eds/partners-shared/placeholders.json`; + preload(placeholderUrl); +} + +function preloadLit(miloLibs) { + const preloadLink = document.createElement('link'); + preloadLink.rel = 'modulepreload'; + preloadLink.crossOrigin = true; + preloadLink.href = `${miloLibs}/deps/lit-all.min.js`; + document.head.appendChild(preloadLink); +} + +export async function preloadResources(locales, miloLibs) { + const locale = getLocale(locales); + const cardBlocks = { + 'partner-news': '"caas:adobe-partners/collections/news"', + 'knowledge-base-overview': '"caas:adobe-partners/collections/knowledge-base"', + }; + + Object.entries(cardBlocks).forEach(async ([key, value]) => { + const el = document.querySelector(`.${key}`); + if (!el) return; + + preloadPlaceholders(locale); + preloadLit(miloLibs); + + const block = { + el, + name: key, + collectionTag: value, + ietf: locale.ietf, + }; + const caasUrl = getCaasUrl(block); + preload(caasUrl); + }); +} + +export function getProgramType(path) { + switch (true) { + case /solutionpartners/.test(path): return 'spp'; + case /technologypartners/.test(path): return 'tpp'; + case /channelpartners/.test(path): return 'cpp'; + default: return ''; + } +} + +export function getCurrentProgramType() { + return getProgramType(window.location.pathname); +} +export function getCookieValue(key) { + const cookies = document.cookie.split(';').map((cookie) => cookie.trim()); + const cookie = cookies.find((el) => el.startsWith(`${key}=`)); + return cookie?.substring((`${key}=`).length); +} +export function getPartnerDataCookieValue(programType, key) { + try { + const partnerDataCookie = getCookieValue('partner_data'); + if (!partnerDataCookie) return; + const partnerDataObj = JSON.parse(decodeURIComponent(partnerDataCookie.toLowerCase())); + const portalData = partnerDataObj?.[programType]; + // eslint-disable-next-line consistent-return + return portalData?.[key]; + } catch (error) { + console.error('Error parsing partner data object:', error); + // eslint-disable-next-line consistent-return + return ''; + } +} + +export function getCaasUrl(block) { + const useStageCaasEndpoint = block.name === 'knowledge-base-overview'; + const domain = `${(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`); + return setApiParams(api, block); +} + +function setApiParams(api, block) { + const { el, collectionTag } = block; + const complexQueryParams = getComplexQueryParams(el, collectionTag); + if (complexQueryParams) api.searchParams.set('complexQuery', complexQueryParams); + + const [language, country] = block.ietf.split('-'); + if (language && country) { + api.searchParams.set('language', language); + api.searchParams.set('country', country); + } + + return api.toString(); +} + +function extractTableCollectionTags(el) { + let tableCollectionTags = []; + Array.from(el.children).forEach((row) => { + const cols = Array.from(row.children); + const rowTitle = cols[0].innerText.trim().toLowerCase().replace(/ /g, '-'); + const colsContent = cols.slice(1); + if (rowTitle === 'collection-tags') { + const [collectionTagsEl] = colsContent; + const collectionTags = Array.from(collectionTagsEl.querySelectorAll('li'), (li) => `"${li.innerText.trim().toLowerCase()}"`); + tableCollectionTags = [...tableCollectionTags, ...collectionTags]; + } + }); + + return tableCollectionTags; +} + +function getComplexQueryParams(el, collectionTag) { + const portal = getCurrentProgramType(); + if (!portal) return; + + const portalCollectionTag = `"caas:adobe-partners/${portal}"`; + const tableTags = extractTableCollectionTags(el); + const collectionTags = [collectionTag, portalCollectionTag, ...tableTags]; + + const partnerLevelParams = getPartnerLevelParams(portal); + + if (!collectionTags.length) return; + + const collectionTagsStr = collectionTags.filter((e) => e.length).join('+AND+'); + let resulStr = `(${collectionTagsStr})`; + if (partnerLevelParams) resulStr += `+AND+${partnerLevelParams}`; + // eslint-disable-next-line consistent-return + return resulStr; +} + +function getPartnerLevelParams(portal) { + const partnerLevel = getPartnerDataCookieValue(portal, 'level'); + const partnerTagBase = `"caas:adobe-partners/${portal}/partner-level/`; + return partnerLevel ? `(${partnerTagBase}${partnerLevel}"+OR+${partnerTagBase}public")` : `(${partnerTagBase}public")`; +} diff --git a/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js b/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js index d1d8055..008195c 100644 --- a/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js +++ b/test/blocks/knowledge-base-overview/knowledge-base-overview.test.js @@ -16,6 +16,7 @@ describe('knowledge-base-overview block', () => { this.cards = cards; this.paginatedCards = this.cards.slice(0, 3); this.hasResponseData = true; + this.fetchedData = true; }); await import('../../../eds/scripts/scripts.js'); @@ -40,7 +41,7 @@ describe('knowledge-base-overview block', () => { expect(knowledgeBaseWrapper.shadowRoot).to.exist; const partnerCardsCollection = knowledgeBaseWrapper.shadowRoot.querySelector('.partner-cards-collection'); expect(partnerCardsCollection).to.exist; - expect(partnerCardsCollection.innerHTML).to.include('news-card'); + expect(partnerCardsCollection.innerHTML).to.include('single-partner-card'); const firstCard = partnerCardsCollection.querySelector('.card-wrapper'); expect(firstCard.shadowRoot).to.exist; const searchBarWrapper = knowledgeBaseWrapper.shadowRoot.querySelector('.partner-cards-sidebar .search-wrapper'); diff --git a/test/blocks/partner-news/partner-news.test.js b/test/blocks/partner-news/partner-news.test.js index 875484b..820ab61 100644 --- a/test/blocks/partner-news/partner-news.test.js +++ b/test/blocks/partner-news/partner-news.test.js @@ -16,6 +16,7 @@ describe('partner-news block', () => { this.cards = cards; this.paginatedCards = this.cards.slice(0, 3); this.hasResponseData = true; + this.fetchedData = true; }); await import('../../../eds/scripts/scripts.js'); @@ -40,7 +41,7 @@ describe('partner-news block', () => { expect(partnerNewsWrapper.shadowRoot).to.exist; const partnerCardsCollection = partnerNewsWrapper.shadowRoot.querySelector('.partner-cards-collection'); expect(partnerCardsCollection).to.exist; - expect(partnerCardsCollection.innerHTML).to.include('news-card'); + expect(partnerCardsCollection.innerHTML).to.include('single-partner-card'); const firstCard = partnerCardsCollection.querySelector('.card-wrapper'); expect(firstCard.shadowRoot).to.exist; const searchBarWrapper = partnerNewsWrapper.shadowRoot.querySelector('.partner-cards-sidebar .search-wrapper');