Web: Files: fixed empty links context-menu

This commit is contained in:
Nikita Gopienko 2023-07-19 15:24:05 +03:00
parent af744d3dff
commit 17be338ccf
12 changed files with 65 additions and 29 deletions

View File

@ -146,5 +146,7 @@
"Links": "Links",
"WantToRestoreTheRoom": "All external links in this room will become active, and its contents will be available to everyone with the link. Do you want to restore the room?",
"WantToRestoreTheRooms": "All external links in restored rooms will become active, and their contents will be available to everyone with the room links. Do you want to restore the rooms?",
"LinkValidUntil": "This link will be valid until"
"LinkValidUntil": "This link will be valid until",
"NoExternalLinks": "No external links",
"AllLinksAreDisabled": "All links are disabled"
}

View File

@ -39,6 +39,5 @@
"SystemProperties": "System properties",
"UsersInRoom": "Users in room",
"Versions": "Versions",
"LinksToViewingIcon": "Links to Viewing",
"NoExternalLinks": "No external links"
"LinksToViewingIcon": "Links to Viewing"
}

View File

@ -42,7 +42,7 @@ const PublicRoomBlock = (props) => {
<Text fontSize="14px" fontWeight={600} color="#a3a9ae">
{externalLinks.length
? t("LinksToViewingIcon")
: t("NoExternalLinks")}
: t("Files:NoExternalLinks")}
</Text>
<IconButton
className="link-to-viewing-icon"

View File

@ -224,7 +224,7 @@ export default inject(({ auth, treeFoldersStore, filesStore }) => {
};
})(
observer(
withTranslation(["Files", "Translations"])(
withTranslation(["Files", "Translations", "Notifications"])(
withContent(withBadges(FilesRowContent))
)
)

View File

@ -367,6 +367,9 @@ const SimpleFilesRow = (props) => {
);
};
export default withTranslation(["Files", "Translations", "InfoPanel"])(
withFileActions(withQuickButtons(SimpleFilesRow))
);
export default withTranslation([
"Files",
"Translations",
"InfoPanel",
"Notifications",
])(withFileActions(withQuickButtons(SimpleFilesRow)));

View File

@ -544,7 +544,7 @@ export default inject(
};
}
)(
withTranslation(["Files", "Common", "Translations"])(
withTranslation(["Files", "Common", "Translations", "Notifications"])(
observer(FilesTableHeader)
)
);

View File

@ -168,6 +168,9 @@ const FilesTableRow = (props) => {
);
};
export default withTranslation(["Files", "Common", "InfoPanel"])(
withFileActions(withContent(withQuickButtons(withBadges(FilesTableRow))))
);
export default withTranslation([
"Files",
"Common",
"InfoPanel",
"Notifications",
])(withFileActions(withContent(withQuickButtons(withBadges(FilesTableRow)))));

View File

@ -170,7 +170,7 @@ export default inject(
};
}
)(
withTranslation(["Files", "InfoPanel"])(
withTranslation(["Files", "InfoPanel", "Notifications"])(
withFileActions(withBadges(withQuickButtons(observer(FileTile))))
)
);

View File

@ -127,7 +127,7 @@ export default inject(({ auth, treeFoldersStore }) => {
return { theme: auth.settingsStore.theme, isRooms };
})(
observer(
withTranslation(["Files", "Translations"])(
withTranslation(["Files", "Translations", "Notifications"])(
withContent(withBadges(FilesTileContent))
)
)

View File

@ -290,4 +290,6 @@ export default inject(({ auth, filesStore, treeFoldersStore }) => {
isRecentFolder,
isDesc,
};
})(observer(withTranslation(["Files", "Common"])(TileContainer)));
})(
observer(withTranslation(["Files", "Common", "Notifications"])(TileContainer))
);

View File

@ -559,26 +559,53 @@ class ContextOptionsStore {
onLoadLinks = async (t, item) => {
const promise = new Promise(async (resolve, reject) => {
const linksArray = [];
let linksArray = [];
this.setLoaderTimer(true);
try {
const links = await this.publicRoomStore.fetchExternalLinks(item.id);
for (let item of links) {
const { id, title, shareLink } = item.sharedTo;
const { id, title, shareLink, disabled, isExpired } = item.sharedTo;
linksArray.push({
icon: InvitationLinkReactSvgUrl,
id,
key: `external-link_${id}`,
label: title,
onClick: () => {
copy(shareLink);
toastr.success(t("Files:LinkSuccessfullyCopied"));
},
});
if (!disabled && !isExpired) {
linksArray.push({
icon: InvitationLinkReactSvgUrl,
id,
key: `external-link_${id}`,
label: title,
onClick: () => {
copy(shareLink);
toastr.success(t("Files:LinkSuccessfullyCopied"));
},
});
}
}
if (!linksArray.length) {
linksArray = [
{
id: "no-external-links-option",
key: "no-external-links",
label: !links.length
? t("Files:NoExternalLinks")
: t("Files:AllLinksAreDisabled"),
disableColor: true,
},
{
key: "separator0",
isSeparator: true,
},
{
icon: SettingsReactSvgUrl,
id: "manage-option",
key: "manage-links",
label: t("Notifications:ManageNotifications"),
onClick: () => this.onShowInfoPanel(item),
},
];
}
this.setLoaderTimer(false, () => resolve(linksArray));
} catch (error) {
toastr.error(error);

View File

@ -155,10 +155,10 @@ const SubMenu = (props) => {
item.className
);
const linkClassName = classNames("p-menuitem-link", "not-selectable", {
"p-disabled": item.disabled,
"p-disabled": item.disabled || item.disableColor,
});
const iconClassName = classNames("p-menuitem-icon", {
"p-disabled": item.disabled,
"p-disabled": item.disabled || item.disableColor,
});
const subMenuIconClassName = "p-submenu-icon";