Skip to content

Commit

Permalink
Use new endpoint for unmounting series
Browse files Browse the repository at this point in the history
I changed the mount endpoint in opencast,
so now this uses a dedicated endpoint each for
mounting and unmounting.
  • Loading branch information
owi92 committed Dec 10, 2024
1 parent 4b25549 commit aaaaef7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Formik } from "formik";
import { useState } from "react";
import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNavigation";
import NewTobiraPage, { TobiraFormProps } from "./NewTobiraPage";
import { fetchSeriesDetailsTobira, setTobiraTabHierarchy, TobiraData, updateSeriesTobiraPath } from "../../../../slices/seriesDetailsSlice";
import { fetchSeriesDetailsTobira, removeSeriesTobiraPath, setTobiraTabHierarchy, TobiraData, updateSeriesTobiraPath } from "../../../../slices/seriesDetailsSlice";
import { fetchSeriesDetailsTobiraNew, TobiraPage } from "../../../../slices/seriesSlice";
import ConfirmModal from "../../../shared/ConfirmModal";
import { Tooltip } from "../../../shared/Tooltip";
Expand Down Expand Up @@ -95,11 +95,9 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => {
};

const handleDelete = async (hostPage: TobiraPage) => {
await dispatch(updateSeriesTobiraPath({
await dispatch(removeSeriesTobiraPath({
seriesId: id,
currentPath: hostPage.path,
breadcrumbs: [],
remove: true,
})).then(() => dispatch(fetchSeriesDetailsTobira(id)))
}

Expand Down
40 changes: 33 additions & 7 deletions src/slices/seriesDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,10 @@ export const fetchSeriesDetailsTobira = createAppAsyncThunk('seriesDetails/fetch
});

export const updateSeriesTobiraPath = createAppAsyncThunk('series/updateSeriesTobiraData', async (
params: TobiraFormProps & {
seriesId: string,
remove?: boolean,
},
params: TobiraFormProps & { seriesId: string },
{ dispatch },
) => {
const tobiraParams = new URLSearchParams();
const operation = params.remove ? "REMOVED" : "UPDATED";
const pathComponents = params.breadcrumbs.slice(1).map(crumb => ({
name: crumb.title,
pathSegment: crumb.segment,
Expand Down Expand Up @@ -467,7 +463,37 @@ export const updateSeriesTobiraPath = createAppAsyncThunk('series/updateSeriesTo
console.info(response);
dispatch(addNotification({
type: 'success',
key: `SERIES_PATH_${operation}`,
key: 'SERIES_PATH_UPDATED',
context: NOTIFICATION_CONTEXT_TOBIRA,
}));

return response.data;
} catch (error) {
console.error(error);
dispatch(addNotification({
type: 'error',
key: 'SERIES_PATH_NOT_UPDATED',
context: NOTIFICATION_CONTEXT_TOBIRA,
}));
throw error;
}}
);

export const removeSeriesTobiraPath = createAppAsyncThunk('series/removeSeriesTobiraData', async (
params: Required<Pick<TobiraFormProps, 'currentPath'>> & { seriesId: string },
{ dispatch },
) => {
const path = encodeURIComponent(params.currentPath);

try {
const response = await axios.delete(
`/admin-ng/series/${params.seriesId}/tobira/${path}`,
);

console.info(response);
dispatch(addNotification({
type: 'success',
key: 'SERIES_PATH_REMOVED',
context: NOTIFICATION_CONTEXT_TOBIRA,
}));

Expand All @@ -476,7 +502,7 @@ export const updateSeriesTobiraPath = createAppAsyncThunk('series/updateSeriesTo
console.error(error);
dispatch(addNotification({
type: 'error',
key: `SERIES_PATH_NOT_${operation}`,
key: 'SERIES_PATH_NOT_REMOVED',
context: NOTIFICATION_CONTEXT_TOBIRA,
}));
throw error;
Expand Down

0 comments on commit aaaaef7

Please sign in to comment.