Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheridan Sunier authored and Sheridan Sunier committed Jul 14, 2023
1 parent bac0c3d commit 76c7a10
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 226 deletions.
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

403 changes: 244 additions & 159 deletions dist/main.js

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions dist/main.min.js

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions dist/main.source.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions react/src/js/components/Consonant/Container/Container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
featuredCards: [{}],
filterPanel: {},
hideCtaIds: [{}],
hideCtaTags: [{}],
sort: {},
pagination: {},
bookmarks: {},
Expand Down Expand Up @@ -120,6 +121,11 @@ const Container = (props) => {
.replace(/\[|\]/g, '')
.replace(/`/g, '')
.split(',');
const hideCtaTags = getConfig('hideCtaTags', '')
.toString()
.replace(/\[|\]/g, '')
.replace(/`/g, '')
.split(',');
const leftPanelSearchPlaceholder = getConfig('search', 'i18n.leftFilterPanel.searchPlaceholderText');
const topPanelSearchPlaceholder = getConfig('search', 'i18n.topFilterPanel.searchPlaceholderText');
const searchPlaceholderText = getConfig('search', 'i18n.filterInfo.searchPlaceholderText');
Expand Down Expand Up @@ -783,6 +789,7 @@ const Container = (props) => {
onlyShowBookmarks,
bookmarkedCardIds,
hideCtaIds,
hideCtaTags,
);
if (payload.isHashed) {
const TAG_HASH_LENGTH = 6;
Expand Down
2 changes: 1 addition & 1 deletion react/src/js/components/Consonant/Grid/Grid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const Grid = (props) => {
* @returns {bool} - whether a cta should be hidden
*/
const getHideCta = (card, style) => {
if (card.hideCtaId || style === 'hidden') return true;
if (card.hideCtaId || card.hideCtaTags || style === 'hidden') return true;
return false;
};

Expand Down
14 changes: 13 additions & 1 deletion react/src/js/components/Consonant/Helpers/JsonProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
truncateString,
removeDuplicatesByKey,
} from './general';
import { hasTag } from './Helpers';

/**
* Class that handles parsing raw JSON data and returning a set of processed cards
Expand Down Expand Up @@ -60,16 +61,27 @@ export default class JsonProcessor {
* @param {*} onlyShowBookmarks
* @param {*} bookmarkedCardIds
* @param {*} hideCtaIds
* @param {*} hideCtaTags
* @return {*}
* @memberof JsonProcessor
*/
addCardMetaData(truncateTextQty, onlyShowBookmarks, bookmarkedCardIds, hideCtaIds) {
addCardMetaData(
truncateTextQty,
onlyShowBookmarks,
bookmarkedCardIds,
hideCtaIds,
hideCtaTags,
) {
this.processedCards = this.processedCards.map(card => ({
...card,
description: truncateString(getByPath(card, 'contentArea.description', ''), truncateTextQty),
isBookmarked: bookmarkedCardIds.some(i => i === card.id),
disableBookmarkIco: onlyShowBookmarks,
hideCtaId: hideCtaIds.some(i => i === card.id),
hideCtaTags: hideCtaTags.some((tag) => {
const re = new RegExp(tag);
return hasTag(re, card.tags);
}),
initial: {
title: getByPath(card, 'contentArea.title', ''),
description: getByPath(card, 'contentArea.description', ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const addCardMetaData = [
detailText: 'detailText 1',
dateDetailText: '',
},
tags: [{ id: 'caas:tagB' }],
},
{
id: 2,
Expand All @@ -40,6 +41,10 @@ const addCardMetaData = [
detailText: '',
dateDetailText: '',
},
tags: [
{ id: 'caas:tagA' },
{ id: 'caas:tagB' },
],
},
{
id: 3,
Expand All @@ -50,12 +55,14 @@ const addCardMetaData = [
detailText: 'detailText 2',
dateDetailText: '',
},
tags: [{ id: 'caas:tagC' }],
},
],
truncateTextQty: 5,
onlyShowBookmarks: false,
bookmarkedCardIds: [1],
hideCtaIds: [2],
hideCtaTags: ['caas:tagC'],
expectedValue: [
{
id: 1,
Expand All @@ -70,13 +77,15 @@ const addCardMetaData = [
isBookmarked: true,
disableBookmarkIco: false,
hideCtaId: false,
hideCtaTags: false,
initial: {
title: 'title 1',
description: '12345',
bannerText: 'overlays.description 1',
dateDetailText: '',
detailText: 'detailText 1',
},
tags: [{ id: 'caas:tagB' }],
},
{
id: 2,
Expand All @@ -91,13 +100,18 @@ const addCardMetaData = [
isBookmarked: false,
disableBookmarkIco: false,
hideCtaId: true,
hideCtaTags: false,
initial: {
title: '',
description: '',
bannerText: '',
dateDetailText: '',
detailText: '',
},
tags: [
{ id: 'caas:tagA' },
{ id: 'caas:tagB' },
],
},
{
id: 3,
Expand All @@ -112,13 +126,15 @@ const addCardMetaData = [
isBookmarked: false,
disableBookmarkIco: false,
hideCtaId: false,
hideCtaTags: true,
initial: {
title: 'title 2',
description: '123456',
bannerText: 'overlays.description 2',
dateDetailText: '',
detailText: 'detailText 2',
},
tags: [{ id: 'caas:tagC' }],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import JsonProcessor from '../JsonProcessor';
describe('utils/JsonProcessor', () => {
describe('addCardMetaData', () => {
PROPS.addCardMetaData.forEach(({
cards, truncateTextQty, onlyShowBookmarks, bookmarkedCardIds, hideCtaIds, expectedValue,
cards,
truncateTextQty,
onlyShowBookmarks,
bookmarkedCardIds,
hideCtaIds,
hideCtaTags,
expectedValue,
}) => {
test('should add card metadata', () => {
const jsonProcessor = new JsonProcessor(cards);
Expand All @@ -15,6 +21,7 @@ describe('utils/JsonProcessor', () => {
onlyShowBookmarks,
bookmarkedCardIds,
hideCtaIds,
hideCtaTags,
);

expect(processedCards).toEqual(expectedValue);
Expand Down
1 change: 1 addition & 0 deletions react/src/js/components/Consonant/Helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const DEFAULT_CONFIG = {
},
featuredCards: [],
hideCtaIds: [],
hideCtaTags: [],
header: {
enabled: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
}
},
"hideCtaIds": "[]",
"hideCtaTags": "[]",
"sort": {
"enabled": true,
"defaultSort": "featured",
Expand Down

0 comments on commit 76c7a10

Please sign in to comment.