Skip to content

Commit 9511948

Browse files
authored
Merge pull request #1048 from Arnei/hide-tobira-tab
Properly hide Tobira tab
2 parents ce64009 + 668e0da commit 9511948

5 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/components/events/partials/modals/EventDetails.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
getModalWorkflowTabHierarchy,
2727
getModalPage,
2828
getEventDetailsTobiraDataError,
29+
getEventDetailsTobiraStatus,
2930
} from "../../../../selectors/eventDetailsSelectors";
3031
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
3132
import EventDetailsStatisticsTab from "../ModalTabsAndPages/EventDetailsStatisticsTab";
@@ -84,6 +85,7 @@ const EventDetails = ({
8485
dispatch(fetchSchedulingInfo(eventId)).then();
8586
dispatch(fetchEventStatistics(eventId)).then();
8687
dispatch(fetchAssetUploadOptions()).then();
88+
dispatch(fetchEventDetailsTobira(eventId));
8789
// eslint-disable-next-line react-hooks/exhaustive-deps
8890
}, []);
8991

@@ -98,6 +100,7 @@ const EventDetails = ({
98100
const hasStatistics = useAppSelector(state => getHasStatistics(state));
99101
const isLoadingStatistics = useAppSelector(state => isFetchingStatistics(state));
100102
const captureAgents = useAppSelector(state => getRecordings(state));
103+
const tobiraStatus = useAppSelector(state => getEventDetailsTobiraStatus(state));
101104
const tobiraError = useAppSelector(state => getEventDetailsTobiraDataError(state));
102105

103106
const tabs = [
@@ -164,7 +167,7 @@ const EventDetails = ({
164167
accessRole: "ROLE_UI_EVENTS_DETAILS_COMMENTS_VIEW",
165168
name: "tobira",
166169
page: EventDetailsPage.Tobira,
167-
hidden: tobiraError?.message?.includes("503"),
170+
hidden: tobiraStatus === "failed" && tobiraError?.message?.includes("503"),
168171
},
169172
{
170173
tabNameTranslation: "EVENTS.EVENTS.DETAILS.TABS.STATISTICS",
@@ -178,9 +181,6 @@ const EventDetails = ({
178181

179182
const openTab = (tabNr: EventDetailsPage) => {
180183
dispatch(removeNotificationWizardForm());
181-
if (tabNr === EventDetailsPage.Tobira) {
182-
dispatch(fetchEventDetailsTobira(eventId));
183-
}
184184
dispatch(openModalTab(tabNr, "entry", "entry"))
185185
};
186186

src/components/events/partials/modals/SeriesDetails.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getSeriesDetailsTheme,
99
getSeriesDetailsThemeNames,
1010
getSeriesDetailsTobiraDataError,
11+
getSeriesDetailsTobiraStatus,
1112
hasStatistics as seriesHasStatistics,
1213
} from "../../../../selectors/seriesDetailsSelectors";
1314
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
@@ -20,6 +21,7 @@ import DetailsMetadataTab from "../ModalTabsAndPages/DetailsMetadataTab";
2021
import DetailsExtendedMetadataTab from "../ModalTabsAndPages/DetailsExtendedMetadataTab";
2122
import { useAppDispatch, useAppSelector } from "../../../../store";
2223
import {
24+
fetchSeriesDetailsTobira,
2325
fetchSeriesStatistics,
2426
setTobiraTabHierarchy,
2527
updateExtendedSeriesMetadata,
@@ -48,10 +50,12 @@ const SeriesDetails = ({
4850
const theme = useAppSelector(state => getSeriesDetailsTheme(state));
4951
const themeNames = useAppSelector(state => getSeriesDetailsThemeNames(state));
5052
const hasStatistics = useAppSelector(state => seriesHasStatistics(state));
53+
const tobiraStatus = useAppSelector(state => getSeriesDetailsTobiraStatus(state));
5154
const tobiraError = useAppSelector(state => getSeriesDetailsTobiraDataError(state));
5255

5356
useEffect(() => {
5457
dispatch(fetchSeriesStatistics(seriesId));
58+
dispatch(fetchSeriesDetailsTobira(seriesId));
5559
dispatch(setTobiraTabHierarchy("main"));
5660
// eslint-disable-next-line react-hooks/exhaustive-deps
5761
}, []);
@@ -90,7 +94,7 @@ const SeriesDetails = ({
9094
tabNameTranslation: "EVENTS.SERIES.DETAILS.TABS.TOBIRA",
9195
accessRole: "ROLE_UI_SERIES_DETAILS_TOBIRA_VIEW",
9296
name: "tobira",
93-
hidden: tobiraError?.message?.includes("503"),
97+
hidden: tobiraStatus === "failed" && tobiraError?.message?.includes("503"),
9498
},
9599
{
96100
tabNameTranslation: "EVENTS.SERIES.DETAILS.TABS.STATISTICS",

src/components/events/partials/wizards/NewSeriesWizard.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
getSeriesExtendedMetadata,
77
getSeriesMetadata,
88
getSeriesTobiraPageError,
9+
getSeriesTobiraPageStatus,
910
} from "../../../../selectors/seriesSeletctor";
1011
import NewMetadataPage from "../ModalTabsAndPages/NewMetadataPage";
1112
import NewMetadataExtendedPage from "../ModalTabsAndPages/NewMetadataExtendedPage";
@@ -15,7 +16,7 @@ import { initialFormValuesNewSeries } from "../../../../configs/modalConfig";
1516
import { MetadataSchema, NewSeriesSchema } from "../../../../utils/validate";
1617
import { getInitialMetadataFieldValues } from "../../../../utils/resourceUtils";
1718
import { useAppDispatch, useAppSelector } from "../../../../store";
18-
import { TobiraPage, postNewSeries } from "../../../../slices/seriesSlice";
19+
import { TobiraPage, fetchSeriesDetailsTobiraNew, postNewSeries } from "../../../../slices/seriesSlice";
1920
import { MetadataCatalog } from "../../../../slices/eventSlice";
2021
import NewTobiraPage from "../ModalTabsAndPages/NewTobiraPage";
2122
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
@@ -34,6 +35,7 @@ const NewSeriesWizard: React.FC<{
3435

3536
const metadataFields = useAppSelector(state => getSeriesMetadata(state));
3637
const extendedMetadata = useAppSelector(state => getSeriesExtendedMetadata(state));
38+
const tobiraStatus = useAppSelector(state => getSeriesTobiraPageStatus(state));
3739
const tobiraError = useAppSelector(state => getSeriesTobiraPageError(state));
3840
const user = useAppSelector(state => getUserInformation(state));
3941
const orgProperties = useAppSelector(state => getOrgProperties(state));
@@ -46,6 +48,13 @@ const NewSeriesWizard: React.FC<{
4648
const [snapshot, setSnapshot] = useState(initialValues);
4749
const [pageCompleted, setPageCompleted] = useState<{ [key: number]: boolean }>({});
4850

51+
useEffect(() => {
52+
// This should set off a web request that will intentionally fail, in order
53+
// to check if tobira is available at all
54+
dispatch(fetchSeriesDetailsTobiraNew(""));
55+
// eslint-disable-next-line react-hooks/exhaustive-deps
56+
}, []);
57+
4958
// Caption of steps used by Stepper
5059
const steps = [
5160
{
@@ -71,7 +80,7 @@ const NewSeriesWizard: React.FC<{
7180
{
7281
translation: "EVENTS.SERIES.NEW.TOBIRA.CAPTION",
7382
name: "tobira",
74-
hidden: !!tobiraError?.message?.includes("503"),
83+
hidden: !!(tobiraStatus === "failed" && tobiraError?.message?.includes("503")),
7584
},
7685
{
7786
translation: "EVENTS.SERIES.NEW.SUMMARY.CAPTION",

src/selectors/seriesDetailsSelectors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const getSeriesDetailsThemeNames = (state: RootState) =>
1313

1414
export const getSeriesDetailsTobiraData = (state: RootState) =>
1515
state.seriesDetails.tobiraData;
16+
export const getSeriesDetailsTobiraStatus = (state: RootState) =>
17+
state.seriesDetails.statusTobiraData;
1618
export const getSeriesDetailsTobiraDataError = (state: RootState) =>
1719
state.seriesDetails.errorTobiraData;
1820
export const getTobiraTabHierarchy = (state: RootState) =>

src/slices/shared/tobiraErrors.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type AxiosErrorResponse = {
2424
// as it isn't really helpful and might not even be considered as one (see TODO comment below).
2525
export const handleTobiraError = (response: AxiosErrorResponse, dispatch: AppDispatch) => {
2626
const data = response.response;
27-
console.info(response.message);
2827

2928
if (data.status === 503) {
3029
// TODO: figure out what to do:
@@ -42,7 +41,6 @@ export const handleTobiraError = (response: AxiosErrorResponse, dispatch: AppDis
4241
// context: NOTIFICATION_CONTEXT,
4342
// }));
4443

45-
console.info(data.data);
4644
throw Error(response.message);
4745
} else if (data.status === 500) {
4846
dispatch(addNotification({
@@ -53,7 +51,6 @@ export const handleTobiraError = (response: AxiosErrorResponse, dispatch: AppDis
5351
noDuplicates: true,
5452
}));
5553

56-
console.error(response);
5754
throw Error(response.message);
5855
} else if (data.status === 404) {
5956
dispatch(addNotification({
@@ -64,7 +61,6 @@ export const handleTobiraError = (response: AxiosErrorResponse, dispatch: AppDis
6461
noDuplicates: true,
6562
}));
6663

67-
console.error(response);
6864
throw Error(response.message);
6965
}
7066
};

0 commit comments

Comments
 (0)