From 227c600fd151d8971b5d46d870ffc91bff33679e Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 14 Sep 2020 11:22:27 +0300 Subject: [PATCH 1/5] Fixes for #4887 --- .../components/Contentful/Article/Article.jsx | 23 ++++++++++++++++++- src/shared/containers/EDU/Home.jsx | 8 +++++++ src/shared/containers/EDU/Search.jsx | 8 +++++++ src/shared/containers/EDU/Tracks.jsx | 8 +++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/shared/components/Contentful/Article/Article.jsx b/src/shared/components/Contentful/Article/Article.jsx index 150d213290..c9078713ea 100644 --- a/src/shared/components/Contentful/Article/Article.jsx +++ b/src/shared/components/Contentful/Article/Article.jsx @@ -15,7 +15,10 @@ import LoadingIndicator from 'components/LoadingIndicator'; import YouTubeVideo from 'components/YouTubeVideo'; import moment from 'moment'; import localStorage from 'localStorage'; -import { config, Link, isomorphy } from 'topcoder-react-utils'; +import { Helmet } from 'react-helmet'; +import { + config, Link, isomorphy, +} from 'topcoder-react-utils'; import qs from 'qs'; // SVGs and assets import GestureIcon from 'assets/images/icon-gesture.svg'; @@ -110,9 +113,27 @@ export default class Article extends React.Component { if (isomorphy.isClientSide()) { shareUrl = encodeURIComponent(window.location.href); } + const description = htmlToText.fromString( + ReactDOMServer.renderToString(markdown(fields.content)), + { + ignoreHref: true, + ignoreImage: true, + singleNewLineParagraphs: true, + uppercaseHeadings: false, + }, + ).substring(0, CONTENT_PREVIEW_LENGTH); return ( + + {fields.title} + + + + + + + {/* Banner */} { fields.featuredImage ? ( diff --git a/src/shared/containers/EDU/Home.jsx b/src/shared/containers/EDU/Home.jsx index 275efaab6c..30c8455a26 100644 --- a/src/shared/containers/EDU/Home.jsx +++ b/src/shared/containers/EDU/Home.jsx @@ -3,6 +3,7 @@ */ import React from 'react'; import { config } from 'topcoder-react-utils'; +import { Helmet } from 'react-helmet'; import Viewport from 'components/Contentful/Viewport'; import SearchBar from 'components/Contentful/SearchBar/SearchBar'; import { getService } from 'services/contentful'; @@ -45,6 +46,13 @@ export default class EDUHome extends React.Component { const { taxonomy } = this.state; return (
+ + THRIVE - Grow with us. Tutorials and workshops that matter. + + + + + {/* Banner */}
diff --git a/src/shared/containers/EDU/Search.jsx b/src/shared/containers/EDU/Search.jsx index b49128c77a..6b311aa68e 100644 --- a/src/shared/containers/EDU/Search.jsx +++ b/src/shared/containers/EDU/Search.jsx @@ -13,6 +13,7 @@ import { updateQuery } from 'utils/url'; import qs from 'qs'; import LoadingIndicator from 'components/LoadingIndicator'; import SearchPageFilter from 'components/Contentful/SearchPageFilter/SearchPageFilter'; +import { Helmet } from 'react-helmet'; // Partials import ResultTabs from './partials/ResultTabs'; // CSS @@ -91,6 +92,13 @@ export default class EDUSearch extends React.Component { if (!taxonomy) return ; return (
+ + THRIVE - Search {`${query.title}`} + + + + + {/* Banner */}
diff --git a/src/shared/containers/EDU/Tracks.jsx b/src/shared/containers/EDU/Tracks.jsx index 0a1b4c8398..d98099191e 100644 --- a/src/shared/containers/EDU/Tracks.jsx +++ b/src/shared/containers/EDU/Tracks.jsx @@ -14,6 +14,7 @@ import qs from 'qs'; import TracksTree from 'components/Contentful/TracksTree/TracksTree'; import LoadingIndicator from 'components/LoadingIndicator'; import TracksFilter from 'components/Contentful/TracksFilter/TracksFilter'; +import { Helmet } from 'react-helmet'; // SVGs & Assets import Dev from 'assets/images/img-development.png'; import Design from 'assets/images/img_design.png'; @@ -167,6 +168,13 @@ export default class EDUTracks extends React.Component { if (!taxonomy) return ; return (
+ + THRIVE - {`${query.track}`} + + + + + {/* Banner */}
Date: Mon, 14 Sep 2020 12:22:27 +0300 Subject: [PATCH 2/5] Fixes for #4888 --- .../Contentful/SearchBar/SearchBar.jsx | 47 +++++++++++++++++-- .../Contentful/SearchBar/themes/default.scss | 4 ++ .../containers/EDU/partials/ResultTabs.jsx | 6 +-- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/shared/components/Contentful/SearchBar/SearchBar.jsx b/src/shared/components/Contentful/SearchBar/SearchBar.jsx index 9444c56777..1ffecbb36d 100644 --- a/src/shared/components/Contentful/SearchBar/SearchBar.jsx +++ b/src/shared/components/Contentful/SearchBar/SearchBar.jsx @@ -56,6 +56,7 @@ export class SearchBarInner extends Component { this.getSuggestionList = this.getSuggestionList.bind(this); this.handleSearchChange = this.handleSearchChange.bind(this); this.handleClickOutside = this.handleClickOutside.bind(this); + this.onKeyDown = this.onKeyDown.bind(this); // using debounce to avoid processing or requesting too much this.updateSuggestionListWithNewSearch = _.debounce( this.updateSuggestionListWithNewSearch.bind(this), 400, @@ -71,6 +72,29 @@ export class SearchBarInner extends Component { document.removeEventListener('mousedown', this.handleClickOutside); } + onKeyDown(e) { + const { inputlVal, selectedFilter } = this.state; + if (inputlVal && e.which === 13) { + const searchQuery = {}; + if (this.searchFieldRef && this.searchFieldRef.value) { + if (selectedFilter.name === 'Tags') { + searchQuery.tags = [this.searchFieldRef.value]; + } + if (selectedFilter.name === 'All') { + searchQuery.phrase = this.searchFieldRef.value; + } + if (selectedFilter.name === 'Title') { + searchQuery.title = this.searchFieldRef.value; + } + } + if (selectedFilter.name !== 'Author') { + window.location.href = `${config.TC_EDU_BASE_PATH}${config.TC_EDU_SEARCH_PATH}?${qs.stringify(searchQuery)}`; + } else { + window.location.href = `${config.TC_EDU_BASE_PATH}${config.TC_EDU_SEARCH_PATH}?author=${inputlVal}`; + } + } + } + /** * Set the search field ref */ @@ -136,6 +160,7 @@ export class SearchBarInner extends Component { isShowSuggestion, suggestionList, selectedFilter, + noResults, } = this.state; const searchQuery = {}; @@ -151,7 +176,8 @@ export class SearchBarInner extends Component { } } - return (suggestionList && !_.isEmpty(suggestionList) && isShowSuggestion && ( + // eslint-disable-next-line no-nested-ternary + return suggestionList && !_.isEmpty(suggestionList) && isShowSuggestion ? (
- )); + ) : noResults ? ( +
+ No Results +
+ ) : null; } handleClickOutside(e) { @@ -379,7 +412,10 @@ export class SearchBarInner extends Component { .then((results) => { // Nothing found? if (!results.total) { - this.setState({ suggestionList: {} }); + this.setState({ + suggestionList: {}, + noResults: true, + }); return; } // Author query? @@ -387,7 +423,7 @@ export class SearchBarInner extends Component { const suggestionList = { Author: _.map(results.items, item => ({ ...item.fields })), }; - this.setState({ suggestionList }); + this.setState({ suggestionList, noResults: false }); return; } // ALL && Tags @@ -395,7 +431,7 @@ export class SearchBarInner extends Component { this.setState({ suggestionList }); }); } else { - this.setState({ suggestionList: {} }); + this.setState({ suggestionList: {}, noResults: false }); } } @@ -471,6 +507,7 @@ export class SearchBarInner extends Component { document.addEventListener('mousedown', this.handleClickOutside); }} onChange={this.handleSearchChange} + onKeyDown={this.onKeyDown} />
- ) : (

Nothing Found

) + ) : (

No results found

) } { videos.total > videos.items.length ? ( @@ -225,7 +225,7 @@ export default class ResultTabs extends React.Component { /> ); }) - ) : (

Nothing Found

) + ) : (

No results found

) } { posts.total > posts.items.length ? ( From b83393204453ae36ee377bfbb45acaae49ebe7d6 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 14 Sep 2020 12:30:54 +0300 Subject: [PATCH 3/5] Fix #4896 --- 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 1ffecbb36d..d23301d0ed 100644 --- a/src/shared/components/Contentful/SearchBar/SearchBar.jsx +++ b/src/shared/components/Contentful/SearchBar/SearchBar.jsx @@ -455,6 +455,7 @@ export class SearchBarInner extends Component { contentAuthor: contentAuthor.fields, externalArticle: fields.externalArticle, contentUrl: fields.contentUrl, + slug: fields.slug, }; }), 'type', From 21576ee445530c23067433f5a3f734354028594e Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 14 Sep 2020 14:21:07 +0300 Subject: [PATCH 4/5] Fix #4889 --- src/shared/services/contentful.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/services/contentful.js b/src/shared/services/contentful.js index 4508f76d6d..60fc4a5a50 100644 --- a/src/shared/services/contentful.js +++ b/src/shared/services/contentful.js @@ -346,8 +346,8 @@ class Service { query.query = tags.join(' '); } } - if (startDate) query['sys.createdAt[gte]'] = startDate; - if (endDate) query['sys.createdAt[lte]'] = endDate; + 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; const content = {}; From 2ffaeec8ff6c568e162fd89c0e76c157db50591c Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 14 Sep 2020 15:05:06 +0300 Subject: [PATCH 5/5] ci: on staging --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6180803b84..cd03e3288f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -260,7 +260,7 @@ workflows: filters: branches: only: - - develop + - feature-contentful # Production builds are exectuted # when PR is merged to the master # Don't change anything in this configuration