Skip to content

Commit

Permalink
Fix notification display in event metadata tab
Browse files Browse the repository at this point in the history
Notifications were not being rendered in the
metadata tab of the event details, especially the
"Active Workflow"-notification. This patch fixes that.

This patch also fixes:
- The "Active Workflow"-notification being rendered
multiple times.
- The "Active Workflow"-notification being
rendered even when there is no active workflow
anymore.
  • Loading branch information
Arnei committed Dec 18, 2024
1 parent fba544d commit ae4fbd6
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/components/configuration/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const Themes = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const GeneralPage = <T,>({
<div className="full-col">
<div className="form-container">
<div className="row">
<Notifications />
<Notifications context={"other"}/>
<label className="required" style={isEdit ? editStyle: undefined}>
{t("CONFIGURATION.THEMES.DETAILS.GENERAL.NAME")}
</label>
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const Events = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
<div className="filters-container">
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const Series = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
<div className="filters-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const DetailsMetadataTab = ({
<>
<div className="modal-content">
<div className="modal-body">
<Notifications context="not-corner" />
<Notifications context="not_corner" />
<div className="full-col">
<div className="obj tbl-list">
<header className="no-expand">{t(header)}</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const EventDetailsCommentsTab = ({
return (
<div className="modal-content">
<div className="modal-body">
<Notifications context="not-corner" />
<Notifications context="not_corner" />
<div className="full-col">
<div className="obj comments">
<header>{t(header)}</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const EventDetailsPublicationTab = ({
<>
<div className="modal-content">
<div className="modal-body">
<Notifications />
<Notifications context={"other"}/>
<div className="full-col">
<div className="obj list-obj">
<header>{t("EVENTS.EVENTS.DETAILS.PUBLICATIONS.CAPTION")}</header>
Expand Down
31 changes: 30 additions & 1 deletion src/components/events/partials/modals/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ import {
fetchEventStatistics,
openModalTab,
fetchEventDetailsTobira,
fetchHasActiveTransactions,
} from "../../../../slices/eventDetailsSlice";
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
import { addNotification, removeNotificationByKey, removeNotificationWizardForm } from "../../../../slices/notificationSlice";
import DetailsTobiraTab from "../ModalTabsAndPages/DetailsTobiraTab";
import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig";
import { unwrapResult } from "@reduxjs/toolkit";

export enum EventDetailsPage {
Metadata,
Expand Down Expand Up @@ -84,6 +87,32 @@ const EventDetails = ({
dispatch(fetchSchedulingInfo(eventId)).then();
dispatch(fetchEventStatistics(eventId)).then();
dispatch(fetchAssetUploadOptions()).then();

dispatch(fetchHasActiveTransactions(eventId)).then((fetchTransactionResult) => {
const result = unwrapResult(fetchTransactionResult)
if (result.active !== undefined && result.active) {
dispatch(
addNotification({
type: "warning",
key: "ACTIVE_TRANSACTION",
duration: -1,
parameter: undefined,
context: NOTIFICATION_CONTEXT,
noDuplicates: true
})
)
}
if (result.active !== undefined && !result.active) {
dispatch(
removeNotificationByKey({
key: "ACTIVE_TRANSACTION",
context: NOTIFICATION_CONTEXT
})
)
}
});


// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down
2 changes: 1 addition & 1 deletion src/components/recordings/Recordings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Recordings = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
8 changes: 7 additions & 1 deletion src/components/shared/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ import {
import { useAppDispatch, useAppSelector } from "../../store";
import { OurNotification, setHidden } from "../../slices/notificationSlice";

type Context = "not_corner" | "tobira" | "above_table" | "other"

/**
* This component renders notifications about occurred errors, warnings and info
*/
const Notifications : React.FC<{ context?: string }> = ({ context }) => {
const Notifications = ({
context,
}: {
context: Context,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ const ResourceDetailsAccessPolicyTab = ({
key: "ACTIVE_TRANSACTION",
duration: -1,
parameter: undefined,
context: NOTIFICATION_CONTEXT
context: NOTIFICATION_CONTEXT,
noDuplicates: true,
}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/systems/Jobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const Jobs = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
2 changes: 1 addition & 1 deletion src/components/systems/Servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const Servers = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
2 changes: 1 addition & 1 deletion src/components/systems/Services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const Services = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/Acls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const Acls: React.FC = () => {
</Link>
)}
</nav>

{/* Add acl button */}
<div className="btn-group">
{hasAccess("ROLE_UI_ACLS_CREATE", user) && (
Expand All @@ -159,7 +159,7 @@ const Acls: React.FC = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/Groups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const Groups = () => {
</Link>
)}
</nav>

{/* Add group button */}
<div className="btn-group">
{hasAccess("ROLE_UI_GROUPS_CREATE", user) && (
Expand All @@ -159,7 +159,7 @@ const Groups = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
4 changes: 2 additions & 2 deletions src/components/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const Users: React.FC = () => {
</Link>
)}
</nav>

{/* Add user button */}
<div className="btn-group">
{hasAccess("ROLE_UI_USERS_CREATE", user) && (
Expand All @@ -159,7 +159,7 @@ const Users: React.FC = () => {

<MainView open={displayNavigation}>
{/* Include notifications component */}
<Notifications />
<Notifications context={"other"}/>

<div className="controls-container">
{/* Include filters component */}
Expand Down
2 changes: 1 addition & 1 deletion src/components/users/partials/wizard/NewAclSummaryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const NewAclSummaryPage = <T extends RequiredFormProps>({
<div className="modal-content">
<div className="modal-body">
<div className="full-col">
<Notifications />
<Notifications context={"other"}/>
<div className="obj tbl-list">
<header className="no-expand">{t("")}</header>
<div className="obj-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const NewGroupSummaryPage = <T extends typeof initialFormValuesNewGroup>({
<div className="modal-content">
<div className="modal-body">
<div className="full-col">
<Notifications />
<Notifications context={"other"}/>

<div className="obj">
<header>{t("USERS.GROUPS.DETAILS.FORM.SUMMARY")}</header>
Expand Down
2 changes: 1 addition & 1 deletion src/components/users/partials/wizard/NewUserGeneralTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const NewUserGeneralTab = <T extends RequiredFormProps>({
<div className="modal-content">
<div className="modal-body">
<div className="form-container">
<Notifications />
<Notifications context={"other"}/>
{/* Fields for user information needed */}
<div className="row">
<label>
Expand Down
12 changes: 0 additions & 12 deletions src/slices/eventDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,6 @@ export const fetchAssets = createAppAsyncThunk('eventDetails/fetchAssets', async
uploadAssetOptions =
uploadAssetOptions.length > 0 ? uploadAssetOptions : undefined;

if (transactionsReadOnly) {
dispatch(
addNotification({
type: "warning",
key: "ACTIVE_TRANSACTION",
duration: -1,
parameter: undefined,
context: NOTIFICATION_CONTEXT
})
);
}

return { assets, transactionsReadOnly, uploadAssetOptions }
});

Expand Down

0 comments on commit ae4fbd6

Please sign in to comment.