Skip to content

Commit

Permalink
Merge branch 'hotfix/v3.0.1' into feature/translations-3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySafronov committed Dec 11, 2024
2 parents f6ea0f7 + 91e75bd commit 06ca250
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 39 deletions.
5 changes: 2 additions & 3 deletions packages/client/src/HOCs/withFileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ export default function withFileActions(WrappedFileItem) {
onDrop = (items) => {
const { isTrashFolder, dragging, setDragging, isDisabledDropItem } =
this.props;
const { fileExst, id } = this.props.item;
const { fileExst, isFolder, id } = this.props.item;

if (isTrashFolder || isDisabledDropItem)
return dragging && setDragging(false);

if (!fileExst) {
if (!fileExst && isFolder) {
this.onDropZoneUpload(items, id);
} else {
this.onDropZoneUpload(items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,5 @@ export type FilesSelectorProps = TSelectorHeader & {
filesSettings: TFilesSettings;

withCreate?: boolean;
checkCreating?: boolean;
};
4 changes: 4 additions & 0 deletions packages/client/src/components/FilesSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const FilesSelectorWrapper = ({

withCreate,
folderIsShared,
checkCreating,
}: FilesSelectorProps) => {
const { t }: { t: TTranslation } = useTranslation([
"Files",
Expand Down Expand Up @@ -364,6 +365,7 @@ const FilesSelectorWrapper = ({
| TRoomSecurity
| undefined,
selectedFileInfo: TSelectedFileInfo,
isDisabledFolder?: boolean,
) => {
return getIsDisabled(
isFirstLoad,
Expand All @@ -380,6 +382,7 @@ const FilesSelectorWrapper = ({
!!selectedFileInfo,
includeFolder,
isRestore,
isDisabledFolder,
);
};

Expand Down Expand Up @@ -441,6 +444,7 @@ const FilesSelectorWrapper = ({
filesSettings={filesSettings}
headerProps={headerProps}
formProps={formProps}
checkCreating={checkCreating}
/>
);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/components/FilesSelector/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ export const getIsDisabled = (
isFileSelected?: boolean,
includeFolder?: boolean,
isRestore?: boolean,
isDisabledFolder?: boolean,
) => {
if (isFirstLoad) return true;
if (isRequestRunning) return true;
if (isDisabledFolder) return true;
if (filterParam) return !isFileSelected;
if (sameId && !isCopy) return true;
if (sameId && isCopy && includeFolder) return true;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/components/FilesSelectorInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const FilesSelectorInput = (props) => {
isRoomBackup,
isDocumentIcon,
withCreate,
checkCreating,
} = props;

const isFilesSelection = !!filterParam;
Expand Down Expand Up @@ -140,6 +141,7 @@ const FilesSelectorInput = (props) => {
isSelect={isSelect}
withCreate={withCreate}
{...(isFilesSelection ? filesSelectionProps : foldersSelectionProps)}
checkCreating={checkCreating}
/>
</Aside>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ const ConflictResolveDialog = (props: ConflictResolveDialogProps) => {
const onCloseConflictDialog = () => {
if (isUploadConflict) {
cancelUploadAction();
onCloseDialog();
onClose();
} else onCloseDialog();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ const DirectThirdPartyConnection = (props) => {
</StyledComboBoxItem>
);
});

return (
<StyledBackup
isConnectedAccount={
Expand Down Expand Up @@ -321,6 +320,9 @@ const DirectThirdPartyConnection = (props) => {
isThirdParty
isSelectFolder={isSelectFolder}
isSelect={isSelect}
checkCreating={
selectedThirdPartyAccount?.provider_key === "WebDav"
}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const DocSpace = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const Editor = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const FileSelector = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const Manager = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const RoomSelector = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const SimpleRoom = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Viewer = (props) => {
};

const initFrame = () => {
sdk.init(config);
setTimeout(() => sdk.init(config), 10);
};

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/store/SettingsSetupStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import api from "@docspace/shared/api";
import { makeAutoObservable } from "mobx";
const { Filter } = api;
import SelectionStore from "./SelectionStore";
//import CommonStore from "./CommonStore";

Expand All @@ -41,6 +40,8 @@ import { isDesktop } from "@docspace/shared/utils";
import { DeviceType } from "@docspace/shared/enums";
import { toastr } from "@docspace/shared/components/toast";

const { Filter } = api;

class SettingsSetupStore {
selectionStore = null;
authStore = null;
Expand Down
6 changes: 1 addition & 5 deletions packages/doceditor/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const Root = ({
isVisibleSelectFolderDialog ||
selectFileDialogVisible
) {
calculateAsideHeight();
setTimeout(() => calculateAsideHeight(calculateAsideHeight), 10);

const activeElement = document.activeElement as HTMLElement | null;

Expand All @@ -203,10 +203,6 @@ const Root = ({
} else if (editorRef.current) {
editorRef.current.focus();
}

if (isSharingDialogVisible) {
setTimeout(calculateAsideHeight, 10);
}
}, [
isSharingDialogVisible,
isVisibleSelectFolderDialog,
Expand Down
52 changes: 34 additions & 18 deletions packages/doceditor/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,43 @@ export const getIsZoom = () =>
window?.navigator?.userAgent?.includes("ZoomApps"));

// need for separate window in desktop editors
export const calculateAsideHeight = () => {
export const calculateAsideHeight = (callback?: () => void) => {
const viewPort = window?.AscDesktopEditor?.getViewportSettings?.();

if (!viewPort) return;
if (!viewPort?.widgetType || viewPort.widgetType !== "window") return;

if (viewPort.widgetType === "window") {
const { captionHeight } = viewPort;
const backdrop =
(document.getElementsByClassName("backdrop-active")[0] as HTMLElement) ??
(document.getElementsByClassName(
"modal-backdrop-active",
)[0] as HTMLElement);
const aside = document.getElementsByTagName("aside")[0];
const { captionHeight } = viewPort;

if (backdrop) {
backdrop.style.height = `calc(100dvh - ${captionHeight}px`;
backdrop.style.marginTop = `${captionHeight}px`;
}
if (aside) {
aside.style.height = `calc(100dvh - ${captionHeight}px`;
aside.style.top = `${captionHeight}px`;
}
const elements = {
backdrop: document.querySelector(
".backdrop-active, .modal-backdrop-active",
),
aside: document.querySelector("aside"),
};

const isElementInDom = !!elements.backdrop || !!elements.aside;

if (!isElementInDom)
return setTimeout(() => {
if (typeof callback === "function") callback();
}, 350);

const styles = {
height: `calc(100dvh - ${captionHeight}px)`,
top: `${captionHeight}px`,
};

if (elements.backdrop) {
Object.assign((elements.backdrop as HTMLElement).style, {
height: styles.height,
marginTop: styles.top,
});
}

if (elements.aside) {
Object.assign(elements.aside.style, {
height: styles.height,
top: styles.top,
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const CreateUserForm = (props: CreateUserFormProps) => {
await signupOAuth(signupAccount, confirmKey);

const url = roomData.roomId
? `/rooms/shared/${roomData.roomId}/filter?folder=${roomData.roomId}/`
? `/rooms/shared/${roomData.roomId}/filter?folder=${roomData.roomId}`
: defaultPage;
window.location.replace(url);
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/components/calendar/Calendar.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ const StyledContainerTheme = styled(Container)<{
${HeaderActionIcon} {
border-color: ${(props) => props.$currentColorScheme?.main?.accent};
}
border: 1px solid ${({ theme }) => theme.calendar.containerBorderColor};
`;

const StyledDateItemTheme = styled(DateItem)<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const RecoverAccessModalDialog: React.FC<IRecoverAccessModalDialogProps> = ({
onBlur={onBlurEmail}
onChange={onChangeEmail}
onValidateInput={onValidateEmail}
maxLength={255}
/>
</FieldContainer>
<FieldContainer
Expand Down
1 change: 1 addition & 0 deletions packages/shared/selectors/Files/FilesSelector.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,5 @@ export type FilesSelectorProps = TSelectorHeader &
createDefineRoomType?: RoomsType;
formProps?: FormPropsType;
withPadding?: boolean;
checkCreating?: boolean;
};
22 changes: 21 additions & 1 deletion packages/shared/selectors/Files/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import useSocketHelper from "./hooks/useSocketHelper";
import { FilesSelectorProps } from "./FilesSelector.types";
import { SettingsContextProvider } from "./contexts/Settings";
import { LoadersContext, LoadersContextProvider } from "./contexts/Loaders";
import { createFolder, deleteFolder } from "../../api/files";

const FilesSelectorComponent = ({
disabledItems,
Expand Down Expand Up @@ -119,6 +120,7 @@ const FilesSelectorComponent = ({

withPadding,
folderIsShared,
checkCreating,
}: FilesSelectorProps) => {
const theme = useTheme();
const { t } = useTranslation(["Common"]);
Expand Down Expand Up @@ -156,6 +158,9 @@ const FilesSelectorComponent = ({
const [isSelectedParentFolder, setIsSelectedParentFolder] =
React.useState<boolean>(false);
const [searchValue, setSearchValue] = React.useState<string>("");
const [isDisabledFolder, setIsDisabledFolder] = React.useState<
boolean | undefined
>(checkCreating);

const afterSearch = React.useRef(false);
const currentSelectedItemId = React.useRef<undefined | number | string>(
Expand Down Expand Up @@ -303,8 +308,10 @@ const FilesSelectorComponent = ({
],
);

const translation = t("Common:NewFolder");

const onSelectAction = React.useCallback(
(
async (
item: TSelectorItem,
isDoubleClick: boolean,
doubleClickCallback: () => Promise<void>,
Expand Down Expand Up @@ -340,6 +347,16 @@ const FilesSelectorComponent = ({
} else {
setSelectedItemType("files");
}

if (checkCreating && breadCrumbs.length === 1 && item.id) {
try {
const folderInfo = await createFolder(item.id, translation);
await deleteFolder(folderInfo.id, true, true);
setIsDisabledFolder(false);
} catch (e) {
setIsDisabledFolder(true);
}
}
} else if (item.id && item.label) {
const inPublic =
breadCrumbs.findIndex(
Expand Down Expand Up @@ -367,6 +384,8 @@ const FilesSelectorComponent = ({
setIsFirstLoad,
formProps?.isRoomFormAccessible,
formProps?.message,
translation,
checkCreating,
],
);

Expand Down Expand Up @@ -561,6 +580,7 @@ const FilesSelectorComponent = ({
isRoot,
selectedItemSecurity,
selectedFileInfo,
isDisabledFolder,
),
};

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/themes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,8 @@ export const getBaseTheme = () => {
},

calendar: {
containerBorderColor: white,

color: black,
disabledColor: lightGraySelected,
pastColor: gray,
Expand Down
1 change: 1 addition & 0 deletions packages/shared/themes/dark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ const Dark: TTheme = {
},

calendar: {
containerBorderColor: grayDarkStrong,
color: white,
disabledColor: grayDarkStrong,
pastColor: grayDark,
Expand Down
2 changes: 1 addition & 1 deletion public/scripts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"loaders": {
"showLoader": true,
"showLoaderTime": null,
"showLoaderTime": 1000,
"loaderTime": null
}
}

0 comments on commit 06ca250

Please sign in to comment.