Web: Added enable/disable notifications to the context menu.

This commit is contained in:
Tatiana Lopaeva 2023-02-06 16:55:19 +03:00
parent a8a633c2e8
commit 68adfe1138
9 changed files with 130 additions and 28 deletions

View File

@ -23,6 +23,7 @@
"CreateRoom": "Create room", "CreateRoom": "Create room",
"CustomRooms": "Custom", "CustomRooms": "Custom",
"Document": "Document", "Document": "Document",
"DisableNotifications": "Disable notifications",
"EditRoom": "Edit room", "EditRoom": "Edit room",
"EmptyFile": "Empty file", "EmptyFile": "Empty file",
"EmptyFilterDescriptionText": "No files or folders match this filter. Try a different one or clear filter to view all files. ", "EmptyFilterDescriptionText": "No files or folders match this filter. Try a different one or clear filter to view all files. ",
@ -33,6 +34,7 @@
"EmptyFolderHeader": "No files in this folder", "EmptyFolderHeader": "No files in this folder",
"EmptyRecycleBin": "Empty Trash", "EmptyRecycleBin": "Empty Trash",
"EmptyScreenFolder": "No docs here yet", "EmptyScreenFolder": "No docs here yet",
"EnableNotifications": "Enable notifications",
"ExcludeSubfolders": "Exclude subfolders", "ExcludeSubfolders": "Exclude subfolders",
"FavoritesEmptyContainerDescription": "To mark files as favorites or remove them from this list, use the context menu.", "FavoritesEmptyContainerDescription": "To mark files as favorites or remove them from this list, use the context menu.",
"FileContents": "File contents", "FileContents": "File contents",

View File

@ -23,6 +23,7 @@
"CreateRoom": "Создание комнаты", "CreateRoom": "Создание комнаты",
"CustomRooms": "Пользовательская", "CustomRooms": "Пользовательская",
"Document": "Документ", "Document": "Документ",
"DisableNotifications": "Выключить уведомления",
"EditRoom": "Изменить комнату", "EditRoom": "Изменить комнату",
"EmptyFile": "Пустой файл", "EmptyFile": "Пустой файл",
"EmptyFilterDescriptionText": "В этом разделе нет файлов или папок, соответствующих фильтру. Пожалуйста, выберите другие параметры или очистите фильтр, чтобы показать все файлы в этом разделе. Вы можете также поискать нужный файл в других разделах.", "EmptyFilterDescriptionText": "В этом разделе нет файлов или папок, соответствующих фильтру. Пожалуйста, выберите другие параметры или очистите фильтр, чтобы показать все файлы в этом разделе. Вы можете также поискать нужный файл в других разделах.",
@ -33,6 +34,7 @@
"EmptyFolderHeader": "В этой папке нет файлов", "EmptyFolderHeader": "В этой папке нет файлов",
"EmptyRecycleBin": "Очистить корзину", "EmptyRecycleBin": "Очистить корзину",
"EmptyScreenFolder": "Здесь пока нет документов", "EmptyScreenFolder": "Здесь пока нет документов",
"EnableNotifications": "Включить уведомления",
"ExcludeSubfolders": "Исключить вложенные папки", "ExcludeSubfolders": "Исключить вложенные папки",
"FavoritesEmptyContainerDescription": "Чтобы добавить файлы в избранное или удалить их из этого списка, используйте контекстное меню.", "FavoritesEmptyContainerDescription": "Чтобы добавить файлы в избранное или удалить их из этого списка, используйте контекстное меню.",
"FileContents": "Содержимое файла", "FileContents": "Содержимое файла",

View File

