Skip to content

Commit

Permalink
feat(toaster) : #MAG-264 add button to notify other users of board
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Mariotti committed Dec 11, 2024
1 parent 935274d commit b4dc76d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void getBoardResourceIds(HttpServerRequest request) {
});
}

@Get("/board/:boardId/notify")
@Post("/board/:boardId/notify")
@ApiDoc("Notify board shared users")
@ResourceFilter(ManageBoardRight.class)
@SecuredAction(value = "", type = ActionType.RESOURCE)
Expand Down
4 changes: 4 additions & 0 deletions backend/src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"magneto.rename": "Renommer",
"magneto.board.properties": "Propriétés du tableau",
"magneto.board.move": "Déplacer le tableau",
"magneto.board.notify": "Notifier les utilisateurs",
"magneto.board.notify.text.1" : "Voulez-vous envoyer une notification aux utilisateurs à qui vous avez partagé le tableau ?",
"magneto.board.notify.text.2" : "Une notification leur sera envoyée dans leur fil d'actualité leur indiquant que des modifications ont été faites sur ce tableau.",
"magneto.board.move.title": "Déplacer l'aimant sélectionné",
"magneto.board.move.text": "Vers quel tableau souhaitez-vous déplacer cet aimant ?",
"magneto.board.duplicate.move.title": "Dupliquer l'aimant sélectionné",
Expand Down Expand Up @@ -218,6 +221,7 @@
"magneto.folder.share.drag.in.warning": "Cet élément sera visible par toutes les personnes ayant accès au dossier {{0}}.",
"magneto.folder.share.drag.out.warning": "Toutes les personnes ayant accès au dossier {{0}} ne pourront plus accéder à cet élément, sauf s'il est partagé directement avec elles.",
"magneto.confirm": "Confirmer",
"magneto.send": "Envoyer",
"magneto.folder.share.predelete.warning": "Les utilisateurs à qui vous avez partagé les éléments n'y auront plus accès.",
"magneto.folder.drag.drop.right.error": "Vous n'avez pas le droit nécessaire pour déplacer cet élément ici",
"magneto.explorer.search.adml.hint": "Saisissez 3 lettres pour démarrer la recherche",
Expand Down
31 changes: 30 additions & 1 deletion frontend/src/components/toaster-container/ToasterContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useNavigate } from "react-router-dom";
import { BoardPublicShareModal } from "../board-public-share-modal/BoardPublicShareModal";
import { CreateFolder } from "../create-folder/CreateFolder";
import { DeleteModal } from "../delete-modal/DeleteModal";
import { MessageModal } from "../message-modal/MessageModal";
import { MoveBoard } from "../move-board/MoveBoard";
import { ShareModalMagneto } from "../share-modal/ShareModalMagneto";
import { CreateBoard } from "~/components/create-board/CreateBoard";
Expand All @@ -27,7 +28,7 @@ import { Board } from "~/models/board.model";
import { Folder } from "~/models/folder.model";
import { useBoardsNavigation } from "~/providers/BoardsNavigationProvider";
import { useFoldersNavigation } from "~/providers/FoldersNavigationProvider";
import { useDuplicateBoardMutation } from "~/services/api/boards.service";
import { useDuplicateBoardMutation, useNotifyBoardUsersMutation } from "~/services/api/boards.service";
import { useActions } from "~/services/queries";
import { useUserRightsStore } from "~/stores";

Expand All @@ -49,6 +50,7 @@ export const ToasterContainer = ({
const canPublish = isActionAvailable("publish", actions);

const [isCreateOpen, toggleCreate] = useToggle(false);
const [isNotifyOpen, toggleNotify] = useToggle(false);
const [isMoveOpen, toggleMove] = useToggle(false);
const [isMoveDelete, toggleDelete] = useToggle(false);
const [isCreateFolder, toggleCreateFolder] = useToggle(false);
Expand All @@ -68,6 +70,7 @@ export const ToasterContainer = ({
useBoardsNavigation();
const { setUserRights } = useUserRightsStore.getState();
const [duplicateBoard] = useDuplicateBoardMutation();
const [notifyBoardUsers] = useNotifyBoardUsersMutation();

const restoreBoardsAndFolders = useRestoreBoardsAndFolders({
selectedBoardsIds,
Expand Down Expand Up @@ -322,6 +325,19 @@ export const ToasterContainer = ({
{t("magneto.restore")}
</Button>
)}
{selectedBoardsIds.length == 1 &&
selectedFoldersIds.length == 0 &&
selectedBoardRights != null &&
selectedBoardRights.manager && (
<Button
type="button"
color="primary"
variant="filled"
onClick={toggleNotify}
>
{t("magneto.board.notify")}
</Button>
)}
{!isPublic && allBoardsMine() && areFoldersMine() && (
<Button
type="button"
Expand Down Expand Up @@ -363,6 +379,19 @@ export const ToasterContainer = ({
reset={reset}
hasSharedElement={hasSharedElement}
/>
<MessageModal
isOpen={isNotifyOpen}
title={t("magneto.board.notify")}
onSubmit={() => { notifyBoardUsers(selectedBoardsIds[0]);
toggleNotify();
}}
submitButtonName={t("magneto.send")}
cancelButtonName={t("magneto.cancel")}
onClose={toggleNotify}
>
<span>{t("magneto.board.notify.text.1")}</span>
<span>{t("magneto.board.notify.text.2")}</span>
</MessageModal>
{shareOptions && (
<ShareModalMagneto
isOpen={isShareBoard}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/services/api/boards.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const boardsApi = emptySplitApi.injectEndpoints({
}),
providesTags: ["Boards"],
}),
notifyBoardUsers: builder.mutation({
query: (idBoard: string) => ({
url: `board/${idBoard}/notify`,
method: "POST",
}),
}),
getAllBoards: builder.query({
query: (params: IBoardsParamsRequest) => {
let urlParams: string =
Expand Down Expand Up @@ -142,4 +148,5 @@ export const {
useRestorePreDeleteBoardsMutation,
useGetUrlQuery,
useGetAllBoardsEditableQuery,
useNotifyBoardUsersMutation,
} = boardsApi;

0 comments on commit b4dc76d

Please sign in to comment.