Web: Templates: added routing, added room tabs fixed rights, fixed translations

This commit is contained in:
Nikita Gopienko 2024-04-15 15:19:57 +03:00
parent 51dacad300
commit 7576398006
13 changed files with 207 additions and 16 deletions

View File

@ -48,6 +48,7 @@
"DisableNotifications": "Disable notifications",
"SaveAsTemplate": "Save as template",
"TemplateName": "Template Name",
"RoomName": "Room Name",
"RoomTags": "Room Tags",
"RoomTagsTooltip": "Tags will apply to the room that will be created based on this template.",
"CreateTemplate": "Create template",

View File

@ -204,7 +204,6 @@ const CreateRoomDialog = ({
isChooseRoomType={!roomParams.type}
onArrowClick={goBack}
isTemplate={isTemplate}
isTemplateSelected={isTemplateSelected}
/>
</ModalDialog.Header>

View File

@ -38,13 +38,8 @@ const DialogHeader = ({
isChooseRoomType,
onArrowClick,
isTemplate,
isTemplateSelected,
}) => {
const title = isTemplateSelected
? t("Files:SaveAsTemplate")
: isTemplate
? t("Files:FromTemplate")
: t("Files:CreateRoom");
const title = isTemplate ? t("Files:FromTemplate") : t("Files:CreateRoom");
return (
<>

View File

@ -148,7 +148,7 @@ const SetRoomParams = ({
return (
<StyledSetRoomParams disableImageRescaling={disableImageRescaling}>
{isEdit || isTemplateSelected ? (
{isEdit || !!isTemplateSelected ? (
<RoomType t={t} roomType={roomParams.type} type="displayItem" />
) : (
<RoomTypeDropdown
@ -172,7 +172,11 @@ const SetRoomParams = ({
)}
<InputParam
id="shared_room-name"
title={`${t("Common:Name")}:`}
title={
!!isTemplateSelected
? `${t("Files:RoomName")}:`
: `${t("Common:Name")}:`
}
placeholder={t("Common:EnterName")}
value={roomParams.title}
onChange={onChangeName}
@ -192,6 +196,7 @@ const SetRoomParams = ({
<TagInput
t={t}
title={!!isTemplateSelected ? t("Files:RoomTags") : ""}
tagHandler={tagHandler}
setIsScrollLocked={setIsScrollLocked}
isDisabled={isDisabled}

View File

@ -80,6 +80,8 @@ export const CategoryType = Object.freeze({
Settings: 8,
Accounts: 9,
PublicRoom: 10,
Templates: 11,
TemplatesRoom: 12,
});
/**

View File

@ -142,6 +142,8 @@ export const getCategoryType = (location) => {
categoryType = CategoryType.PublicRoom;
} else if (pathname.indexOf("archive") > -1) {
categoryType = CategoryType.Archive;
} else if (pathname.indexOf("templates") > -1) {
categoryType = CategoryType.Templates;
}
} else if (pathname.startsWith("/favorite")) {
categoryType = CategoryType.Favorite;
@ -200,6 +202,12 @@ export const getCategoryUrl = (categoryType, folderId = null) => {
case CategoryType.ArchivedRoom:
return `/rooms/archived/${folderId}/filter`;
case CategoryType.Templates:
return "/rooms/templates/filter";
case CategoryType.TemplatesRoom:
return `/rooms/templates/${folderId}/filter`;
case CategoryType.Favorite:
return "/files/favorite/filter";

View File

@ -89,10 +89,25 @@ const useFiles = ({
const url = getCategoryUrl(categoryType);
filter.searchArea =
categoryType === CategoryType.Shared
? RoomSearchArea.Active
: RoomSearchArea.Archive;
let searchArea;
switch (categoryType) {
case CategoryType.Shared:
searchArea = RoomSearchArea.Shared;
break;
case CategoryType.Templates:
searchArea = RoomSearchArea.Templates;
break;
case CategoryType.Archive:
searchArea = RoomSearchArea.Archive;
break;
default:
searchArea = RoomSearchArea.Archive;
break;
}
filter.searchArea = searchArea;
navigate(`${url}?${filter.toUrlParams()}`);
};
@ -172,7 +187,8 @@ const useFiles = ({
if (
(categoryType == CategoryType.Shared ||
categoryType == CategoryType.SharedRoom ||
categoryType == CategoryType.Archive) &&
categoryType == CategoryType.Archive ||
categoryType == CategoryType.Templates) &&
!isRoomFolder
) {
filterObj = RoomsFilter.getFilter(window.location);

View File

@ -0,0 +1,103 @@
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
import { inject, observer } from "mobx-react";
import { useTranslation } from "react-i18next";
import { Submenu } from "@docspace/shared/components/submenu";
import { SectionSubmenuSkeleton } from "@docspace/shared/skeletons/sections";
import RoomsFilter from "@docspace/shared/api/rooms/filter";
import { getObjectByLocation } from "@docspace/shared/utils/common";
import { RoomSearchArea } from "@docspace/shared/enums";
import { CategoryType } from "SRC_DIR/helpers/constants";
import { getCategoryUrl } from "SRC_DIR/helpers/utils";
const RoomTemplatesSubMenu = ({ setFilter, showBodyLoader, showSubmenu }) => {
const { t } = useTranslation(["Common"]);
const submenu = [
{
id: "rooms",
name: t("Common:Rooms"),
},
{
id: "templates",
name: t("Common:Templates"),
},
];
const onSelect = (e) => {
const filter = RoomsFilter.getDefault();
let path;
if (e.id === "templates") {
filter.searchArea = RoomSearchArea.Templates;
path = getCategoryUrl(CategoryType.Templates);
} else {
filter.searchArea = RoomSearchArea.Active;
path = getCategoryUrl(CategoryType.Shared);
}
setFilter(filter);
window.DocSpace.navigate(`${path}?${filter.toUrlParams()}`, {
replace: true,
});
};
const startSelect =
getObjectByLocation(window.DocSpace.location)?.searchArea ===
RoomSearchArea.Active
? 0
: 1;
if (showSubmenu && showBodyLoader) return <SectionSubmenuSkeleton />;
return showSubmenu ? (
<Submenu data={submenu} startSelect={startSelect} onSelect={onSelect} />
) : null;
};
export default inject(
({
treeFoldersStore,
filesStore,
clientLoadingStore,
selectedFolderStore,
}) => {
const { isRoomsFolderRoot, isTemplatesFolderRoot } = treeFoldersStore;
const { setFilter } = filesStore;
const { showBodyLoader } = clientLoadingStore;
return {
setFilter,
showBodyLoader,
showSubmenu:
(isRoomsFolderRoot || isTemplatesFolderRoot) &&
selectedFolderStore.security?.Create,
};
},
)(observer(RoomTemplatesSubMenu));

View File

@ -26,14 +26,20 @@
import AccountsSubmenu from "./AccountsSubmenu";
import MyDocumentsSubmenu from "./MyDocumentsSubmenu";
import RoomTemplatesSubMenu from "./RoomTemplatesSubMenu";
import { inject, observer } from "mobx-react";
import { useLocation } from "react-router-dom";
const SectionSubmenuContent = ({ isPersonalRoom, isRecentTab }) => {
const SectionSubmenuContent = ({
isPersonalRoom,
isRecentTab,
isRoomsFolder,
}) => {
const location = useLocation();
const isAccounts = location.pathname.includes("/accounts");
if (isPersonalRoom || isRecentTab) return <MyDocumentsSubmenu />;
if (isRoomsFolder) return <RoomTemplatesSubMenu />;
if (isAccounts) return <AccountsSubmenu />;
return null;
};
@ -41,4 +47,5 @@ const SectionSubmenuContent = ({ isPersonalRoom, isRecentTab }) => {
export default inject(({ treeFoldersStore }) => ({
isPersonalRoom: treeFoldersStore.isPersonalRoom,
isRecentTab: treeFoldersStore.isRecentTab,
isRoomsFolder: treeFoldersStore.isRoomsFolder,
}))(observer(SectionSubmenuContent));

View File

@ -128,6 +128,14 @@ const ClientRoutes = [
</PrivateRoute>
),
},
{
path: "templates",
element: (
<PrivateRoute>
<Navigate to="/rooms/templates" replace />
</PrivateRoute>
),
},
{
path: "rooms/personal",
element: (
@ -224,6 +232,38 @@ const ClientRoutes = [
</PrivateRoute>
),
},
{
path: "rooms/templates",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/templates/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/templates/:room",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/templates/:room/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "media/view/:id",
element: (

View File

@ -1376,7 +1376,7 @@ class ContextOptionsStore {
icon: CreateTemplateSvgUrl,
onClick: () => this.onCreateRoomTemplate(item),
badgeLabel: t("New").toUpperCase(),
disabled: false,
disabled: !item.security?.Create,
},
{
id: "option_owner-change",

View File

@ -207,6 +207,12 @@ class TreeFoldersStore {
);
}
get templatesFolder() {
return this.treeFolders.find(
(x) => x.rootFolderType === FolderType.Templates,
);
}
get privacyFolder() {
return this.treeFolders.find(
(x) => x.rootFolderType === FolderType.Privacy,
@ -333,10 +339,18 @@ class TreeFoldersStore {
);
}
get isRoomsFolderRoot() {
return FolderType.Rooms === this.selectedFolderStore.rootFolderType;
}
get isArchiveFolderRoot() {
return FolderType.Archive === this.selectedFolderStore.rootFolderType;
}
get isTemplatesFolderRoot() {
return FolderType.Templates === this.selectedFolderStore.rootFolderType;
}
get isPersonalFolderRoot() {
return FolderType.USER === this.selectedFolderStore.rootFolderType;
}

View File

@ -168,6 +168,7 @@ export const enum RoomSearchArea {
Any = "Any",
Active = "Active",
Archive = "Archive",
Templates = "Templates",
}
/**
* Enum for file action.