Skip to content

Commit

Permalink
Merge pull request #292 from ONLYOFFICE/feature/privacy-rooms-page
Browse files Browse the repository at this point in the history
Feature/privacy rooms page
  • Loading branch information
ilyaoleshko authored Jul 1, 2021
2 parents 4be9f84 + 50d9d91 commit a1f5596
Show file tree
Hide file tree
Showing 38 changed files with 565 additions and 161 deletions.
10 changes: 8 additions & 2 deletions packages/asc-web-common/api/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,14 @@ export function setFileOwner(folderIds, fileIds, userId) {
});
}

export function startUploadSession(folderId, fileName, fileSize, relativePath) {
const data = { fileName, fileSize, relativePath };
export function startUploadSession(
folderId,
fileName,
fileSize,
relativePath,
encrypted
) {
const data = { fileName, fileSize, relativePath, encrypted };
return request({
method: "post",
url: `/files/${folderId}/upload/create_session.json`,
Expand Down
2 changes: 1 addition & 1 deletion packages/asc-web-common/components/PageLayout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class PageLayout extends React.Component {
<Selecto
dragContainer={".main"}
selectableTargets={[".files-item"]}
hitRate={1}
hitRate={0}
selectByClick={false}
selectFromInside={true}
ratio={0}
Expand Down
8 changes: 0 additions & 8 deletions products/ASC.Files/Client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,6 @@
-->
<script>
console.log("It's FILES INIT");
var pathname = window.location.pathname.toLowerCase();
if (
pathname.indexOf("doceditor") === -1 &&
window["AscDesktopEditor"] === undefined
) {
let el = document.getElementById("temp-content");
el.style.display = "block";
}
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions products/ASC.Files/Client/public/locales/en/DeleteDialog.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"MoveToTrashOneFolderTitle": "Move folder to Trash?",
"UnsubscribeButton": "Unsubscribe",
"UnsubscribeNote": "Are you sure you want to unsubscribe from the selected items from the list?",
"UnsubscribeTitle": "Unsubscribe confirmation"
}
"UnsubscribeTitle": "Unsubscribe confirmation",
"ConfirmRemove": "Confirmation"
}
10 changes: 10 additions & 0 deletions products/ASC.Files/Client/public/locales/en/PrivacyPage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"PrivacyHeader": "This document is encrypted",
"PrivacyClick": "Click Open <1>ONLYOFFICE Desktop</1> in the browser dialog to work with the encrypted documents",
"PrivacyDialog": "If you don’t see a dialog, click the button below",
"PrivacyButton": "Open ONLYOFFICE Desktop Editors",
"PrivacyEditors": "Don’t have ONLYOFFICE Desktop Editors",
"PrivacyInstall": "Install now",
"PrivacyDescriptionEditors": "If you have ONLYOFFICE Desktop Editors installed but can't open it from this page, your browser might be blocking it",
"PrivacyDescriptionConnect": "You can open this file from the desktop app's interface once your cloud is connected"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"MoveToTrashOneFolderTitle": "Переместить папку в корзину?",
"UnsubscribeButton": "Отписаться",
"UnsubscribeNote": "Вы действительно хотите отписаться от выделенных элементов из списка?",
"UnsubscribeTitle": "Подтверждение отписки"
"UnsubscribeTitle": "Подтверждение отписки",
"ConfirmRemove": "Подтверждение удаления"
}
10 changes: 10 additions & 0 deletions products/ASC.Files/Client/public/locales/ru/PrivacyPage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"PrivacyHeader": "Этот документ зашифрован",
"PrivacyClick": "Нажмите открыть <1>ONLYOFFICE Desktop</1> в диалоговом окне браузера, чтобы работать с зашифрованными документами",
"PrivacyDialog": "Если вы не видите диалоговое окно, нажмите кнопку ниже",
"PrivacyButton": "Откройте ONLYOFFICE Desktop Editors",
"PrivacyEditors": "Не установлены ONLYOFFICE Desktop Editors",
"PrivacyInstall": "Установить сейчас",
"PrivacyDescriptionEditors": "Если у вас установлен ONLYOFFICE Desktop Editors, но вы не можете открыть его с этой страницы, возможно, ваш браузер блокирует его",
"PrivacyDescriptionConnect": "Вы можете открыть этот файл из интерфейса настольного приложения после подключения вашего облака"
}
5 changes: 5 additions & 0 deletions products/ASC.Files/Client/src/Files.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { regDesktop } from "@appserver/common/desktop";
import Home from "./pages/Home";
import Settings from "./pages/Settings";
import VersionHistory from "./pages/VersionHistory";
import PrivateRoomsPage from "./pages/PrivateRoomsPage";
import ErrorBoundary from "@appserver/common/components/ErrorBoundary";
import Panels from "./components/FilesPanels";
import { AppServerConfig } from "@appserver/common/constants";
Expand All @@ -26,6 +27,7 @@ const PROXY_HOMEPAGE_URL = combineUrl(proxyURL, homepage);
const HOME_URL = combineUrl(PROXY_HOMEPAGE_URL, "/");
const SETTINGS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/settings/:setting");
const HISTORY_URL = combineUrl(PROXY_HOMEPAGE_URL, "/:fileId/history");
const PRIVATE_ROOMS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/private");
const FILTER_URL = combineUrl(PROXY_HOMEPAGE_URL, "/filter");

if (!window.AppServer) {
Expand All @@ -36,6 +38,7 @@ window.AppServer.files = {
HOME_URL,
SETTINGS_URL,
HISTORY_URL,
PRIVATE_ROOMS_URL,
FILTER_URL,
};

Expand Down Expand Up @@ -86,6 +89,7 @@ class FilesContent extends React.Component {
encryptionKeys,
setEncryptionKeys,
this.isEditor,
null,
this.props.t
);
console.log(
Expand All @@ -106,6 +110,7 @@ class FilesContent extends React.Component {
<Switch>
<PrivateRoute exact path={SETTINGS_URL} component={Settings} />
<PrivateRoute exact path={HISTORY_URL} component={VersionHistory} />
<PrivateRoute path={PRIVATE_ROOMS_URL} component={PrivateRoomsPage} />
<PrivateRoute exact path={HOME_URL} component={Home} />
<PrivateRoute path={FILTER_URL} component={Home} />
<PrivateRoute component={Error404Route} />
Expand Down
14 changes: 12 additions & 2 deletions products/ASC.Files/Client/src/HOCs/withBadges.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ export default function withBadges(WrappedComponent) {
item,
canWebEdit,
isTrashFolder,
isPrivacyFolder,
canConvert,
onFilesClick, // from withFileAction HOC
isAdmin,
isDesktopClient,
} = this.props;
const { fileStatus, access } = item;

Expand All @@ -154,6 +156,8 @@ export default function withBadges(WrappedComponent) {
canWebEdit={canWebEdit}
canConvert={canConvert}
isTrashFolder={isTrashFolder}
isPrivacyFolder={isPrivacyFolder}
isDesktopClient={isDesktopClient}
accessToEdit={accessToEdit}
onClickLock={this.onClickLock}
onClickFavorite={this.onClickFavorite}
Expand Down Expand Up @@ -186,13 +190,17 @@ export default function withBadges(WrappedComponent) {
{ item }
) => {
const { docserviceStore } = formatsStore;
const { isRecycleBinFolder, updateRootBadge } = treeFoldersStore;
const {
isRecycleBinFolder,
isPrivacyFolder,
updateRootBadge,
} = treeFoldersStore;
const {
lockFileAction,
setFavoriteAction,
markAsRead,
} = filesActionsStore;
const { isTabletView } = auth.settingsStore;
const { isTabletView, isDesktopClient } = auth.settingsStore;
const { setIsVerHistoryPanel, fetchFileVersions } = versionHistoryStore;
const {
setNewFilesPanelVisible,
Expand All @@ -214,6 +222,7 @@ export default function withBadges(WrappedComponent) {
canWebEdit,
canConvert,
isTrashFolder: isRecycleBinFolder,
isPrivacyFolder,
lockFileAction,
setFavoriteAction,
homepage: config.homepage,
Expand All @@ -232,6 +241,7 @@ export default function withBadges(WrappedComponent) {
fetchFiles,
setConvertDialogVisible,
setConvertItem,
isDesktopClient,
};
}
)(observer(WithBadges));
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Client/src/HOCs/withContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default function withContent(WrappedContent) {
.then(() => {
const exst = item.fileExst;
return toastr.success(
<Trans i18nKey="FileCreated" ns="Home">
<Trans t={t} i18nKey="FileCreated" ns="Home">
New file {{ itemTitle }}.{{ exst }} is created
</Trans>
);
Expand Down
44 changes: 31 additions & 13 deletions products/ASC.Files/Client/src/HOCs/withFileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Text from "@appserver/components/text";
import toastr from "@appserver/components/toast/toastr";

import { EncryptedFileIcon } from "../components/Icons";
import { createTreeFolders } from "../helpers/files-helpers";
import { checkProtocol, createTreeFolders } from "../helpers/files-helpers";

const svgLoader = () => <div style={{ width: "24px" }}></div>;
export default function withFileActions(WrappedFileItem) {
Expand All @@ -21,7 +21,7 @@ export default function withFileActions(WrappedFileItem) {
}
onContentFileSelect = (checked, file) => {
const { selectRowAction } = this.props;
if (!file) return;
if (!file || file.id === -1) return;
selectRowAction(checked, file);
};

Expand All @@ -33,7 +33,8 @@ export default function withFileActions(WrappedFileItem) {

fileContextClick = () => {
const { onSelectItem, item } = this.props;
onSelectItem(item);

item.id !== -1 && onSelectItem(item);
};

getSharedButton = (shared) => {
Expand Down Expand Up @@ -63,7 +64,7 @@ export default function withFileActions(WrappedFileItem) {
};

getItemIcon = (isEdit) => {
const { item, isPrivacy } = this.props;
const { item, isPrivacy, viewAs } = this.props;
const { icon, fileExst } = item;
return (
<>
Expand All @@ -72,7 +73,9 @@ export default function withFileActions(WrappedFileItem) {
src={icon}
loading={svgLoader}
/>
{isPrivacy && fileExst && <EncryptedFileIcon isEdit={isEdit} />}
{isPrivacy && fileExst && (
<EncryptedFileIcon isEdit={isEdit && viewAs !== "tile"} />
)}
</>
);
};
Expand All @@ -95,12 +98,17 @@ export default function withFileActions(WrappedFileItem) {
};

onMouseDown = (e) => {
const { draggable, setTooltipPosition, setStartDrag } = this.props;
const {
draggable,
setTooltipPosition,
setStartDrag,
isPrivacy,
} = this.props;
const notSelectable = e.target.classList.contains("not-selectable");

this.setState({ isMouseDown: true });

if (!draggable) return;
if (!draggable || isPrivacy) return;

if (window.innerWidth < 1025 || notSelectable) {
return;
Expand Down Expand Up @@ -149,11 +157,11 @@ export default function withFileActions(WrappedFileItem) {
} else {
if (checked) {
this.onContentFileSelect(!checked, item);
this.fileContextClick(item);
this.fileContextClick();
} else {
if (!isMouseDown) return;
this.onContentFileSelect(true, item);
this.fileContextClick(item);
this.fileContextClick();
}
}
this.setState({ isMouseDown: false });
Expand All @@ -171,6 +179,7 @@ export default function withFileActions(WrappedFileItem) {
canWebEdit,
item,
isTrashFolder,
isPrivacy,
openDocEditor,
expandedKeys,
addExpandedKeys,
Expand All @@ -186,7 +195,10 @@ export default function withFileActions(WrappedFileItem) {
providerKey,
contentLength,
fileStatus,
encrypted,
} = item;
if (encrypted && isPrivacy) return checkProtocol(item.id, true);

if (isTrashFolder) return;
if (e && e.target.tagName === "INPUT") return;

Expand Down Expand Up @@ -234,7 +246,7 @@ export default function withFileActions(WrappedFileItem) {
render() {
const {
item,
isRecycleBin,
isTrashFolder,
draggable,
canShare,
isPrivacy,
Expand All @@ -245,13 +257,14 @@ export default function withFileActions(WrappedFileItem) {
checked,
dragging,
isFolder,
isDesktop,
} = this.props;
const { fileExst, access, contentLength, id, shared } = item;

const isEdit =
!!actionType && actionId === id && fileExst === actionExtension;
actionType !== null && actionId === id && fileExst === actionExtension;

const isDragging = isFolder && access < 2 && !isRecycleBin;
const isDragging = isFolder && access < 2 && !isTrashFolder && !isPrivacy;

let className = isDragging ? " droppable" : "";
if (draggable) className += " draggable not-selectable";
Expand All @@ -266,8 +279,10 @@ export default function withFileActions(WrappedFileItem) {
? "38px"
: "96px";

const showShare = isPrivacy && (!isDesktop || !fileExst) ? false : true;

const sharedButton =
!canShare || (isPrivacy && !fileExst) || isEdit || id <= 0 || isMobile
!canShare || !showShare || isEdit || id <= 0 || isMobile
? null
: this.getSharedButton(shared);

Expand All @@ -293,6 +308,7 @@ export default function withFileActions(WrappedFileItem) {
checkedProps={checkedProps}
element={element}
dragging={dragging}
isEdit={isEdit}
{...this.props}
/>
);
Expand All @@ -302,6 +318,7 @@ export default function withFileActions(WrappedFileItem) {
return inject(
(
{
auth,
filesActionsStore,
dialogsStore,
treeFoldersStore,
Expand Down Expand Up @@ -412,6 +429,7 @@ export default function withFileActions(WrappedFileItem) {
viewAs,
setConvertItem,
setConvertDialogVisible,
isDesktop: auth.settingsStore.isDesktopClient,
};
}
)(observer(WithFileActions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class TreeFolders extends React.Component {
key={item.id}
className={className}
title={item.title}
needTopMargin={item.rootFolderType === FolderType.Privacy}
icon={this.getFolderIcon(item)}
dragging={dragging}
isLeaf={
Expand Down Expand Up @@ -246,7 +245,13 @@ class TreeFolders extends React.Component {
title={item.title}
needTopMargin={item.rootFolderType === FolderType.TRASH}
dragging={dragging}
isLeaf={item.foldersCount ? false : true}
isLeaf={
(item.rootFolderType === FolderType.Privacy &&
!this.props.isDesktop) ||
!item.foldersCount
? true
: false
}
icon={this.getFolderIcon(item)}
newItems={
!this.props.isDesktop && item.rootFolderType === FolderType.Privacy
Expand Down
4 changes: 4 additions & 0 deletions products/ASC.Files/Client/src/components/Badges.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const Badges = ({
item,
canWebEdit,
isTrashFolder,
isPrivacyFolder,
isDesktopClient,
canConvert,
accessToEdit,
showNew,
Expand All @@ -29,6 +31,7 @@ const Badges = ({
const isEditing = fileStatus === 1;
const isNewWithFav = fileStatus === 34;
const showEditBadge = !locked || item.access === 0;
const isPrivacy = isPrivacyFolder && isDesktopClient;

return fileExst ? (
<div className="badges additional-badges">
Expand All @@ -46,6 +49,7 @@ const Badges = ({
{canWebEdit &&
!isEditing &&
!isTrashFolder &&
isPrivacy &&
accessToEdit &&
showEditBadge &&
!canConvert && (
Expand Down
Loading

0 comments on commit a1f5596

Please sign in to comment.