mirror of
https://github.com/outline/outline.git
synced 2026-12-05 02:44:34 +03:00
stash
This commit is contained in:
1 parent
00205e9eb5
commit
a88fc392de
11 files changed
+92
-84
No files matched your search
@@ -32,13 +32,13 @@ import { toast } from "sonner";
|
||||
import { ExportContentType, TeamPreference } from "@shared/types";
|
||||
import MarkdownHelper from "@shared/utils/MarkdownHelper";
|
||||
import { getEventFiles } from "@shared/utils/files";
|
||||
import SharePopover from "~/scenes/Document/components/SharePopover";
|
||||
import DocumentDelete from "~/scenes/DocumentDelete";
|
||||
import DocumentMove from "~/scenes/DocumentMove";
|
||||
import DocumentPermanentDelete from "~/scenes/DocumentPermanentDelete";
|
||||
import DocumentPublish from "~/scenes/DocumentPublish";
|
||||
import DocumentTemplatizeDialog from "~/components/DocumentTemplatizeDialog";
|
||||
import DuplicateDialog from "~/components/DuplicateDialog";
|
||||
import SharePopover from "~/components/Sharing";
|
||||
import { createAction } from "~/actions";
|
||||
import { DocumentSection } from "~/actions/sections";
|
||||
import env from "~/env";
|
||||
@@ -952,4 +952,5 @@ export const rootDocumentActions = [
|
||||
openDocumentComments,
|
||||
openDocumentHistory,
|
||||
openDocumentInsights,
|
||||
shareDocument,
|
||||
];
|
||||
File renamed without changes.
@@ -163,6 +163,7 @@ const InputSelect = (props: Props) => {
|
||||
topAnchor={topAnchor}
|
||||
rightAnchor={rightAnchor}
|
||||
hiddenScrollbars
|
||||
maxWidth={400}
|
||||
style={
|
||||
maxHeight && topAnchor
|
||||
? {
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { $Diff } from "utility-types";
|
||||
import { CollectionPermission } from "@shared/types";
|
||||
import { EmptySelectValue } from "~/types";
|
||||
import InputSelect, { Props, Option } from "./InputSelect";
|
||||
|
||||
export default function InputSelectPermission(
|
||||
@@ -17,7 +18,7 @@ export default function InputSelectPermission(
|
||||
const { t } = useTranslation();
|
||||
const handleChange = React.useCallback(
|
||||
(value) => {
|
||||
if (value === "no_access") {
|
||||
if (value === EmptySelectValue) {
|
||||
value = null;
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ export default function InputSelectPermission(
|
||||
label={t("Default access")}
|
||||
options={[
|
||||
{
|
||||
label: t("View and edit"),
|
||||
label: t("Can edit"),
|
||||
value: CollectionPermission.ReadWrite,
|
||||
},
|
||||
{
|
||||
@@ -40,11 +41,11 @@ export default function InputSelectPermission(
|
||||
},
|
||||
{
|
||||
label: t("No access"),
|
||||
value: "no_access",
|
||||
value: EmptySelectValue,
|
||||
},
|
||||
]}
|
||||
ariaLabel={t("Default access")}
|
||||
value={value || "no_access"}
|
||||
value={value || EmptySelectValue}
|
||||
onChange={handleChange}
|
||||
{...rest}
|
||||
/>
|
||||
|
||||
+19
-42
@@ -1,6 +1,6 @@
|
||||
import { t } from "i18next";
|
||||
import { orderBy } from "lodash";
|
||||
import isNil from "lodash/isNil";
|
||||
import orderBy from "lodash/orderBy";
|
||||
import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
import { toast } from "sonner";
|
||||
@@ -11,6 +11,7 @@ import User from "~/models/User";
|
||||
import UserMembership from "~/models/UserMembership";
|
||||
import Avatar from "~/components/Avatar";
|
||||
import { AvatarSize } from "~/components/Avatar/Avatar";
|
||||
import Combobox from "~/components/Combobox";
|
||||
import Flex from "~/components/Flex";
|
||||
import LoadingIndicator from "~/components/LoadingIndicator";
|
||||
import PaginatedList from "~/components/PaginatedList";
|
||||
@@ -18,7 +19,6 @@ import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
import useRequest from "~/hooks/useRequest";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import useThrottledCallback from "~/hooks/useThrottledCallback";
|
||||
import Combobox from "./Combobox";
|
||||
import MemberListItem from "./MemberListItem";
|
||||
|
||||
type Props = {
|
||||
@@ -26,38 +26,31 @@ type Props = {
|
||||
document: Document;
|
||||
};
|
||||
|
||||
function InviteTeamMembers({ document }: Props) {
|
||||
function DocumentMembersList({ document }: Props) {
|
||||
const { users, userMemberships } = useStores();
|
||||
const [query, setQuery] = React.useState("");
|
||||
const [selectedUser, setSelectedUser] = React.useState<User | null>(null);
|
||||
const [invitedInSession, setInvitedInSession] = React.useState<string[]>([]);
|
||||
const user = useCurrentUser();
|
||||
|
||||
const {
|
||||
data: teamMembers,
|
||||
loading: loadingTeamMembers,
|
||||
request: fetchTeamMembers,
|
||||
} = useRequest(
|
||||
const { loading: loadingTeamMembers, request: fetchTeamMembers } = useRequest(
|
||||
React.useCallback(
|
||||
() => users.fetchPage({ limit: Pagination.defaultLimit }),
|
||||
[users]
|
||||
)
|
||||
);
|
||||
|
||||
const {
|
||||
data: documentMembers,
|
||||
loading: loadingDocumentMembers,
|
||||
request: fetchDocumentMembers,
|
||||
} = useRequest(
|
||||
React.useCallback(
|
||||
() =>
|
||||
userMemberships.fetchDocumentMemberships({
|
||||
id: document.id,
|
||||
limit: Pagination.defaultLimit,
|
||||
}),
|
||||
[userMemberships, document.id]
|
||||
)
|
||||
);
|
||||
const { loading: loadingDocumentMembers, request: fetchDocumentMembers } =
|
||||
useRequest(
|
||||
React.useCallback(
|
||||
() =>
|
||||
userMemberships.fetchDocumentMemberships({
|
||||
id: document.id,
|
||||
limit: Pagination.defaultLimit,
|
||||
}),
|
||||
[userMemberships, document.id]
|
||||
)
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
void fetchTeamMembers();
|
||||
@@ -85,20 +78,8 @@ function InviteTeamMembers({ document }: Props) {
|
||||
|
||||
const nonMembers = React.useMemo(
|
||||
() =>
|
||||
teamMembers && documentMembers
|
||||
? users
|
||||
.notInDocument(document.id, query)
|
||||
.filter((u) => u.id !== user.id)
|
||||
: [],
|
||||
[
|
||||
users,
|
||||
document.id,
|
||||
document.members,
|
||||
teamMembers,
|
||||
documentMembers,
|
||||
user.id,
|
||||
query,
|
||||
]
|
||||
users.notInDocument(document.id, query).filter((u) => u.id !== user.id),
|
||||
[users, users.orderedData, document.id, document.members, user.id, query]
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -178,10 +159,6 @@ function InviteTeamMembers({ document }: Props) {
|
||||
return <LoadingIndicator />;
|
||||
}
|
||||
|
||||
if (!teamMembers && !documentMembers) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<RelativeFlex column>
|
||||
<Combobox
|
||||
@@ -199,7 +176,7 @@ function InviteTeamMembers({ document }: Props) {
|
||||
onChangeInput={handleQuery}
|
||||
onSelectOption={handleSelect}
|
||||
listLabel={t("Team members")}
|
||||
placeholder={`${t("Add workspace members")}…`}
|
||||
placeholder={`${t("Find by name")}…`}
|
||||
autoFocus
|
||||
/>
|
||||
<PaginatedList
|
||||
@@ -224,4 +201,4 @@ const RelativeFlex = styled(Flex)`
|
||||
position: relative;
|
||||
`;
|
||||
|
||||
export default observer(InviteTeamMembers);
|
||||
export default observer(DocumentMembersList);
|
||||
+6
-5
@@ -47,23 +47,24 @@ const MemberListItem = ({
|
||||
image={<Avatar model={user} size={AvatarSize.Medium} />}
|
||||
border={false}
|
||||
style={{ marginRight: -8 }}
|
||||
small
|
||||
actions={
|
||||
<Flex align="center" gap={8}>
|
||||
{onUpdate && (
|
||||
<InputMemberPermissionSelect
|
||||
permissions={[
|
||||
{
|
||||
label: t("No access"),
|
||||
value: EmptySelectValue,
|
||||
},
|
||||
{
|
||||
label: t("View only"),
|
||||
value: DocumentPermission.Read,
|
||||
},
|
||||
{
|
||||
label: t("View and edit"),
|
||||
label: t("Can edit"),
|
||||
value: DocumentPermission.ReadWrite,
|
||||
},
|
||||
{
|
||||
label: t("No access"),
|
||||
value: EmptySelectValue,
|
||||
},
|
||||
]}
|
||||
value={membership?.permission}
|
||||
onChange={handleChange}
|
||||
+52
-28
@@ -25,7 +25,9 @@ import useKeyDown from "~/hooks/useKeyDown";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import useUserLocale from "~/hooks/useUserLocale";
|
||||
import InviteTeamMembers from "./InviteTeamMembers";
|
||||
import { EmptySelectValue } from "~/types";
|
||||
import InputSelect from "../InputSelect";
|
||||
import DocumentMembersList from "./DocumentMemberList";
|
||||
|
||||
type Props = {
|
||||
/** The document to share. */
|
||||
@@ -221,7 +223,7 @@ function SharePopover({
|
||||
|
||||
return (
|
||||
<>
|
||||
{!hideTitle && (
|
||||
{/* {!hideTitle && (
|
||||
<Heading>
|
||||
{isPubliclyShared ? (
|
||||
<GlobeIcon size={28} />
|
||||
@@ -230,7 +232,7 @@ function SharePopover({
|
||||
)}
|
||||
<span>{t("Share this document")}</span>
|
||||
</Heading>
|
||||
)}
|
||||
)} */}
|
||||
|
||||
{sharedParent && !document.isDraft && (
|
||||
<NoticeWrapper>
|
||||
@@ -246,9 +248,53 @@ function SharePopover({
|
||||
</NoticeWrapper>
|
||||
)}
|
||||
|
||||
{canPublish && !sharedParent?.published && (
|
||||
{/* {canPublish && !sharedParent?.published && (
|
||||
<PublishToInternet canPublish />
|
||||
)}
|
||||
)} */}
|
||||
|
||||
<h3>People with access</h3>
|
||||
<DocumentMembersList document={document} />
|
||||
|
||||
<Separator />
|
||||
<h3>Link access</h3>
|
||||
|
||||
<Flex gap={8}>
|
||||
<InputSelect
|
||||
short={false}
|
||||
ariaLabel={t("Link access")}
|
||||
options={[
|
||||
{
|
||||
label: (
|
||||
<Flex gap={4} align="center">
|
||||
<PadlockIcon />
|
||||
{t("No public access")}
|
||||
</Flex>
|
||||
),
|
||||
value: EmptySelectValue,
|
||||
},
|
||||
{
|
||||
label: (
|
||||
<Flex gap={4} align="center">
|
||||
<GlobeIcon />
|
||||
{t("Anyone with link can view")}
|
||||
</Flex>
|
||||
),
|
||||
value: "public",
|
||||
},
|
||||
]}
|
||||
// value={value || EmptySelectValue}
|
||||
// onChange={handleChange}
|
||||
/>
|
||||
<CopyToClipboard text={shareUrl} onCopy={handleCopied}>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!share || slugValidationError}
|
||||
ref={buttonRef}
|
||||
>
|
||||
{t("Copy link")}
|
||||
</Button>
|
||||
</CopyToClipboard>
|
||||
</Flex>
|
||||
|
||||
{canPublish && share && !document.isDraft && (
|
||||
<SwitchWrapper>
|
||||
@@ -270,24 +316,11 @@ function SharePopover({
|
||||
</SwitchWrapper>
|
||||
)}
|
||||
|
||||
{canPublish ? (
|
||||
<>
|
||||
<Separator />
|
||||
<SwitchWrapper>
|
||||
<InviteTeamMembers document={document} />
|
||||
</SwitchWrapper>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{expandedOptions && (
|
||||
<>
|
||||
{canPublish && sharedParent?.published && (
|
||||
<>
|
||||
<Separator />
|
||||
<PublishToInternet canPublish />
|
||||
</>
|
||||
<PublishToInternet canPublish />
|
||||
)}
|
||||
<Separator />
|
||||
<SwitchWrapper>
|
||||
<Switch
|
||||
id="enableEditMode"
|
||||
@@ -346,15 +379,6 @@ function SharePopover({
|
||||
{t("More options")}
|
||||
</MoreOptionsButton>
|
||||
)}
|
||||
<CopyToClipboard text={shareUrl} onCopy={handleCopied}>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!share || slugValidationError}
|
||||
ref={buttonRef}
|
||||
>
|
||||
{t("Copy link")}
|
||||
</Button>
|
||||
</CopyToClipboard>
|
||||
</Flex>
|
||||
</>
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
import SharePopover from "./SharePopover";
|
||||
|
||||
export default SharePopover;
|
||||
@@ -37,7 +37,7 @@ const CollectionGroupMemberListItem = ({
|
||||
value: CollectionPermission.Read,
|
||||
},
|
||||
{
|
||||
label: t("View and edit"),
|
||||
label: t("Can edit"),
|
||||
value: CollectionPermission.ReadWrite,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ const MemberListItem = ({
|
||||
value: CollectionPermission.Read,
|
||||
},
|
||||
{
|
||||
label: t("View and edit"),
|
||||
label: t("Can edit"),
|
||||
value: CollectionPermission.ReadWrite,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,10 +6,10 @@ import { usePopoverState, PopoverDisclosure } from "reakit/Popover";
|
||||
import Document from "~/models/Document";
|
||||
import Button from "~/components/Button";
|
||||
import Popover from "~/components/Popover";
|
||||
import SharePopover from "~/components/Sharing";
|
||||
import Tooltip from "~/components/Tooltip";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import SharePopover from "./SharePopover";
|
||||
|
||||
type Props = {
|
||||
document: Document;
|
||||
@@ -61,7 +61,7 @@ function ShareButton({ document }: Props) {
|
||||
)}
|
||||
</PopoverDisclosure>
|
||||
|
||||
<Popover {...popover} aria-label={t("Share")}>
|
||||
<Popover {...popover} aria-label={t("Share")} width={400}>
|
||||
<SharePopover
|
||||
document={document}
|
||||
share={share}
|
||||
|
||||
Reference in new issue
Block a user