@ -1,4 +1,4 @@
import HistoryReactSvgUrl from "PUBLIC_DIR/images/history.react.svg?url"; import HistoryReactSvgUrl from "PUBLIC_DIR/images/history.react.svg?url";
import HistoryFinalizedReactSvgUrl from "PUBLIC_DIR/images/history-finalized.react.svg?url"; import HistoryFinalizedReactSvgUrl from "PUBLIC_DIR/images/history-finalized.react.svg?url";
import MoveReactSvgUrl from "PUBLIC_DIR/images/move.react.svg?url"; import MoveReactSvgUrl from "PUBLIC_DIR/images/move.react.svg?url";
import CheckBoxReactSvgUrl from "PUBLIC_DIR/images/check-box.react.svg?url"; import CheckBoxReactSvgUrl from "PUBLIC_DIR/images/check-box.react.svg?url";
@ -25,6 +25,8 @@ import PersonReactSvgUrl from "PUBLIC_DIR/images/person.react.svg?url";
import InfoOutlineReactSvgUrl from "PUBLIC_DIR/images/info.outline.react.svg?url"; import InfoOutlineReactSvgUrl from "PUBLIC_DIR/images/info.outline.react.svg?url";
import PinReactSvgUrl from "PUBLIC_DIR/images/pin.react.svg?url"; import PinReactSvgUrl from "PUBLIC_DIR/images/pin.react.svg?url";
import UnpinReactSvgUrl from "PUBLIC_DIR/images/unpin.react.svg?url"; import UnpinReactSvgUrl from "PUBLIC_DIR/images/unpin.react.svg?url";
import UnmuteReactSvgUrl from "PUBLIC_DIR/images/unmute.react.svg?url";
import MuteReactSvgUrl from "PUBLIC_DIR/images/mute.react.svg?url";
import ShareReactSvgUrl from "PUBLIC_DIR/images/share.react.svg?url"; import ShareReactSvgUrl from "PUBLIC_DIR/images/share.react.svg?url";
import InvitationLinkReactSvgUrl from "PUBLIC_DIR/images/invitation.link.react.svg?url"; import InvitationLinkReactSvgUrl from "PUBLIC_DIR/images/invitation.link.react.svg?url";
import MailReactSvgUrl from "PUBLIC_DIR/images/mail.react.svg?url"; import MailReactSvgUrl from "PUBLIC_DIR/images/mail.react.svg?url";
@ -573,15 +575,75 @@ class ContextOptionsStore {
onSelectItem({ id: item.id, isFolder: item.isFolder }, true, false); onSelectItem({ id: item.id, isFolder: item.isFolder }, true, false);
}; };
onClickMute = (e, id, t) => {
const data = (e.currentTarget && e.currentTarget.dataset) || e;
const { action } = data;
this.filesActionsStore.setMuteAction(action, id, t);
};
getRoomsRootContextOptions = (item, t) => {
const { id, rootFolderId } = this.selectedFolderStore;
const isRootRoom = item.isRoom && rootFolderId === id;
if (!isRootRoom) return { pinOptions: [], muteOptions: [] };
const pinOptions = [
{
id: "option_pin-room",
key: "pin-room",
label: t("PinToTop"),
icon: PinReactSvgUrl,
onClick: (e) => this.onClickPin(e, item.id, t),
disabled: false,
"data-action": "pin",
action: "pin",
},
{
id: "option_unpin-room",
key: "unpin-room",
label: t("Unpin"),
icon: UnpinReactSvgUrl,
onClick: (e) => this.onClickPin(e, item.id, t),
disabled: false,
"data-action": "unpin",
action: "unpin",
},
];
const muteOptions = [
{
id: "option_unmute-room",
key: "unmute-room",
label: t("EnableNotifications"),
icon: UnmuteReactSvgUrl,
onClick: (e) => this.onClickMute(e, item.id, t),
disabled: false,
"data-action": "unmute",
action: "unmute",
},
{
id: "option_mute-room",
key: "mute-room",
label: t("DisableNotifications"),
icon: MuteReactSvgUrl,
onClick: (e) => this.onClickMute(e, item.id, t),
disabled: false,
"data-action": "mute",
action: "mute",
},
];
return { pinOptions, muteOptions };
};
getFilesContextOptions = (item, t, isInfoPanel) => { getFilesContextOptions = (item, t, isInfoPanel) => {
const { contextOptions } = item; const { contextOptions } = item;
const { id, rootFolderId } = this.selectedFolderStore;
const { enablePlugins } = this.authStore.settingsStore; const { enablePlugins } = this.authStore.settingsStore;
const isRootThirdPartyFolder = const isRootThirdPartyFolder =
item.providerKey && item.id === item.rootFolderId; item.providerKey && item.id === item.rootFolderId;
const isRootRoom = item.isRoom && rootFolderId === id;
const isShareable = item.canShare; const isShareable = item.canShare;
const isMedia = const isMedia =
@ -724,30 +786,10 @@ class ContextOptionsStore {
}, },
]; ];
const pinOptions = isRootRoom const { pinOptions, muteOptions } = this.getRoomsRootContextOptions(
? [ item,
{ t
id: "option_pin-room", );
key: "pin-room",
label: t("PinToTop"),
icon: PinReactSvgUrl,
onClick: (e) => this.onClickPin(e, item.id, t),
disabled: false,
"data-action": "pin",
action: "pin",
},
{
id: "option_unpin-room",
key: "unpin-room",
label: t("Unpin"),
icon: UnpinReactSvgUrl,
onClick: (e) => this.onClickPin(e, item.id, t),
disabled: false,
"data-action": "unpin",
action: "unpin",
},
]
: [];
const optionsModel = [ const optionsModel = [
{ {
@ -841,6 +883,7 @@ class ContextOptionsStore {
disabled: false, disabled: false,
}, },
...pinOptions, ...pinOptions,
...muteOptions,
{ {
id: "option_sharing-settings", id: "option_sharing-settings",
key: "sharing-settings", key: "sharing-settings",

View File

@ -38,6 +38,7 @@ import config from "PACKAGE_FILE";
import FilesFilter from "@docspace/common/api/files/filter"; import FilesFilter from "@docspace/common/api/files/filter";
import api from "@docspace/common/api"; import api from "@docspace/common/api";
import { isTablet } from "@docspace/components/utils/device"; import { isTablet } from "@docspace/components/utils/device";
import { muteRoomNotification } from "@docspace/common/api/settings";
class FilesActionStore { class FilesActionStore {
authStore; authStore;
@ -935,6 +936,23 @@ class FilesActionStore {
} }
}; };
setMuteAction = (action, id) => {
switch (action) {
case "mute":
return muteRoomNotification(id, false)
.then(() => {
this.updateCurrentFolder(null, [id]);
})
.then(() => toastr.success("MUTE"));
case "unmute":
return muteRoomNotification(id, true)
.then(() => {
this.updateCurrentFolder(null, [id]);
})
.then(() => toastr.success("UNMUTE"));
}
};
setArchiveAction = async (action, folders, t) => { setArchiveAction = async (action, folders, t) => {
const { addActiveItems, setSelected } = this.filesStore; const { addActiveItems, setSelected } = this.filesStore;

View File

@ -1616,6 +1616,7 @@ class FilesStore {
const canEditRoom = item.security?.EditRoom; const canEditRoom = item.security?.EditRoom;
const canViewRoomInfo = item.security?.Read; const canViewRoomInfo = item.security?.Read;
const canMuteRoom = true; //item.security?.Mute;
let roomOptions = [ let roomOptions = [
"select", "select",
@ -1627,6 +1628,8 @@ class FilesStore {
"room-info", "room-info",
"pin-room", "pin-room",
"unpin-room", "unpin-room",
"mute-room",
"unmute-room",
"separator1", "separator1",
"archive-room", "archive-room",
"unarchive-room", "unarchive-room",
@ -1674,6 +1677,18 @@ class FilesStore {
: (roomOptions = this.removeOptions(roomOptions, ["unpin-room"])); : (roomOptions = this.removeOptions(roomOptions, ["unpin-room"]));
} }
if (!canMuteRoom) {
roomOptions = this.removeOptions(roomOptions, [
"unmute-room",
"mute-room",
]);
} else {
console.log("item.mute", item.mute);
item.mute
? (roomOptions = this.removeOptions(roomOptions, ["mute-room"]))
: (roomOptions = this.removeOptions(roomOptions, ["unmute-room"]));
}
if (!canViewRoomInfo) { if (!canViewRoomInfo) {
roomOptions = this.removeOptions(roomOptions, ["room-info"]); roomOptions = this.removeOptions(roomOptions, ["room-info"]);
} }
@ -1699,7 +1714,7 @@ class FilesStore {
} }
roomOptions = this.removeSeparator(roomOptions); roomOptions = this.removeSeparator(roomOptions);
console.log("roomOptions", roomOptions);
return roomOptions; return roomOptions;
} else { } else {
let folderOptions = [ let folderOptions = [

View File

@ -177,6 +177,7 @@ class SettingsStore {
setForcesave = (val) => (this.forcesave = val); setForcesave = (val) => (this.forcesave = val);
updateRootTreeFolders = () => { updateRootTreeFolders = () => {
console.log("updateRootTreeFolders");
const { getFoldersTree, setTreeFolders } = this.treeFoldersStore; const { getFoldersTree, setTreeFolders } = this.treeFoldersStore;
getFoldersTree().then((root) => setTreeFolders(root)); getFoldersTree().then((root) => setTreeFolders(root));
}; };

View File

@ -716,3 +716,13 @@ export function removeActiveSession(eventId) {
data: { eventId }, data: { eventId },
}); });
} }
export function muteRoomNotification(id, isMute) {
const options = {
method: "post",
url: `/settings/notification/rooms`,
data: { RoomsId: id, Mute: isMute },
};
return request(options);
}

View File

@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 14C10 14.2626 9.94827 14.5227 9.84776 14.7654C9.74725 15.008 9.59993 15.2285 9.41421 15.4142C9.2285 15.5999 9.00802 15.7472 8.76537 15.8478C8.52272 15.9483 8.26264 16 8 16C7.73736 16 7.47728 15.9483 7.23463 15.8478C6.99198 15.7472 6.7715 15.5999 6.58579 15.4142C6.40007 15.2285 6.25275 15.008 6.15224 14.7654C6.05173 14.5227 6 14.2626 6 14L8 14H10Z" fill="#333333"/>
<rect x="7" width="2" height="3" rx="1" fill="#333333"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.353516 12.2383L13.3535 1.23828L14.6454 2.76505L1.6454 13.7651L0.353516 12.2383Z" fill="#333333"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.9387 1.97176C10.1899 1.36702 9.21596 1 8 1C6.62795 1 5.56406 1.46729 4.78403 2.21611C4.02807 2.94184 3.59987 3.87187 3.3525 4.72C3.1036 5.57337 3.01852 6.4098 2.99305 7.02087C2.98751 7.15389 2.98474 7.2776 2.98383 7.39005L2.65836 7.55279C1.64201 8.06096 1 9.09975 1 10.2361V10.3814L4.99626 6.99998C5.02269 6.50228 5.09641 5.88375 5.2725 5.28C5.46263 4.62813 5.75318 4.05816 6.16909 3.65889C6.56094 3.28271 7.12205 3 8 3C8.57421 3 9.01289 3.12093 9.35732 3.30985L10.9387 1.97176ZM12.583 4.51025C12.3849 3.89762 12.0889 3.25528 11.6417 2.68685L10.1132 3.9802C10.3826 4.34106 10.5837 4.78711 10.7275 5.28C10.7926 5.50303 10.8436 5.72808 10.8835 5.94831L12.583 4.51025ZM6.46146 11H13V10.2361C13 9.8573 12.786 9.51103 12.4472 9.34164L11.5528 8.89443L10.9472 8.59165L11.0033 7.91879L11.0033 7.9185L11.0034 7.91814L11.0034 7.91761L11.0035 7.91695L11.0038 7.91173L11.0062 7.87438C11.0083 7.83925 11.011 7.78431 11.0131 7.71244C11.0172 7.5773 11.019 7.38388 11.0105 7.15081L12.8517 5.5929C12.9482 6.12633 12.9903 6.62168 13.0069 7.02087C13.0125 7.15389 13.0153 7.2776 13.0162 7.39005L13.3416 7.55279C14.358 8.06096 15 9.09975 15 10.2361V11C15 12.1046 14.1046 13 13 13H4.09783L6.46146 11ZM4.91334 11H3V10.2361C3 10.1442 3.0126 10.0542 3.03652 9.96817L1.09504 11.611C1.31333 12.2921 1.88683 12.8143 2.59757 12.9595L4.91334 11ZM4.10078 9.06765L4.44721 8.89443L5.05277 8.59165L5.02712 8.28382L4.10078 9.06765Z" fill="#333333"/>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 14C10 14.2626 9.94827 14.5227 9.84776 14.7654C9.74725 15.008 9.59993 15.2285 9.41421 15.4142C9.2285 15.5999 9.00802 15.7472 8.76537 15.8478C8.52272 15.9483 8.26264 16 8 16C7.73736 16 7.47728 15.9483 7.23463 15.8478C6.99198 15.7472 6.7715 15.5999 6.58579 15.4142C6.40007 15.2285 6.25275 15.008 6.15224 14.7654C6.05173 14.5227 6 14.2626 6 14L8 14H10Z" fill="#333333"/>
<rect x="7" width="2" height="3" rx="1" fill="#333333"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.9966 7.91761L4.99664 7.91814L4.99667 7.91846L4.99667 7.9185L4.9967 7.91879L4.99671 7.91891L5.05277 8.59165L4.44721 8.89443L3.55279 9.34164C3.214 9.51103 3 9.8573 3 10.2361V11H13V10.2361C13 9.8573 12.786 9.51103 12.4472 9.34164L11.5528 8.89443L10.9472 8.59165L11.0033 7.91879L11.0033 7.9185L11.0034 7.91814L11.0034 7.91761L11.0035 7.91695L11.0038 7.91173L11.0062 7.87438C11.0083 7.83925 11.011 7.78431 11.0131 7.71244C11.0174 7.56837 11.0193 7.35809 11.0087 7.10413C10.9873 6.5902 10.9161 5.92663 10.7275 5.28C10.5374 4.62813 10.2468 4.05816 9.83091 3.65889C9.43906 3.28271 8.87795 3 8 3C7.12205 3 6.56094 3.28271 6.16909 3.65889C5.75318 4.05816 5.46263 4.62813 5.2725 5.28C5.0839 5.92663 5.01273 6.5902 4.99132 7.10413C4.98074 7.35809 4.98257 7.56837 4.98686 7.71244C4.989 7.78431 4.99174 7.83925 4.99379 7.87438L4.99618 7.91173L4.9966 7.91761ZM13.0162 7.39005C13.0153 7.2776 13.0125 7.15389 13.0069 7.02087C12.9815 6.4098 12.8964 5.57337 12.6475 4.72C12.4001 3.87187 11.9719 2.94184 11.216 2.21611C10.4359 1.46729 9.37205 1 8 1C6.62795 1 5.56406 1.46729 4.78403 2.21611C4.02807 2.94184 3.59987 3.87187 3.3525 4.72C3.1036 5.57337 3.01852 6.4098 2.99305 7.02087C2.98751 7.15389 2.98474 7.2776 2.98383 7.39005L2.65836 7.55279C1.64201 8.06096 1 9.09975 1 10.2361V11C1 12.1046 1.89543 13 3 13H13C14.1046 13 15 12.1046 15 11V10.2361C15 9.09975 14.358 8.06096 13.3416 7.55279L13.0162 7.39005Z" fill="#333333"/>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB