Skip to content

Commit

Permalink
Merge branch 'main' of github.com:outline/outline into migrate-s3-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed Apr 3, 2024
2 parents 3c7adbd + 6a4628a commit 26f87a1
Show file tree
Hide file tree
Showing 97 changed files with 1,885 additions and 1,929 deletions.
30 changes: 12 additions & 18 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ PORT=3000
# server, for normal operation this does not need to be set.
COLLABORATION_URL=

# To support uploading of images for avatars and document attachments an
# s3-compatible storage must be provided. AWS S3 is recommended for redundancy
# however if you want to keep all file storage local an alternative such as
# minio (https://github.com/minio/minio) can be used.

# A more detailed guide on setting up S3 is available here:
# => https://wiki.generaloutline.com/share/125de1cc-9ff6-424b-8415-0d58c809a40f
#
AWS_ACCESS_KEY_ID=get_a_key_from_aws
AWS_SECRET_ACCESS_KEY=get_the_secret_of_above_key
AWS_REGION=xx-xxxx-x
AWS_S3_ACCELERATE_URL=
AWS_S3_UPLOAD_BUCKET_URL=http://s3:4569
AWS_S3_UPLOAD_BUCKET_NAME=bucket_name_here
AWS_S3_FORCE_PATH_STYLE=true
AWS_S3_ACL=private

# Specify what storage system to use. Possible value is one of "s3" or "local".
# For "local", the avatar images and document attachments will be saved on local disk.
FILE_STORAGE=local
Expand All @@ -73,6 +56,17 @@ FILE_STORAGE_IMPORT_MAX_SIZE=
# and the files are temporary being automatically deleted after a period of time.
FILE_STORAGE_WORKSPACE_IMPORT_MAX_SIZE=

# To support uploading of images for avatars and document attachments in a distributed
# architecture an s3-compatible storage can be configured if FILE_STORAGE=s3 above.
AWS_ACCESS_KEY_ID=get_a_key_from_aws
AWS_SECRET_ACCESS_KEY=get_the_secret_of_above_key
AWS_REGION=xx-xxxx-x
AWS_S3_ACCELERATE_URL=
AWS_S3_UPLOAD_BUCKET_URL=http://s3:4569
AWS_S3_UPLOAD_BUCKET_NAME=bucket_name_here
AWS_S3_FORCE_PATH_STYLE=true
AWS_S3_ACL=private

# –––––––––––––– AUTHENTICATION ––––––––––––––

# Third party signin credentials, at least ONE OF EITHER Google, Slack,
Expand Down Expand Up @@ -205,4 +199,4 @@ RATE_LIMITER_DURATION_WINDOW=60

