Skip to content

Commit

Permalink
Always open series details modal on the first page again
Browse files Browse the repository at this point in the history
Due to the previous commit, the current modal page is no longer local state
that is cleaned up when the series details modal is unmounted.
  • Loading branch information
JulianKniephoff committed Nov 14, 2024
1 parent b001953 commit fb27bc0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/components/events/partials/EventActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SeriesDetailsModal from "./modals/SeriesDetailsModal";
import { EventDetailsPage } from "./modals/EventDetails";
import { useAppDispatch, useAppSelector } from "../../../store";
import {
openModal as openSeriesModal,
fetchSeriesDetailsAcls,
fetchSeriesDetailsFeeds,
fetchSeriesDetailsMetadata,
Expand All @@ -16,7 +17,7 @@ import {
} from "../../../slices/seriesDetailsSlice";
import { Event, deleteEvent } from "../../../slices/eventSlice";
import { Tooltip } from "../../shared/Tooltip";
import { openModal } from "../../../slices/eventDetailsSlice";
import { openModal as openEventModal } from "../../../slices/eventDetailsSlice";

/**
* This component renders the action cells of events in the table view
Expand Down Expand Up @@ -67,24 +68,26 @@ const EventActionCell = ({
await dispatch(fetchSeriesDetailsTheme(row.series.id));
await dispatch(fetchSeriesDetailsThemeNames());

dispatch(openSeriesModal());

showSeriesDetailsModal();
}
};

const onClickEventDetails = () => {
dispatch(openModal(EventDetailsPage.Metadata, row));
dispatch(openEventModal(EventDetailsPage.Metadata, row));
};

const onClickComments = () => {
dispatch(openModal(EventDetailsPage.Comments, row));
dispatch(openEventModal(EventDetailsPage.Comments, row));
};

const onClickWorkflow = () => {
dispatch(openModal(EventDetailsPage.Workflow, row));
dispatch(openEventModal(EventDetailsPage.Workflow, row));
};

const onClickAssets = () => {
dispatch(openModal(EventDetailsPage.Assets, row));
dispatch(openEventModal(EventDetailsPage.Assets, row));
};

return (
Expand Down
3 changes: 3 additions & 0 deletions src/components/events/partials/SeriesActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
fetchSeriesDetailsMetadata,
fetchSeriesDetailsTheme,
fetchSeriesDetailsTobira,
openModal,
} from "../../../slices/seriesDetailsSlice";
import { getUserInformation } from "../../../selectors/userInfoSelectors";
import { hasAccess } from "../../../utils/utils";
Expand Down Expand Up @@ -69,6 +70,8 @@ const SeriesActionsCell = ({
await dispatch(fetchSeriesDetailsThemeNames());
await dispatch(fetchSeriesDetailsTobira(row.id));

dispatch(openModal());

setSeriesDetailsModal(true);
};

Expand Down
7 changes: 6 additions & 1 deletion src/slices/seriesDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Statistics, fetchStatistics, fetchStatisticsValueUpdate } from './stati
import { Ace } from './aclSlice';
import { TransformedAcl } from './aclDetailsSlice';
import { MetadataCatalog } from './eventSlice';
import { AppDispatch } from '../store';

/**
* This file contains redux reducer for actions affecting the state of a series
Expand All @@ -30,12 +31,12 @@ export type Feed = {
version: string,
}


// Contains the navigation logic for the modal
type SeriesDetailsModal = {
page: number,
}


type SeriesDetailsState = {
statusMetadata: 'uninitialized' | 'loading' | 'succeeded' | 'failed',
errorMetadata: SerializedError | null,
Expand Down Expand Up @@ -115,6 +116,10 @@ const initialState: SeriesDetailsState = {
},
};

export const openModal = () => (dispatch: AppDispatch) => {
dispatch(setModalPage(0));
};

// fetch metadata of certain series from server
export const fetchSeriesDetailsMetadata = createAppAsyncThunk('seriesDetails/fetchSeriesDetailsMetadata', async (id: string, { rejectWithValue }) => {
const res = await axios.get(`/admin-ng/series/${id}/metadata.json`);
Expand Down

0 comments on commit fb27bc0

Please sign in to comment.