diff --git a/app/assets/javascripts/training/components/training_libraries_list.jsx b/app/assets/javascripts/training/components/training_libraries_list.jsx index 2ba54d4094..55bdd921ee 100644 --- a/app/assets/javascripts/training/components/training_libraries_list.jsx +++ b/app/assets/javascripts/training/components/training_libraries_list.jsx @@ -9,16 +9,23 @@ const TrainingLibraries = () => { const slides = useSelector(state => state.training.slides); const [search, setSearch] = useState(''); const [showSearchResults, setShowSearchResults] = useState(false); + const [isLoading, setIsLoading] = useState(true); const dispatch = useDispatch(); useEffect(() => { dispatch(fetchTrainingLibraries()); -}, [dispatch]); + }, [dispatch]); useEffect(() => { setShowSearchResults(showSearchResults); }, [slides]); + useEffect(() => { + if (libraries.length > 0) { + setIsLoading(false); + } + }, [libraries]); + const handleSearch = (e) => { setSearch(e.target.value); }; @@ -28,6 +35,35 @@ const TrainingLibraries = () => { dispatch(searchTrainingLibraries(search)); setShowSearchResults(true); }; + + if (isLoading) { + return ( +
+
+
+ ); + } + if (libraries.length === 0) { + if (Features.wikiEd) { + return ( +
+

+

+ ); + } + + return ( +
+ {I18n.t('training.no_training_library_records_non_wiki_ed_mode')} +
+ ); + } return (

Training Libraries

diff --git a/app/controllers/training_controller.rb b/app/controllers/training_controller.rb index 2c8dae0b53..74d1e07d31 100644 --- a/app/controllers/training_controller.rb +++ b/app/controllers/training_controller.rb @@ -10,7 +10,6 @@ class TrainingController < ApplicationController def index @libraries = @query_object.all_libraries - render 'no_training_module' if @libraries.empty? respond_to do |format| format.html { render 'index' } format.json { handle_json_request }