# Iframely API config
IFRAMELY_URL=
IFRAMELY_API_KEY=
IFRAMELY_API_KEY=
7 changes: 4 additions & 3 deletions app/actions/definitions/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ export const copyDocumentAsMarkdown = createAction({
name: ({ t }) => t("Copy as Markdown"),
section: DocumentSection,
keywords: "clipboard",
visible: ({ activeDocumentId }) => !!activeDocumentId,
visible: ({ activeDocumentId, stores }) =>
!!activeDocumentId && stores.policies.abilities(activeDocumentId).download,
perform: ({ stores, activeDocumentId, t }) => {
const document = activeDocumentId
? stores.documents.get(activeDocumentId)
Expand Down Expand Up @@ -856,7 +857,7 @@ export const openDocumentHistory = createAction({
icon: <HistoryIcon />,
visible: ({ activeDocumentId, stores }) => {
const can = stores.policies.abilities(activeDocumentId ?? "");
return !!activeDocumentId && can.read && !can.restore;
return !!activeDocumentId && can.listRevisions;
},
perform: ({ activeDocumentId, stores }) => {
if (!activeDocumentId) {
Expand All @@ -883,7 +884,7 @@ export const openDocumentInsights = createAction({

return (
!!activeDocumentId &&
can.read &&
can.listViews &&
!document?.isTemplate &&
!document?.isDeleted
);
Expand Down
9 changes: 4 additions & 5 deletions app/actions/definitions/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export const navigateToSettings = createAction({
section: NavigationSection,
shortcut: ["g", "s"],
icon: <SettingsIcon />,
visible: ({ stores }) =>
stores.policies.abilities(stores.auth.team?.id || "").update,
visible: () => stores.policies.abilities(stores.auth.team?.id || "").update,
perform: () => history.push(settingsPath()),
});

Expand Down Expand Up @@ -142,7 +141,7 @@ export const toggleSidebar = createAction({
analyticsName: "Toggle sidebar",
keywords: "hide show navigation",
section: NavigationSection,
perform: ({ stores }) => stores.ui.toggleCollapsedSidebar(),
perform: () => stores.ui.toggleCollapsedSidebar(),
});

export const openFeedbackUrl = createAction({
Expand Down Expand Up @@ -205,8 +204,8 @@ export const logout = createAction({
analyticsName: "Log out",
section: NavigationSection,
icon: <LogoutIcon />,
perform: () => {
void stores.auth.logout();
perform: async () => {
await stores.auth.logout();
if (env.OIDC_LOGOUT_URI) {
window.location.replace(env.OIDC_LOGOUT_URI);
}
Expand Down
3 changes: 1 addition & 2 deletions app/actions/definitions/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export const inviteUser = createAction({
stores.policies.abilities(stores.auth.team?.id || "").inviteUser,
perform: ({ t }) => {
stores.dialogs.openModal({
title: t("Invite people"),
fullscreen: true,
title: t("Invite to workspace"),
content: <Invite onSubmit={stores.dialogs.closeAllModals} />,
});
},
Expand Down
20 changes: 12 additions & 8 deletions app/components/AuthenticatedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const AuthenticatedLayout: React.FC = ({ children }: Props) => {
const { ui, auth } = useStores();
const location = useLocation();
const layoutRef = React.useRef<HTMLDivElement>(null);
const can = usePolicy(ui.activeCollectionId);
const can = usePolicy(ui.activeDocumentId);
const canCollection = usePolicy(ui.activeCollectionId);
const team = useCurrentTeam();
const documentContext = useLocalStore<DocumentContextValue>(() => ({
editor: null,
Expand All @@ -69,7 +70,7 @@ const AuthenticatedLayout: React.FC = ({ children }: Props) => {
return;
}
const { activeCollectionId } = ui;
if (!activeCollectionId || !can.createDocument) {
if (!activeCollectionId || !canCollection.createDocument) {
return;
}
history.push(newDocumentPath(activeCollectionId));
Expand All @@ -88,15 +89,18 @@ const AuthenticatedLayout: React.FC = ({ children }: Props) => {
</Fade>
);

const showHistory = !!matchPath(location.pathname, {
path: matchDocumentHistory,
});
const showInsights = !!matchPath(location.pathname, {
path: matchDocumentInsights,
});
const showHistory =
!!matchPath(location.pathname, {
path: matchDocumentHistory,
}) && can.listRevisions;
const showInsights =
!!matchPath(location.pathname, {
path: matchDocumentInsights,
}) && can.listViews;
const showComments =
!showInsights &&
!showHistory &&
can.comment &&
ui.activeDocumentId &&
ui.commentsExpanded.includes(ui.activeDocumentId) &&
team.getPreference(TeamPreference.Commenting);
Expand Down
34 changes: 17 additions & 17 deletions app/components/HoverPreview/HoverPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from "react";
import { Portal } from "react-portal";
import styled from "styled-components";
import { depths } from "@shared/styles";
import { UnfurlType } from "@shared/types";
import { UnfurlResourceType } from "@shared/types";
import LoadingIndicator from "~/components/LoadingIndicator";
import env from "~/env";
import useEventListener from "~/hooks/useEventListener";
Expand Down Expand Up @@ -120,41 +120,41 @@ function HoverPreviewDesktop({ element, onClose }: Props) {
transitionEnd: { pointerEvents: "auto" },
}}
>
{data.type === UnfurlType.Mention ? (
{data.type === UnfurlResourceType.Mention ? (
<HoverPreviewMention
url={data.thumbnailUrl}
title={data.title}
info={data.meta.info}
color={data.meta.color}
name={data.name}
avatarUrl={data.avatarUrl}
color={data.color}
lastActive={data.lastActive}
/>
) : data.type === UnfurlType.Document ? (
) : data.type === UnfurlResourceType.Document ? (
<HoverPreviewDocument
id={data.meta.id}
url={data.url}
id={data.id}
title={data.title}
description={data.description}
info={data.meta.info}
summary={data.summary}
lastActivityByViewer={data.lastActivityByViewer}
/>
) : data.type === UnfurlType.Issue ? (
) : data.type === UnfurlResourceType.Issue ? (
<HoverPreviewIssue
url={data.url}
id={data.id}
title={data.title}
description={data.description}
author={data.author}
labels={data.labels}
state={data.state}
createdAt={data.createdAt}
identifier={data.meta.identifier}
labels={data.meta.labels}
status={data.meta.status}
/>
) : data.type === UnfurlType.Pull ? (
) : data.type === UnfurlResourceType.PR ? (
<HoverPreviewPullRequest
url={data.url}
id={data.id}
title={data.title}
description={data.description}
author={data.author}
createdAt={data.createdAt}
identifier={data.meta.identifier}
status={data.meta.status}
state={data.state}
/>
) : (
<HoverPreviewLink
Expand Down
20 changes: 5 additions & 15 deletions app/components/HoverPreview/HoverPreviewDocument.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from "react";
import { UnfurlResourceType, UnfurlResponse } from "@shared/types";
import Editor from "~/components/Editor";
import Flex from "~/components/Flex";
import {
Expand All @@ -10,21 +11,10 @@ import {
Description,
} from "./Components";

type Props = {
/** Document id associated with the editor, if any */
id?: string;
/** Document url */
url: string;
/** Title for the preview card */
title: string;
/** Info about last activity on the document */
info: string;
/** Text preview of document content */
description: string;
};
type Props = Omit<UnfurlResponse[UnfurlResourceType.Document], "type">;

const HoverPreviewDocument = React.forwardRef(function _HoverPreviewDocument(
{ id, url, title, info, description }: Props,
{ url, id, title, summary, lastActivityByViewer }: Props,
ref: React.Ref<HTMLDivElement>
) {
return (
Expand All @@ -33,12 +23,12 @@ const HoverPreviewDocument = React.forwardRef(function _HoverPreviewDocument(
<CardContent>
<Flex column gap={2}>
<Title>{title}</Title>
<Info>{info}</Info>
<Info>{lastActivityByViewer}</Info>
<Description as="div">
<React.Suspense fallback={<div />}>
<Editor
key={id}
defaultValue={description}
defaultValue={summary}
embedsDisabled
readOnly
/>
Expand Down
35 changes: 5 additions & 30 deletions app/components/HoverPreview/HoverPreviewIssue.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react";
import { Trans } from "react-i18next";
import { UnfurlResourceType, UnfurlResponse } from "@shared/types";
import Flex from "~/components/Flex";
import Avatar from "../Avatar";
import { IssueStatusIcon } from "../Icons/IssueStatusIcon";
Expand All @@ -15,36 +16,10 @@ import {
Info,
} from "./Components";

type Props = {
/** Issue url */
url: string;
/** Issue title */
title: string;
/** Issue description */
description: string;
/** Wehn the issue was created */
createdAt: string;
/** Author of the issue */
author: { name: string; avatarUrl: string };
/** Labels attached to the issue */
labels: Array<{ name: string; color: string }>;
/** Issue status */
status: { name: string; color: string };
/** Issue identifier */
identifier: string;
};
type Props = Omit<UnfurlResponse[UnfurlResourceType.Issue], "type">;

const HoverPreviewIssue = React.forwardRef(function _HoverPreviewIssue(
{
url,
title,
identifier,
description,
author,
labels,
status,
createdAt,
}: Props,
{ url, id, title, description, author, labels, state, createdAt }: Props,
ref: React.Ref<HTMLDivElement>
) {
const authorName = author.name;
Expand All @@ -56,9 +31,9 @@ const HoverPreviewIssue = React.forwardRef(function _HoverPreviewIssue(
<CardContent>
<Flex gap={2} column>
<Title>
<IssueStatusIcon status={status.name} color={status.color} />
<IssueStatusIcon status={state.name} color={state.color} />
<span>
{title}&nbsp;<Text type="tertiary">{identifier}</Text>
{title}&nbsp;<Text type="tertiary">{id}</Text>
</span>
</Title>
<Flex align="center" gap={4}>
Expand Down
22 changes: 7 additions & 15 deletions app/components/HoverPreview/HoverPreviewMention.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import * as React from "react";
import { UnfurlResourceType, UnfurlResponse } from "@shared/types";
import Avatar from "~/components/Avatar";
import { AvatarSize } from "~/components/Avatar/Avatar";
import Flex from "~/components/Flex";
import { Preview, Title, Info, Card, CardContent } from "./Components";

type Props = {
/** Resource url, avatar url in case of user mention */
url: string;
/** Title for the preview card*/
title: string;
/** Info about mentioned user's recent activity */
info: string;
/** Used for avatar's background color in absence of avatar url */
color: string;
};
type Props = Omit<UnfurlResponse[UnfurlResourceType.Mention], "type">;

const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
{ url, title, info, color }: Props,
{ avatarUrl, name, lastActive, color }: Props,
ref: React.Ref<HTMLDivElement>
) {
return (
Expand All @@ -26,15 +18,15 @@ const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
<Flex gap={12}>
<Avatar
model={{
avatarUrl: url,
initial: title ? title[0] : "?",
avatarUrl,
initial: name ? name[0] : "?",
color,
}}
size={AvatarSize.XLarge}
/>
<Flex column gap={2} justify="center">
<Title>{title}</Title>
<Info>{info}</Info>
<Title>{name}</Title>
<Info>{lastActive}</Info>
</Flex>
</Flex>
</CardContent>
Expand Down
Loading

0 comments on commit 26f87a1

Please sign in to comment.