Skip to content

Commit 59c3bb9

Browse files
committed
Merge branch 'filters-set-for-all-tables' of Arnei/opencast-admin-interface into r/17.x
Pull request #1329 Fixes #1284 Fix service and servers filters being applied to the wrong tables
2 parents 9842665 + c4374e4 commit 59c3bb9

8 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/components/events/partials/EventsLocationCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const EventsLocationCell = ({
2323
const addFilter = (location: string) => {
2424
let filter = filterMap.find(({ name }) => name === "location");
2525
if (!!filter) {
26-
dispatch(editFilterValue({filterName: filter.name, value: location}));
26+
dispatch(editFilterValue({filterName: filter.name, value: location, resource: "events"}));
2727
dispatch(fetchEvents());
2828
dispatch(loadEventsIntoTable());
2929
}

src/components/events/partials/EventsSeriesCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const EventsSeriesCell = ({
2323
const addFilter = async (seriesId: string) => {
2424
let filter = filterMap.find(({ name }) => name === "series");
2525
if (!!filter) {
26-
await dispatch(editFilterValue({filterName: filter.name, value: seriesId}));
26+
await dispatch(editFilterValue({filterName: filter.name, value: seriesId, resource: "events"}));
2727
await dispatch(fetchEvents());
2828
dispatch(loadEventsIntoTable());
2929
}

src/components/events/partials/EventsTechnicalDateCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const EventsTechnicalDateCell = ({
2626
const addFilter = async (date: string) => {
2727
let filter = filterMap.find(({ name }) => name === "technicalStart");
2828
if (!!filter) {
29-
await dispatch(editFilterValue({filterName: filter.name, value: date + "/" + date}));
29+
await dispatch(editFilterValue({filterName: filter.name, value: date + "/" + date, resource: "events"}));
3030
await dispatch(fetchEvents());
3131
dispatch(loadEventsIntoTable());
3232
}

src/components/shared/DateTimeCell.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { renderValidDate } from "../../utils/dateUtils";
77
import { IconButton } from "../shared/IconButton";
88
import { ParseKeys } from "i18next";
99
import { AsyncThunk } from "@reduxjs/toolkit";
10+
import { Resource } from "../../slices/tableSlice";
1011

1112
/**
1213
* This component renders the start date cells of events in the table view
@@ -19,7 +20,7 @@ const DateTimeCell = ({
1920
loadResourceIntoTable,
2021
tooltipText,
2122
}: {
22-
resource: string
23+
resource: Resource
2324
date: string
2425
filterName: string
2526
fetchResource: AsyncThunk<any, void, any>
@@ -44,7 +45,7 @@ const DateTimeCell = ({
4445
endDate.setMinutes(59);
4546
endDate.setSeconds(59);
4647

47-
await dispatch(editFilterValue({filterName: filter.name, value: startDate.toISOString() + "/" + endDate.toISOString()}));
48+
await dispatch(editFilterValue({filterName: filter.name, value: startDate.toISOString() + "/" + endDate.toISOString(), resource}));
4849
await dispatch(fetchResource());
4950
dispatch(loadResourceIntoTable());
5051
}

src/components/shared/MultiValueCell.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AppThunk, useAppDispatch, useAppSelector } from "../../store";
55
import { IconButton } from "../shared/IconButton";
66
import { AsyncThunk } from "@reduxjs/toolkit";
77
import { ParseKeys } from "i18next";
8+
import { Resource } from "../../slices/tableSlice";
89

910
/**
1011
* This component renders the presenters cells of events in the table view
@@ -17,7 +18,7 @@ const MultiValueCell = ({
1718
loadResourceIntoTable,
1819
tooltipText,
1920
}: {
20-
resource: string
21+
resource: Resource
2122
values: string[]
2223
filterName: string
2324
fetchResource: AsyncThunk<any, void, any>
@@ -34,7 +35,7 @@ const MultiValueCell = ({
3435
({ name }) => name === filterName
3536
);
3637
if (!!filter) {
37-
await dispatch(editFilterValue({filterName: filter.name, value: presenter}));
38+
await dispatch(editFilterValue({filterName: filter.name, value: presenter, resource}));
3839
await dispatch(fetchResource());
3940
dispatch(loadResourceIntoTable());
4041
}

src/components/shared/Stats.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Stats = () => {
3838
let filter = filterMap.find(({ name }) => name === f.name);
3939
filterValue = f.value;
4040
if (!!filter) {
41-
dispatch(editFilterValue({filterName: filter.name, value: filterValue}));
41+
dispatch(editFilterValue({filterName: filter.name, value: filterValue, resource: "events"}));
4242
}
4343
});
4444
await dispatch(fetchEvents());

src/components/shared/TableFilters.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import DropDown from "./DropDown";
3131
import { AsyncThunk } from "@reduxjs/toolkit";
3232
import ButtonLikeAnchor from "./ButtonLikeAnchor";
3333
import { ParseKeys } from "i18next";
34+
import { Resource } from "../../slices/tableSlice";
3435

3536
/**
3637
* This component renders the table filters in the upper right corner of the table
@@ -42,7 +43,7 @@ const TableFilters = ({
4243
}: {
4344
loadResource: AsyncThunk<any, void, any>,
4445
loadResourceIntoTable: () => AppThunk,
45-
resource: string,
46+
resource: Resource,
4647
}) => {
4748
const { t } = useTranslation();
4849
const dispatch = useAppDispatch();
@@ -91,7 +92,7 @@ const TableFilters = ({
9192
setEndDate(undefined);
9293
}
9394

94-
dispatch(editFilterValue({filterName: filter.name, value: ""}));
95+
dispatch(editFilterValue({filterName: filter.name, value: "", resource}));
9596

9697
// Reload resources when filter is removed
9798
await dispatch(loadResource());
@@ -116,7 +117,7 @@ const TableFilters = ({
116117
if (name === "secondFilter") {
117118
let filter = filterMap.find(({ name }) => name === selectedFilter);
118119
if (!!filter) {
119-
dispatch(editFilterValue({filterName: filter.name, value: value}));
120+
dispatch(editFilterValue({filterName: filter.name, value: value, resource}));
120121
setFilterSelector(false);
121122
dispatch(removeSelectedFilter());
122123
dispatch(removeSecondFilter());
@@ -195,7 +196,8 @@ const TableFilters = ({
195196
if (filter) {
196197
dispatch(editFilterValue({
197198
filterName: filter.name,
198-
value: start.toISOString() + "/" + end.toISOString()
199+
value: start.toISOString() + "/" + end.toISOString(),
200+
resource
199201
}));
200202
setFilterSelector(false);
201203
dispatch(removeSelectedFilter());

src/slices/tableFilterSlice.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import axios from 'axios';
33
import { relativeDateSpanToFilterValue } from '../utils/dateUtils';
44
import { createAppAsyncThunk } from '../createAsyncThunkWithTypes';
55
import { FilterProfile } from './tableFilterProfilesSlice';
6+
import { Resource } from './tableSlice';
67

78
/**
89
* This file contains redux reducer for actions affecting the state of table filters
@@ -174,7 +175,8 @@ export const setSpecificEventFilter = createAppAsyncThunk('tableFilters/setSpeci
174175
if (!!filterToChange) {
175176
await dispatch(editFilterValue({
176177
filterName: filterToChange.name,
177-
value: filterValue
178+
value: filterValue,
179+
resource: "events"
178180
}));
179181
}
180182
});
@@ -195,7 +197,8 @@ export const setSpecificServiceFilter = createAppAsyncThunk('tableFilters/setSpe
195197
if (!!filterToChange) {
196198
await dispatch(editFilterValue({
197199
filterName: filterToChange.name,
198-
value: filterValue
200+
value: filterValue,
201+
resource: "services"
199202
}));
200203
}
201204
});
@@ -290,10 +293,11 @@ const tableFilterSlice = createSlice({
290293
editFilterValue(state, action: PayloadAction<{
291294
filterName: TableFilterState["data"][0]["name"],
292295
value: TableFilterState["data"][0]["value"],
296+
resource: Resource
293297
}>) {
294-
const { filterName, value } = action.payload;
298+
const { filterName, value, resource } = action.payload;
295299
state.data = state.data.map((filter) => {
296-
return filter.name === filterName
300+
return filter.name === filterName && filter.resource === resource
297301
? { ...filter, value: value }
298302
: filter;
299303
})

0 commit comments

Comments
 (0)