Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into to-redux-toolkit-table
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnei committed Jun 21, 2024
2 parents 57c0a2b + e6cb18f commit ef96dda
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 22 deletions.
18 changes: 11 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"serve": "vite preview",
"test": "vitest"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
11 changes: 10 additions & 1 deletion src/components/events/partials/EventsDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ const EventsDateCell = ({
const addFilter = async (date: string) => {
let filter = filterMap.find(({ name }) => name === "startDate");
if (!!filter) {
await dispatch(editFilterValue({filterName: filter.name, value: date + "/" + date}));
let startDate = new Date(date);
startDate.setHours(0);
startDate.setMinutes(0);
startDate.setSeconds(0);
let endDate = new Date(date);
endDate.setHours(23);
endDate.setMinutes(59);
endDate.setSeconds(59);

await dispatch(editFilterValue({filterName: filter.name, value: startDate.toISOString() + "/" + endDate.toISOString()}));
await dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
}
Expand Down
21 changes: 21 additions & 0 deletions src/components/events/partials/ModalTabsAndPages/NewAccessPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { hasAccess } from "../../../../utils/utils";
import DropDown from "../../../shared/DropDown";
import { filterRoles, getAclTemplateText } from "../../../../utils/aclUtils";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { fetchSeriesDetailsAcls } from "../../../../slices/seriesDetailsSlice";
import { getSeriesDetailsAcl } from "../../../../selectors/seriesDetailsSelectors";

/**
* This component renders the access page for new events and series in the wizards.
Expand All @@ -30,6 +32,8 @@ const NewAccessPage = ({
formik,
// @ts-expect-error TS(7031): Binding element 'editAccessRole' implicitly has an... Remove this comment to see the full error message
editAccessRole,
// @ts-expect-error TS(7031): Binding element 'checkAcls' implicitly has an 'any... Remove this comment to see the full error messag
initEventAclWithSeriesAcl //boolean
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
Expand All @@ -41,6 +45,7 @@ const NewAccessPage = ({
const [loading, setLoading] = useState(false);

const user = useAppSelector(state => getUserInformation(state));
const seriesAcl = useAppSelector(state => getSeriesDetailsAcl(state));

useEffect(() => {
// fetch data about roles, acl templates and actions from backend
Expand All @@ -58,6 +63,22 @@ const NewAccessPage = ({
fetchData();
}, []);

// If we have to use series ACL, fetch it
useEffect(() => {
if (initEventAclWithSeriesAcl && formik.values.isPartOf) {
dispatch(fetchSeriesDetailsAcls(formik.values.isPartOf))
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formik.values, initEventAclWithSeriesAcl]);

// If we have to use series ACL, overwrite existing rules
useEffect(() => {
if (initEventAclWithSeriesAcl && formik.values.isPartOf && seriesAcl) {
formik.setFieldValue("acls", seriesAcl)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [initEventAclWithSeriesAcl, seriesAcl]);

// @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
const handleTemplateChange = async (value) => {
// fetch information about chosen template from backend
Expand Down
13 changes: 11 additions & 2 deletions src/components/events/partials/wizards/NewEventWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
getExtendedEventMetadata,
} from "../../../../selectors/eventSelectors";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
import { MetadataCatalog, UploadAssetOption, postNewEvent } from "../../../../slices/eventSlice";
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
import { UserInfoState } from "../../../../slices/userInfoSlice";

/**
Expand All @@ -36,12 +36,20 @@ const NewEventWizard: React.FC<{
const metadataFields = useAppSelector(state => getEventMetadata(state));
const extendedMetadata = useAppSelector(state => getExtendedEventMetadata(state));
const user = useAppSelector(state => getUserInformation(state));
const orgProperties = useAppSelector(state => getOrgProperties(state));

// Whether the ACL of a new event is initialized with the ACL of its series.
let initEventAclWithSeriesAcl = true
const ADMIN_INIT_EVENT_ACL_WITH_SERIES_ACL = "admin.init.event.acl.with.series.acl";
if (!!orgProperties && !!orgProperties[ADMIN_INIT_EVENT_ACL_WITH_SERIES_ACL]) {
initEventAclWithSeriesAcl = user.org.properties[ADMIN_INIT_EVENT_ACL_WITH_SERIES_ACL] === 'true';
}

const initialValues = getInitialValues(
metadataFields,
extendedMetadata,
uploadAssetOptions,
user
user,
);

const [page, setPage] = useState(0);
Expand Down Expand Up @@ -193,6 +201,7 @@ const NewEventWizard: React.FC<{
nextPage={nextPage}
formik={formik}
editAccessRole="ROLE_UI_SERIES_DETAILS_ACL_EDIT"
initEventAclWithSeriesAcl={initEventAclWithSeriesAcl}
/>
)}
{page === 6 && (
Expand Down
1 change: 1 addition & 0 deletions src/components/events/partials/wizards/NewSeriesWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ const NewSeriesWizard: React.FC<{
previousPage={previousPage}
formik={formik}
editAccessRole="ROLE_UI_SERIES_DETAILS_ACL_EDIT"
initEventAclWithSeriesAcl={false}
/>
)}
{page === 3 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"COMMIT": "Git commit this version of Opencast was built from.",
"VERSION": "Common bundle version of Opencast modules"
},
"NO": "No",
"NO": "Nej",
"SUBMIT": "Submit",
"UPDATE": {
"MINOR": "Minor update available",
Expand Down
1 change: 1 addition & 0 deletions src/slices/eventDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@ export const saveAccessPolicies = createAsyncThunk('eventDetails/saveAccessPolic
.post(`/admin-ng/event/${eventId}/access`, data.toString(), headers)
.then((response) => {
console.info(response);
dispatch(fetchAccessPolicies(eventId))
dispatch(
addNotification({
type: "info",
Expand Down
6 changes: 4 additions & 2 deletions src/slices/tableSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ const initialState: TableState = {
resource: "",
pages: [],
columns: [],
sortBy: "",
sortBy: "date",
predicate: "",
reverse: "ASC",
reverse: "DESC",
rows: [],
maxLabel: "",
pagination: {
Expand All @@ -115,6 +115,7 @@ const tableSlice = createSlice({
pages: TableState["pages"],
rows: TableState["rows"],
sortBy: TableState["sortBy"],
reverse: TableState["reverse"],
totalItems: TableState["pagination"]["totalItems"],
}>) {
state.multiSelect = action.payload.multiSelect;
Expand All @@ -123,6 +124,7 @@ const tableSlice = createSlice({
state.pages = action.payload.pages;
state.rows = action.payload.rows;
state.sortBy = action.payload.sortBy;
state.reverse = action.payload.reverse;
state.pagination = {
...state.pagination,
totalItems: action.payload.totalItems,
Expand Down
6 changes: 5 additions & 1 deletion src/styles/components/_steps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@

.step-by-step {

.MuiStepLabel-iconContainer svg {
color: $color-gray !important;
}

.MuiStepLabel-labelContainer span {
color: #92a0ab;
color: $color-darkgray;
margin: 3px 10px;
position: relative;
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ div.table-filter {
}

.ng-multi-value {
padding: 5px;
align-self: center;
}

.MuiInputBase-root {
Expand Down
Loading

0 comments on commit ef96dda

Please sign in to comment.