From 56218909c8a81b78140a2ca0e1515a47555af3ab Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Tue, 26 Oct 2021 19:56:37 +0300 Subject: [PATCH 1/6] Fix spooky 301 --- src/shared/components/Contentful/SearchBar/SearchBar.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/shared/components/Contentful/SearchBar/SearchBar.jsx b/src/shared/components/Contentful/SearchBar/SearchBar.jsx index 3fe97914e3..16e90a5650 100644 --- a/src/shared/components/Contentful/SearchBar/SearchBar.jsx +++ b/src/shared/components/Contentful/SearchBar/SearchBar.jsx @@ -379,12 +379,13 @@ export class SearchBarInner extends Component { * Update suggestion list with new search text * This function use debounce delay to avoid processing or requesting too much * - * @param {String} searchText Search text + * @param {String} searchTerm Search text */ - updateSuggestionListWithNewSearch(searchText) { + updateSuggestionListWithNewSearch(searchTerm) { const { selectedFilter, } = this.state; + const searchText = searchTerm ? encodeURIComponent(searchTerm) : ''; if (searchText) { const query = { From e135df5c8d38c721fbe9fc4cce09324cfbc477c8 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Wed, 27 Oct 2021 12:48:12 +0300 Subject: [PATCH 2/6] Fix spooky 288 --- src/shared/containers/EDU/Tracks.jsx | 31 ++++++++++++++++++++++++++++ src/shared/services/contentful.js | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/shared/containers/EDU/Tracks.jsx b/src/shared/containers/EDU/Tracks.jsx index db827da600..c56164f40d 100644 --- a/src/shared/containers/EDU/Tracks.jsx +++ b/src/shared/containers/EDU/Tracks.jsx @@ -84,6 +84,16 @@ export default class EDUTracks extends React.Component { ? urlQuery.tags : (urlQuery.tags ? [urlQuery.tags] : []); if (urlQuery.startDate) urlQuery.startDate = moment(urlQuery.startDate).format(); if (urlQuery.endDate) urlQuery.endDate = moment(urlQuery.endDate).format(); + // validate track string in URL query + // set CP if missing or wrong + const tracks = _.keys(TRACK_BANNER_BACK_COLORS); + if (!urlQuery.track || _.indexOf(tracks, urlQuery.track) === -1) { + urlQuery.track = 'Competitive Programming'; + updateQuery({ + ...query, + ...urlQuery, + }); + } this.setState({ query: { ...query, @@ -96,6 +106,27 @@ export default class EDUTracks extends React.Component { // Get the EDU taxonomy this.apiService.getEDUTaxonomy() .then((taxonomy) => { + if (urlQuery.tax) { + // check if tax exists or is wrong + const foundSome = _.some( + _.flatten( + _.values(taxonomy), + ), cat => cat.name.toLowerCase() === urlQuery.tax.toLowerCase(), + ); + if (!foundSome) { + delete urlQuery.tax; + updateQuery({ + ...query, + ...urlQuery, + }); + this.setState({ + query: { + ...query, + ...urlQuery, + }, + }); + } + } const tree = tracksTreeBuilder(taxonomy, urlQuery); this.setState({ tree, diff --git a/src/shared/services/contentful.js b/src/shared/services/contentful.js index ded9dacaf7..67abbfe495 100644 --- a/src/shared/services/contentful.js +++ b/src/shared/services/contentful.js @@ -335,8 +335,8 @@ class Service { } }); } else { - const taxId = _.find(taxonomy[track], ['name', tax]).id; - taxIDs.push(taxId); + const taxId = _.find(taxonomy[track], ['name', tax]); + if (taxId) taxIDs.push(taxId.id); } if (taxIDs.length) query['fields.contentCategory.sys.id[in]'] = taxIDs.join(','); } From 08d5ddaad3c722a40ef19c8e614b4b97f9657b69 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Wed, 27 Oct 2021 12:57:23 +0300 Subject: [PATCH 3/6] Fix spooky 188 --- src/shared/services/contentful.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shared/services/contentful.js b/src/shared/services/contentful.js index 67abbfe495..5bd4fc3065 100644 --- a/src/shared/services/contentful.js +++ b/src/shared/services/contentful.js @@ -319,9 +319,7 @@ class Service { query: author, }) .then((result) => { - if (result.total) { - query['fields.contentAuthor.sys.id'] = result.items[0].sys.id; - } + query['fields.contentAuthor.sys.id'] = result.total ? result.items[0].sys.id : 'NO_SUCH_ID'; }); } if (tax && track && taxonomy && taxonomy[track]) { From e7c466f99c1d418a6256d78e6fcfb35fb6b3b221 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Wed, 27 Oct 2021 13:07:11 +0300 Subject: [PATCH 4/6] Fix spooky 173 --- src/shared/components/Contentful/SearchBar/SearchBar.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shared/components/Contentful/SearchBar/SearchBar.jsx b/src/shared/components/Contentful/SearchBar/SearchBar.jsx index 16e90a5650..ab0abb9e09 100644 --- a/src/shared/components/Contentful/SearchBar/SearchBar.jsx +++ b/src/shared/components/Contentful/SearchBar/SearchBar.jsx @@ -500,6 +500,7 @@ export class SearchBarInner extends Component { Date: Wed, 27 Oct 2021 13:09:25 +0300 Subject: [PATCH 5/6] ci: on beta --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e37ab4b7a..5c86213e84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -364,7 +364,7 @@ workflows: filters: branches: only: - - thrive-vulnerability-1 + - thrive-spooky1-p0 # This is stage env for production QA releases - "build-prod-staging": context : org-global From 8ebfbdd5bc02dee599b24fce326078268c0b5aa6 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Thu, 28 Oct 2021 10:35:13 +0300 Subject: [PATCH 6/6] fixes encodeURI --- src/shared/services/contentful.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/services/contentful.js b/src/shared/services/contentful.js index 5bd4fc3065..81b7dd1e1c 100644 --- a/src/shared/services/contentful.js +++ b/src/shared/services/contentful.js @@ -316,7 +316,7 @@ class Service { // thus we need to find it first await this.queryEntries({ content_type: 'person', - query: author, + query: encodeURIComponent(author), }) .then((result) => { query['fields.contentAuthor.sys.id'] = result.total ? result.items[0].sys.id : 'NO_SUCH_ID'; @@ -340,12 +340,12 @@ class Service { } if (track) query['fields.trackCategory'] = track; if (!_.isEmpty(tags)) { - query['fields.tags[all]'] = tags.join(','); + query['fields.tags[all]'] = tags.map(t => encodeURIComponent(t)).join(','); } if (startDate) query['fields.creationDate[gte]'] = startDate; if (endDate) query['fields.creationDate[lte]'] = endDate; - if (phrase) query.query = phrase; - if (title) query['fields.title[match]'] = title; + if (phrase) query.query = encodeURIComponent(phrase); + if (title) query['fields.title[match]'] = encodeURIComponent(title); if (sortBy) { switch (sortBy) { case 'Likes': query.order = '-fields.upvotes,-fields.creationDate'; break;