Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/components/tree-views-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router';
import {
DirectoriesNotificationType,

Check failure on line 20 in src/components/tree-views-container.tsx

View workflow job for this annotation

GitHub Actions / build / build

Module '"@gridsuite/commons-ui"' has no exported member 'DirectoriesNotificationType'.
type ElementAttributes,
ElementType,
fetchDirectoryContent,
Expand All @@ -40,7 +41,7 @@
setUploadingElements,
} from '../redux/actions';
import DirectoryTreeView from './directory-tree-view';
import { DirectoryInfos, isExportCaseNotification, NotificationType } from '../utils/notificationType';
import { DirectoryInfos, isExportCaseNotification } from '../utils/notificationType';
import * as constants from '../utils/UIconstants';
import { LAST_ELEMENT_INDEX } from '../utils/UIconstants';
import DirectoryTreeContextualMenu from './menus/directory-tree-contextual-menu';
Expand Down Expand Up @@ -490,13 +491,13 @@
function updateDirectory(
directory: DirectoryInfos,
isDirectoryMoving: boolean,
notificationType: NotificationType
notificationType: DirectoriesNotificationType
) {
if (directory.isRoot) {
updateRootDirectories();
if (
selectedDirectoryRef.current != null && // nothing to do if nothing already selected
notificationType === NotificationType.DELETE_DIRECTORY &&
notificationType === DirectoriesNotificationType.DELETE_DIRECTORY &&
selectedDirectoryRef.current.elementUuid === directory.uuid
) {
// Selected root directory deleted: go back to root (selection follows from the URL).
Expand All @@ -511,7 +512,7 @@

// if it's a deleted root directory then do not continue because we don't need
// to fetch its content anymore
if (notificationType === NotificationType.DELETE_DIRECTORY) {
if (notificationType === DirectoriesNotificationType.DELETE_DIRECTORY) {
return;
}
}
Expand All @@ -531,7 +532,8 @@
}

if (directoryUpdatedEvent.eventData?.headers) {
const notificationType = directoryUpdatedEvent.eventData.headers.notificationType as NotificationType;
const notificationType = directoryUpdatedEvent.eventData.headers
.notificationType as DirectoriesNotificationType;
const directoriesInfos = JSON.parse(
directoryUpdatedEvent.eventData.headers.directoriesInfos as string
) as DirectoryInfos[];
Expand Down
11 changes: 3 additions & 8 deletions src/utils/notificationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
*/
import type { UUID } from 'node:crypto';

export enum NotificationType {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree for me it's related to this work

DELETE_DIRECTORY = 'DELETE_DIRECTORY',
ADD_DIRECTORY = 'ADD_DIRECTORY',
UPDATE_DIRECTORY = 'UPDATE_DIRECTORY',
CASE_EXPORT_FINISHED = 'caseExportFinished',
}
const CASE_EXPORT_FINISHED = 'caseExportFinished';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably, we should keep a single enum for all notification types intended for gridexplore-app, just like in gridstudy-app, otherwise, it will become complicated to manage and understand

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is this one is not really related to the other directory enumeration. So I extracted the shared notification in the lib and I've let this one there.


export interface DirectoryInfos {
uuid: UUID;
Expand All @@ -24,12 +19,12 @@ export interface ExportCaseEventData {
}

interface ExportCaseEventDataHeaders {
notificationType: NotificationType.CASE_EXPORT_FINISHED;
notificationType: typeof CASE_EXPORT_FINISHED;
userId: string;
exportUuid: UUID;
error: string | null;
}

export function isExportCaseNotification(notif: unknown): notif is ExportCaseEventData {
return (notif as ExportCaseEventData).headers?.notificationType === NotificationType.CASE_EXPORT_FINISHED;
return (notif as ExportCaseEventData).headers?.notificationType === CASE_EXPORT_FINISHED;
}
Loading