From b68eba4b63dd63e53c11fed6a4dd1616f1ac8a05 Mon Sep 17 00:00:00 2001 From: Aditya Sharma <65771169+adityash1@users.noreply.github.com> Date: Sat, 18 Mar 2023 02:56:55 +0530 Subject: [PATCH] [GH-4699]: Improve share dialog for nested docs (#4719) Co-authored-by: Tom Moor --- .../Document/components/SharePopover.tsx | 124 +++++++++++------- shared/i18n/locales/en_US/translation.json | 6 +- 2 files changed, 80 insertions(+), 50 deletions(-) diff --git a/app/scenes/Document/components/SharePopover.tsx b/app/scenes/Document/components/SharePopover.tsx index c6e58320b..6857a5876 100644 --- a/app/scenes/Document/components/SharePopover.tsx +++ b/app/scenes/Document/components/SharePopover.tsx @@ -5,6 +5,7 @@ import { observer } from "mobx-react"; import { ExpandedIcon, GlobeIcon, PadlockIcon } from "outline-icons"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; +import { Link } from "react-router-dom"; import styled from "styled-components"; import { SHARE_URL_SLUG_REGEX } from "@shared/utils/urlHelpers"; import Document from "~/models/Document"; @@ -161,14 +162,61 @@ function SharePopover({ [t, document.id, shares] ); + const PublishToInternet = ({ canPublish }: { canPublish: boolean }) => { + if (!canPublish) { + return ( + + {t("Only members with permission can view")} + + ); + } + return ( + + + + + {share?.published + ? t("Anyone with the link can view this document") + : t("Only members with permission can view")} + {share?.lastAccessedAt && ( + <> + .{" "} + {t("The shared link was last accessed {{ timeAgo }}.", { + timeAgo: formatDistanceToNow( + Date.parse(share?.lastAccessedAt), + { + addSuffix: true, + locale, + } + ), + })} + + )} + + + + ); + }; + const userLocale = useUserLocale(); const locale = userLocale ? dateLocale(userLocale) : undefined; - let shareUrl = team.sharing ? share?.url ?? "" : `${team.url}${document.url}`; + let shareUrl = team.sharing + ? sharedParent?.url + ? `${sharedParent.url}${document.url}` + : share?.url ?? "" + : `${team.url}${document.url}`; if (isEditMode) { shareUrl += "?edit=true"; } const url = shareUrl.replace(/https?:\/\//, ""); + const documentTitle = sharedParent?.documentTitle; return ( <> @@ -182,54 +230,21 @@ function SharePopover({ {sharedParent && !document.isDraft && ( - - , - }} - /> - + + + + This document is shared because the parent{" "} + + {documentTitle} + {" "} + is publicly shared. + + + )} - {canPublish ? ( - - - - - {share?.published - ? t("Anyone with the link can view this document") - : t("Only members with permission can view")} - {share?.lastAccessedAt && ( - <> - .{" "} - {t("The shared link was last accessed {{ timeAgo }}.", { - timeAgo: formatDistanceToNow( - Date.parse(share?.lastAccessedAt), - { - addSuffix: true, - locale, - } - ), - })} - - )} - - - - ) : ( - - {t("Only members with permission can view")} - + {canPublish && !sharedParent?.published && ( + )} {canPublish && share?.published && !document.isDraft && ( @@ -254,6 +269,12 @@ function SharePopover({ {expandedOptions && ( <> + {canPublish && sharedParent?.published && ( + <> + + + + )} props.theme.textSecondary}; + text-decoration: underline; +`; + const Heading = styled.h2` display: flex; align-items: center; @@ -341,6 +367,10 @@ const SwitchWrapper = styled.div` margin: 20px 0; `; +const NoticeWrapper = styled.div` + margin: 20px 0; +`; + const MoreOptionsButton = styled(Button)` background: none; font-size: 14px; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index db59b9f4b..775e25a57 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -500,12 +500,12 @@ "Share": "Share", "Only lowercase letters, digits and dashes allowed": "Only lowercase letters, digits and dashes allowed", "Sorry, this link has already been used": "Sorry, this link has already been used", - "Share this document": "Share this document", - "This document is shared because the parent {{ documentTitle }} is publicly shared": "This document is shared because the parent {{ documentTitle }} is publicly shared", + "Only members with permission can view": "Only members with permission can view", "Publish to internet": "Publish to internet", "Anyone with the link can view this document": "Anyone with the link can view this document", - "Only members with permission can view": "Only members with permission can view", "The shared link was last accessed {{ timeAgo }}.": "The shared link was last accessed {{ timeAgo }}.", + "Share this document": "Share this document", + "This document is shared because the parent<1>{documentTitle}is publicly shared.": "This document is shared because the parent<1>{documentTitle}is publicly shared.", "Share nested documents": "Share nested documents", "Nested documents are publicly available": "Nested documents are publicly available", "Nested documents are not shared": "Nested documents are not shared",