Skip to content

Commit

Permalink
feat: CQDG-701 fix shared saved filters fetch (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulous authored Oct 9, 2024
1 parent 2e65303 commit f2c64b9
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
13 changes: 11 additions & 2 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,14 @@ const en = {
404: 'Sorry, the page you visited does not exist.',
500: 'Sorry, something went wrong.',
backHome: 'Back home',
query: {
notFound: {
title: 'Query not found',
content:
'We were unable to load your query. Please try again or <a href="{href}" style="text-decoration: underline;" target="_blank">contact support</a>.',
okText: 'Close',
},
},
},
notification: {
genericError: 'An error occured',
Expand Down Expand Up @@ -1039,9 +1047,10 @@ const en = {
title: 'Connection error',
subtitle:
'We are currently unable to connect to this service. Please refresh the page and try again. If the problem persists, please',
contactSupport: 'contact support',
pleaseRefresh: 'Please refresh and try again or ',
failedFetch: 'Failed to fetch filters saved',
failedFetchFilters: 'Failed to fetch Saved Filters',
failedFetchSets: 'Failed to fetch Saved Sets',
contactSupport: 'contact our support',
},
savedFilters: {
title: 'My Filters',
Expand Down
12 changes: 10 additions & 2 deletions src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ const fr = {
404: "Désolé, cette page n'existe pas.",
500: 'Désolé, quelque chose en va pas.',
backHome: 'Retour accueil',
query: {
notFound: {
title: 'Requête introuvable',
content: `Nous n'avons pas pu charger votre requête. Veuillez réessayer ou <a href="{href}" style="text-decoration: underline;" target="_blank">contacter le support</a>.`,
okText: 'Fermer',
},
},
},
notification: {
genericError: 'Une erreur est apparue',
Expand Down Expand Up @@ -1046,9 +1053,10 @@ const fr = {
title: 'Erreur de connexion',
subtitle:
'Nous ne sommes actuellement pas en mesure de nous connecter à ce service. Veuillez actualiser la page et réessayer. Si le problème persiste, veuillez',
contactSupport: 'contactez le support',
pleaseRefresh: 'Veuillez actualiser et réessayer ou ',
failedFetch: 'Échec de la récupération des filtres sauvegardés',
failedFetchFilters: 'Échec de la récupération des filtres sauvegardés',
failedFetchSets: 'Échec de la récupération des ensembles sauvegardés',
contactSupport: 'contactez le support',
},
savedFilters: {
title: 'Mes filtres',
Expand Down
3 changes: 1 addition & 2 deletions src/store/savedFilter/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ const savedFilterSlice = createSlice({
savedFilters: sortByUpdateDate(action.payload),
isLoading: false,
}));
builder.addCase(fetchSavedFilters.rejected, (state, action) => ({
builder.addCase(fetchSavedFilters.rejected, (state) => ({
...state,
fetchingError: action.payload,
isLoading: false,
}));
// Fetch Shared
Expand Down
11 changes: 11 additions & 0 deletions src/store/savedFilter/thunks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import intl from 'react-intl-universal';
import { setQueryBuilderState } from '@ferlab/ui/core/components/QueryBuilder/utils/useQueryBuilderState';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { Modal } from 'antd';
import isEmpty from 'lodash/isEmpty';
import { v4 } from 'uuid';

Expand All @@ -14,6 +15,8 @@ import {
import { globalActions } from 'store/global';
import { handleThunkApiReponse } from 'store/utils';

import { SUPPORT_EMAIL } from '../report/thunks';

const fetchSavedFilters = createAsyncThunk<
TUserSavedFilter[],
void | string,
Expand Down Expand Up @@ -44,6 +47,14 @@ const fetchSharedSavedFilter = createAsyncThunk<

return handleThunkApiReponse({
error,
onError: () =>
Modal.error({
content: intl.getHTML('global.errors.query.notFound.content', {
href: `mailto:${SUPPORT_EMAIL}`,
}),
okText: intl.get('global.errors.query.notFound.okText'),
title: intl.get('global.errors.query.notFound.title'),
}),
data: data,
reject: thunkAPI.rejectWithValue,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ const getItemList = (
locale={{
emptyText: fetchingError ? (
<CardErrorPlaceholder
title={intl.get('screen.dashboard.cards.error.failedFetch')}
title={intl.get('screen.dashboard.cards.error.failedFetchFilters')}
subTitle={
<Text>
{intl.get('screen.dashboard.cards.pleaseRefresh')}
{intl.get('screen.dashboard.cards.error.pleaseRefresh')}
<ExternalLink href={`mailto:${SUPPORT_EMAIL}`}>
<Text>{intl.get('screen.dashboard.cards.savedFilters.contact')}</Text>
<Text>{intl.get('screen.dashboard.cards.error.contactSupport')}</Text>
</ExternalLink>
.
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const getItemList = (
locale={{
emptyText: fetchingError ? (
<CardErrorPlaceholder
title={intl.get('screen.dashboard.cards.error.failedFetch')}
title={intl.get('screen.dashboard.cards.error.failedFetchSets')}
subTitle={
<Text>
{intl.get('screen.dashboard.cards.pleaseRefresh')}
{intl.get('screen.dashboard.cards.error.pleaseRefresh')}
<ExternalLink href={`mailto:${SUPPORT_EMAIL}`}>
<Text>{intl.get('screen.dashboard.cards.contact')}</Text>
<Text>{intl.get('screen.dashboard.cards.error.contactSupport')}</Text>
</ExternalLink>
.
</Text>
Expand Down
1 change: 1 addition & 0 deletions src/views/DataExploration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const DataExploration = () => {
},
});
if (data) setQuickFilterData(data?.data);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(activeQuery)]);

useEffect(() => {
Expand Down

0 comments on commit f2c64b9

Please sign in to comment.