Web: Files: PublicRoom: fixed external link actions
This commit is contained in:
parent
5dab788680
commit
573afcb448
@ -15,7 +15,7 @@ const DeleteLinkDialogComponent = (props) => {
|
||||
setIsVisible,
|
||||
tReady,
|
||||
roomId,
|
||||
setExternalLinks,
|
||||
deleteExternalLink,
|
||||
editExternalLink,
|
||||
} = props;
|
||||
|
||||
@ -45,8 +45,8 @@ const DeleteLinkDialogComponent = (props) => {
|
||||
newLink.access = 0;
|
||||
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLinks(res);
|
||||
.then(() => {
|
||||
deleteExternalLink(newLink.sharedTo.id);
|
||||
toastr.success(t("Files:LinkDeletedSuccessfully"));
|
||||
})
|
||||
.catch((err) => toastr.error(err?.message))
|
||||
@ -104,7 +104,7 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
setDeleteLinkDialogVisible: setIsVisible,
|
||||
linkParams,
|
||||
} = dialogsStore;
|
||||
const { editExternalLink, setExternalLinks } = publicRoomStore;
|
||||
const { editExternalLink, deleteExternalLink } = publicRoomStore;
|
||||
|
||||
return {
|
||||
visible,
|
||||
@ -112,6 +112,6 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
roomId: selectionParentRoom.id,
|
||||
link: linkParams.link,
|
||||
editExternalLink,
|
||||
setExternalLinks,
|
||||
deleteExternalLink,
|
||||
};
|
||||
})(observer(DeleteLinkDialog));
|
||||
|
@ -21,20 +21,18 @@ import LinkBlock from "./LinkBlock";
|
||||
import ToggleBlock from "./ToggleBlock";
|
||||
import PasswordAccessBlock from "./PasswordAccessBlock";
|
||||
import LimitTimeBlock from "./LimitTimeBlock";
|
||||
import { LinkType } from "../../../helpers/constants";
|
||||
import { isMobileOnly } from "react-device-detect";
|
||||
|
||||
const EditLinkPanel = (props) => {
|
||||
const {
|
||||
t,
|
||||
roomId,
|
||||
linkId,
|
||||
isEdit,
|
||||
visible,
|
||||
password,
|
||||
setIsVisible,
|
||||
editExternalLink,
|
||||
setExternalLinks,
|
||||
setExternalLink,
|
||||
shareLink,
|
||||
unsavedChangesDialogVisible,
|
||||
setUnsavedChangesDialog,
|
||||
@ -47,7 +45,7 @@ const EditLinkPanel = (props) => {
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const linkTitle = link.sharedTo.title ?? "";
|
||||
const linkTitle = link?.sharedTo?.title ?? "";
|
||||
const [linkNameValue, setLinkNameValue] = useState(linkTitle);
|
||||
const [passwordValue, setPasswordValue] = useState(password);
|
||||
const [expirationDate, setExpirationDate] = useState(date);
|
||||
@ -93,7 +91,9 @@ const EditLinkPanel = (props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const newLink = JSON.parse(JSON.stringify(link));
|
||||
const externalLink = link ?? { access: 2, sharedTo: {} };
|
||||
|
||||
const newLink = JSON.parse(JSON.stringify(externalLink));
|
||||
|
||||
newLink.sharedTo.title = linkNameValue;
|
||||
newLink.sharedTo.password = passwordAccessIsChecked ? passwordValue : null;
|
||||
@ -102,10 +102,8 @@ const EditLinkPanel = (props) => {
|
||||
|
||||
setIsLoading(true);
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLinks(res);
|
||||
|
||||
const link = res.find((l) => l?.sharedTo?.id === linkId);
|
||||
.then((link) => {
|
||||
setExternalLink(link);
|
||||
|
||||
if (isEdit) {
|
||||
copy(linkValue);
|
||||
@ -271,25 +269,22 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
setUnsavedChangesDialog,
|
||||
linkParams,
|
||||
} = dialogsStore;
|
||||
const { externalLinks, editExternalLink, setExternalLinks } = publicRoomStore;
|
||||
const { externalLinks, editExternalLink, setExternalLink } = publicRoomStore;
|
||||
const { isEdit } = linkParams;
|
||||
|
||||
const linkId = linkParams?.link?.sharedTo?.id;
|
||||
const link = externalLinks.find((l) => l?.sharedTo?.id === linkId);
|
||||
const template = externalLinks.find(
|
||||
(t) =>
|
||||
t?.sharedTo?.isTemplate && t?.sharedTo?.linkType === LinkType.External
|
||||
);
|
||||
const shareLink = link?.sharedTo?.shareLink ?? template?.sharedTo?.shareLink;
|
||||
|
||||
const shareLink = link?.sharedTo?.shareLink;
|
||||
|
||||
return {
|
||||
visible: editLinkPanelIsVisible,
|
||||
setIsVisible: setEditLinkPanelIsVisible,
|
||||
isEdit,
|
||||
linkId: link?.sharedTo?.id ?? template?.sharedTo?.id,
|
||||
linkId: link?.sharedTo?.id,
|
||||
editExternalLink,
|
||||
roomId: selectionParentRoom.id,
|
||||
setExternalLinks,
|
||||
setExternalLink,
|
||||
isLocked: !!link?.sharedTo?.password,
|
||||
password: link?.sharedTo?.password ?? "",
|
||||
date: link?.sharedTo?.expirationDate,
|
||||
@ -298,7 +293,7 @@ export default inject(({ auth, dialogsStore, publicRoomStore }) => {
|
||||
externalLinks,
|
||||
unsavedChangesDialogVisible,
|
||||
setUnsavedChangesDialog,
|
||||
link: link ?? template,
|
||||
link,
|
||||
language: auth.language,
|
||||
};
|
||||
})(
|
||||
|
@ -94,7 +94,7 @@ const MembersList = (props) => {
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledMembersList className="aaaaaaaaaw">
|
||||
<StyledMembersList>
|
||||
<AutoSizer>
|
||||
{({ height, width }) => (
|
||||
<InfiniteLoader
|
||||
|
@ -40,15 +40,8 @@ const LinkRow = (props) => {
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const {
|
||||
title,
|
||||
shareLink,
|
||||
id,
|
||||
password,
|
||||
disabled,
|
||||
expirationDate,
|
||||
isExpired,
|
||||
} = link.sharedTo;
|
||||
const { title, shareLink, password, disabled, expirationDate, isExpired } =
|
||||
link.sharedTo;
|
||||
|
||||
const isLocked = !!password;
|
||||
const expiryDate = !!expirationDate;
|
||||
@ -76,8 +69,8 @@ const LinkRow = (props) => {
|
||||
newLink.sharedTo.disabled = !newLink.sharedTo.disabled;
|
||||
|
||||
editExternalLink(roomId, newLink)
|
||||
.then((res) => {
|
||||
setExternalLink(id, res);
|
||||
.then((link) => {
|
||||
setExternalLink(link);
|
||||
|
||||
disabled
|
||||
? toastr.success(t("Files:LinkEnabledSuccessfully"))
|
||||
|
@ -2459,13 +2459,9 @@ class FilesStore {
|
||||
});
|
||||
};
|
||||
|
||||
// 2 (External link), 3 (All links);
|
||||
|
||||
getRoomLinks = (id) => {
|
||||
// 1 (Invitation link)
|
||||
|
||||
return api.rooms
|
||||
.getRoomMembers(id, { filterType: 1 })
|
||||
.getRoomMembers(id, { filterType: 2 }) // 2 (External link)
|
||||
.then((res) => res.items);
|
||||
};
|
||||
|
||||
|
@ -45,12 +45,25 @@ class PublicRoomStore {
|
||||
this.externalLinks = externalLinks;
|
||||
};
|
||||
|
||||
setExternalLink = (linkId, data) => {
|
||||
const linkIndex = this.externalLinks.findIndex(
|
||||
(l) => l.sharedTo.id === linkId
|
||||
deleteExternalLink = (linkId) => {
|
||||
const externalLinks = this.externalLinks.filter(
|
||||
(l) => l.sharedTo.id !== linkId
|
||||
);
|
||||
const dataLink = data.find((l) => l.sharedTo.id === linkId);
|
||||
this.externalLinks[linkIndex] = dataLink;
|
||||
this.externalLinks = externalLinks;
|
||||
};
|
||||
|
||||
setExternalLink = (link) => {
|
||||
const linkIndex = this.externalLinks.findIndex(
|
||||
(l) => l.sharedTo.id === link.sharedTo.id
|
||||
);
|
||||
const externalLinks = this.externalLinks;
|
||||
|
||||
if (linkIndex === -1) {
|
||||
externalLinks.push(link);
|
||||
this.externalLinks = externalLinks;
|
||||
} else {
|
||||
externalLinks[linkIndex] = link;
|
||||
}
|
||||
};
|
||||
|
||||
setExternalLinks = (links) => {
|
||||
|
Loading…
Reference in New Issue
Block a user