Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor training pages to allow rendering on client-side instead of … #5523

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a82227e
refactor training pages to allow rendering on client-side instead of …
sharon-odhiambo Oct 24, 2023
fdcbb14
update a single library api endpoint
sharon-odhiambo Oct 24, 2023
29691f9
render no training libraries messages in wiki ed mode and non wiki ed…
sharon-odhiambo Oct 24, 2023
f8ad43f
update search input with labels from the backend
sharon-odhiambo Oct 24, 2023
3ae4caf
add breadcrumbs to a single library page
sharon-odhiambo Oct 24, 2023
060c87c
fix linting issues on training controller
sharon-odhiambo Oct 24, 2023
8b16761
fix linting issues on training controller
sharon-odhiambo Oct 24, 2023
d7972f2
remove unnecessary message flashing before libraries are loaded
sharon-odhiambo Oct 29, 2023
fa7083d
update slides array
sharon-odhiambo Oct 29, 2023
6e4b93c
restore module source in training module handler
sharon-odhiambo Oct 29, 2023
4a3d859
update libraries loading functionality
sharon-odhiambo Oct 29, 2023
a5ee692
fix failing spec for libraries index
sharon-odhiambo Oct 30, 2023
a95377f
fix failing training spec
sharon-odhiambo Oct 30, 2023
ab6e2e3
transfer training library from server side to client-side
sharon-odhiambo Nov 1, 2023
d4dcc24
update libraries list
sharon-odhiambo Nov 2, 2023
1de53f1
move the no-training rendering to server side to avoid flashing
sharon-odhiambo Nov 2, 2023
970ada0
add training module progress on training show
sharon-odhiambo Nov 2, 2023
3f9188d
fix module progress styling
sharon-odhiambo Nov 2, 2023
56afa0f
move no libraries message to react side
sharon-odhiambo Nov 3, 2023
a0b8f7b
display no libraries only when libraries are feteched and empty
sharon-odhiambo Nov 3, 2023
c746f6d
fix no training libraries issue and failing spec
sharon-odhiambo Nov 4, 2023
6e043ac
update no search results styling
sharon-odhiambo Nov 4, 2023
58697fb
move libraries test to react testing
sharon-odhiambo Nov 9, 2023
512b3d7
fix failing spec
sharon-odhiambo Nov 9, 2023
dea7937
reset libraries test
sharon-odhiambo Nov 9, 2023
234335e
fix failing spec
sharon-odhiambo Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/assets/javascripts/training/components/search_results.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

const SearchResults = ({ slides }) => {
const SearchResults = ({ slides, message }) => {
if (slides && slides.length > 0) {
return (
<ul className="training-libraries no-bullets no-margin action-card-text">
Expand All @@ -16,7 +16,7 @@ const SearchResults = ({ slides }) => {
</ul>
);
}
return null;
return message;
};

export default SearchResults;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fetchTrainingLibraries, searchTrainingLibraries } from '../../actions/t
const TrainingLibraries = () => {
const libraries = useSelector(state => state.training.libraries);
const focusedLibrarySlug = useSelector(state => state.training.focusedLibrarySlug);
const slides = useSelector(state => state.training.slides);
const slides = useSelector(state => state.training.slides).slides;
const [search, setSearch] = useState('');
const [showSearchResults, setShowSearchResults] = useState(false);
const dispatch = useDispatch();
Expand All @@ -28,7 +28,7 @@ const TrainingLibraries = () => {
dispatch(searchTrainingLibraries(search));
setShowSearchResults(true);
};
if (libraries.length === 0) {
if (!libraries) {
if (Features.wikiEd) {
return (
<div>
Expand Down Expand Up @@ -69,7 +69,7 @@ const TrainingLibraries = () => {
</form>
</div>
{showSearchResults ? (
<SearchResults slides={slides} message="No training resources match your search." />
<SearchResults slides={slides} message={I18n.t('training.no_training_resource_match_your_search')} />
) : (
<ul className="training-libraries no-bullets no-margin">
{libraries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,12 @@ const TrainingModuleHandler = createReactClass({
);
}
);
let moduleSource;
if (this.props.training.module.wiki_page) {
moduleSource = (
<div className="training-module-source">
<a href={`https://meta.wikimedia.org/wiki/${this.props.training.module.wiki_page}`} target="_blank">{I18n.t('training.view_module_source')}</a>
<br />
<a href={`/reload_trainings?module=${this.props.training.module.slug}`}>{I18n.t('training.reload_from_source')}</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these messages are still relevant, they just shouldn't be shown until after the data has been loaded. If any empty response has already been received from the server, at that point we should show relevant 'missing' messages.

</div>
);
}

return (
<div className="training__toc-container">
<h1 className="h4 capitalize"> {I18n.t('training.table_of_contents')} <span className="pull-right total-slides">({slidesAry.length})</span></h1>
<ol>
{slides}
</ol>
{moduleSource}
</div>

);
Expand Down
Loading