diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8984265c1a..fad0be731a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: bundle-size: needs: [build, types, changes] - if: ${{ needs.changes.outputs.app == 'true' }} + if: ${{ needs.changes.outputs.app == 'true' && github.repository == 'outline/outline' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/app/components/Modal.tsx b/app/components/Modal.tsx index 45e3105ee1..35cf5dc995 100644 --- a/app/components/Modal.tsx +++ b/app/components/Modal.tsx @@ -114,6 +114,8 @@ const Modal: React.FC = ({ ev.stopPropagation()} + // maxHeight needed for proper overflow behavior in Safari + style={{ maxHeight: "65vh" }} column reverse > @@ -259,6 +261,7 @@ const Small = styled.div` width: 75vw; min-width: 350px; max-width: 450px; + max-height: 65vh; z-index: ${depths.modal}; display: flex; justify-content: center; diff --git a/app/components/Sidebar/components/DocumentLink.tsx b/app/components/Sidebar/components/DocumentLink.tsx index 122c87ab53..d1050bd34c 100644 --- a/app/components/Sidebar/components/DocumentLink.tsx +++ b/app/components/Sidebar/components/DocumentLink.tsx @@ -148,7 +148,12 @@ function InnerDocumentLink( const color = document?.color || node.color; // Draggable - const [{ isDragging }, drag] = useDragDocument(node, depth, document); + const [{ isDragging }, drag] = useDragDocument( + node, + depth, + document, + isEditing + ); // Drop to re-parent const parentRef = React.useRef(null); @@ -270,6 +275,8 @@ function InnerDocumentLink(
{ location?: Location; strict?: boolean; to: LocationDescriptor; + component?: React.ComponentType; onBeforeClick?: () => void; } @@ -146,17 +147,22 @@ const NavLink = ({ setPreActive(undefined); }, [currentLocation]); + const handleKeyDown = React.useCallback( + (event: React.KeyboardEvent) => { + if (["Enter", " "].includes(event.key)) { + navigateTo(); + event.currentTarget?.blur(); + } + }, + [navigateTo] + ); + return ( { - if (["Enter", " "].includes(event.key)) { - navigateTo(); - event.currentTarget?.blur(); - } - }} + onKeyDown={handleKeyDown} aria-current={(isActive && ariaCurrent) || undefined} className={className} style={style} diff --git a/app/components/Sidebar/hooks/useDragAndDrop.tsx b/app/components/Sidebar/hooks/useDragAndDrop.tsx index 4d1867c7ca..58ade6c59c 100644 --- a/app/components/Sidebar/hooks/useDragAndDrop.tsx +++ b/app/components/Sidebar/hooks/useDragAndDrop.tsx @@ -166,11 +166,13 @@ export function useDropToReorderStar(getIndex?: () => string) { * @param node The NavigationNode model to drag. * @param depth The depth of the node in the sidebar. * @param document The related Document model. + * @param isEditing Whether the sidebar item is currently being edited. */ export function useDragDocument( node: NavigationNode, depth: number, - document?: Document + document?: Document, + isEditing?: boolean ) { const icon = document?.icon || node.icon || node.emoji; const color = document?.color || node.color; @@ -188,7 +190,7 @@ export function useDragDocument( icon: icon ? : undefined, collectionId: document?.collectionId || "", } as DragObject), - canDrag: () => !!document?.isActive, + canDrag: () => !!document?.isActive && !isEditing, collect: (monitor) => ({ isDragging: monitor.isDragging(), }), diff --git a/app/components/Table.tsx b/app/components/Table.tsx index d1b9c25e74..b92d3effa1 100644 --- a/app/components/Table.tsx +++ b/app/components/Table.tsx @@ -335,6 +335,7 @@ const TR = styled.div<{ $columns: string }>` grid-template-columns: ${({ $columns }) => `${$columns}`}; align-items: center; border-bottom: 1px solid ${s("divider")}; + overflow: hidden; &:last-child { border-bottom: 0; @@ -357,7 +358,8 @@ const TD = styled.span` padding: 10px 6px; font-size: 14px; text-wrap: wrap; - word-break: break-word; + overflow: hidden; + text-overflow: ellipsis; &:first-child { font-size: 15px; diff --git a/app/editor/components/PasteMenu.tsx b/app/editor/components/PasteMenu.tsx index a0015a7163..9042f50a4f 100644 --- a/app/editor/components/PasteMenu.tsx +++ b/app/editor/components/PasteMenu.tsx @@ -26,7 +26,7 @@ type Props = Omit< export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => { const { t } = useTranslation(); const { integrations } = useStores(); - const user = useCurrentUser(); + const user = useCurrentUser({ rejectOnEmpty: false }); let mentionType: MentionType | undefined; const url = pastedText ? new URL(pastedText) : undefined; @@ -70,7 +70,7 @@ export const PasteMenu = observer(({ pastedText, embeds, ...props }: Props) => { label: pastedText, href: pastedText, modelId: v4(), - actorId: user.id, + actorId: user?.id, }, appendSpace: true, }, diff --git a/app/editor/components/SelectionToolbar.tsx b/app/editor/components/SelectionToolbar.tsx index a263317ba5..bea7956d6b 100644 --- a/app/editor/components/SelectionToolbar.tsx +++ b/app/editor/components/SelectionToolbar.tsx @@ -174,12 +174,12 @@ export default function SelectionToolbar(props: Props) { const { isTemplate, rtl, canComment, canUpdate, ...rest } = props; const { state } = view; const { selection } = state; - const isDividerSelection = isNodeActive(state.schema.nodes.hr)(state); if ((readOnly && !canComment) || isDragging) { return null; } + const isDividerSelection = isNodeActive(state.schema.nodes.hr)(state); const colIndex = getColumnIndex(state); const rowIndex = getRowIndex(state); const isTableSelection = colIndex !== undefined && rowIndex !== undefined; diff --git a/app/hooks/useSettingsConfig.ts b/app/hooks/useSettingsConfig.ts index 89935f8c80..e564103dc7 100644 --- a/app/hooks/useSettingsConfig.ts +++ b/app/hooks/useSettingsConfig.ts @@ -8,7 +8,6 @@ import { GlobeIcon, TeamIcon, BeakerIcon, - BuildingBlocksIcon, SettingsIcon, ExportIcon, ImportIcon, @@ -40,7 +39,6 @@ const Notifications = lazy(() => import("~/scenes/Settings/Notifications")); const Preferences = lazy(() => import("~/scenes/Settings/Preferences")); const Profile = lazy(() => import("~/scenes/Settings/Profile")); const Security = lazy(() => import("~/scenes/Settings/Security")); -const SelfHosted = lazy(() => import("~/scenes/Settings/SelfHosted")); const Shares = lazy(() => import("~/scenes/Settings/Shares")); const Templates = lazy(() => import("~/scenes/Settings/Templates")); const Zapier = lazy(() => import("~/scenes/Settings/Zapier")); @@ -177,14 +175,6 @@ const useSettingsConfig = () => { icon: ExportIcon, }, // Integrations - { - name: t("Self Hosted"), - path: integrationSettingsPath("self-hosted"), - component: SelfHosted, - enabled: can.update && !isCloudHosted, - group: t("Integrations"), - icon: BuildingBlocksIcon, - }, { name: "Zapier", path: integrationSettingsPath("zapier"), diff --git a/app/scenes/Invite.tsx b/app/scenes/Invite.tsx index 8cb13d9c1b..4c22b2824d 100644 --- a/app/scenes/Invite.tsx +++ b/app/scenes/Invite.tsx @@ -209,7 +209,9 @@ function Invite({ onSubmit }: Props) { placeholder={`name@${predictedDomain}`} value={invite.email} required={index === 0} + autoComplete="off" autoFocus + data-1p-ignore flex /> .getoutline.com diff --git a/app/scenes/Login/urls.ts b/app/scenes/Login/urls.ts index fe5612453e..81a3fd92e1 100644 --- a/app/scenes/Login/urls.ts +++ b/app/scenes/Login/urls.ts @@ -3,6 +3,15 @@ import { parseDomain } from "@shared/utils/domains"; import env from "~/env"; import Desktop from "~/utils/Desktop"; +function validateAndEncodeSubdomain(subdomain: string): string { + const encodedSubdomain = encodeURIComponent(subdomain); + const urlPattern = /^[a-z\d-]{1,63}$/; + if (!urlPattern.test(encodedSubdomain)) { + throw new Error("Invalid subdomain"); + } + return `https://${encodedSubdomain}.getoutline.com`; +} + /** * If we're on a custom domain or a subdomain then the auth must point to the * apex (env.URL) for authentication so that the state cookie can be set and read. @@ -36,7 +45,7 @@ export async function navigateToSubdomain(subdomain: string) { .toLowerCase() .trim() .replace(/^https?:\/\//, ""); - const host = `https://${normalizedSubdomain}.getoutline.com`; + const host = validateAndEncodeSubdomain(normalizedSubdomain); await Desktop.bridge?.addCustomHost(host); window.location.href = host; } diff --git a/app/scenes/Settings/SelfHosted.tsx b/app/scenes/Settings/SelfHosted.tsx deleted file mode 100644 index bc836d218d..0000000000 --- a/app/scenes/Settings/SelfHosted.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import find from "lodash/find"; -import { observer } from "mobx-react"; -import { BuildingBlocksIcon } from "outline-icons"; -import * as React from "react"; -import { useForm } from "react-hook-form"; -import { useTranslation } from "react-i18next"; -import { toast } from "sonner"; -import { IntegrationService, IntegrationType } from "@shared/types"; -import Integration from "~/models/Integration"; -import Button from "~/components/Button"; -import Heading from "~/components/Heading"; -import Input from "~/components/Input"; -import Scene from "~/components/Scene"; -import useStores from "~/hooks/useStores"; -import SettingRow from "./components/SettingRow"; - -type FormData = { - drawIoUrl: string; - gristUrl: string; -}; - -function SelfHosted() { - const { integrations } = useStores(); - const { t } = useTranslation(); - - const integrationDiagrams = find(integrations.orderedData, { - type: IntegrationType.Embed, - service: IntegrationService.Diagrams, - }) as Integration | undefined; - - const integrationGrist = find(integrations.orderedData, { - type: IntegrationType.Embed, - service: IntegrationService.Grist, - }) as Integration | undefined; - - const { - register, - reset, - handleSubmit: formHandleSubmit, - formState, - } = useForm({ - mode: "all", - defaultValues: { - drawIoUrl: integrationDiagrams?.settings.url, - gristUrl: integrationGrist?.settings.url, - }, - }); - - React.useEffect(() => { - void integrations.fetchPage({ - type: IntegrationType.Embed, - }); - }, [integrations]); - - React.useEffect(() => { - reset({ - drawIoUrl: integrationDiagrams?.settings.url, - gristUrl: integrationGrist?.settings.url, - }); - }, [integrationDiagrams, integrationGrist, reset]); - - const handleSubmit = React.useCallback( - async (data: FormData) => { - try { - if (data.drawIoUrl) { - await integrations.save({ - id: integrationDiagrams?.id, - type: IntegrationType.Embed, - service: IntegrationService.Diagrams, - settings: { - url: data.drawIoUrl, - }, - }); - } else { - await integrationDiagrams?.delete(); - } - - if (data.gristUrl) { - await integrations.save({ - id: integrationGrist?.id, - type: IntegrationType.Embed, - service: IntegrationService.Grist, - settings: { - url: data.gristUrl, - }, - }); - } else { - await integrationGrist?.delete(); - } - - toast.success(t("Settings saved")); - } catch (err) { - toast.error(err.message); - } - }, - [integrations, integrationDiagrams, integrationGrist, t] - ); - - return ( - }> - {t("Self Hosted")} - -
- - - - - - - - - -
-
- ); -} - -export default observer(SelfHosted); diff --git a/app/scenes/Settings/components/ImageUpload.tsx b/app/scenes/Settings/components/ImageUpload.tsx index c703ae3c91..d5e1db53ea 100644 --- a/app/scenes/Settings/components/ImageUpload.tsx +++ b/app/scenes/Settings/components/ImageUpload.tsx @@ -3,7 +3,7 @@ import { observer } from "mobx-react"; import * as React from "react"; import { useState, useRef } from "react"; import AvatarEditor from "react-avatar-editor"; -import Dropzone from "react-dropzone"; +import { useDropzone } from "react-dropzone"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; import { s } from "@shared/styles"; @@ -12,7 +12,6 @@ import { AttachmentValidation } from "@shared/validations"; import ButtonLarge from "~/components/ButtonLarge"; import Flex from "~/components/Flex"; import LoadingIndicator from "~/components/LoadingIndicator"; -import Modal from "~/components/Modal"; import useStores from "~/hooks/useStores"; import { compressImage } from "~/utils/compressImage"; import { uploadFile, dataUrlToBlob } from "~/utils/files"; @@ -28,81 +27,138 @@ const ImageUpload: React.FC = ({ onSuccess, onError, submitText, - borderRadius = 150, + borderRadius, children, }) => { - const { ui } = useStores(); + const { dialogs } = useStores(); const { t } = useTranslation(); - submitText || t("Crop image"); const [isUploading, setIsUploading] = useState(false); const [isCropping, setIsCropping] = useState(false); - const [zoom, setZoom] = useState(1); - const [file, setFile] = useState(null); - const avatarEditorRef = useRef(null); + const uploadImage = React.useCallback( + async (blob: Blob, file: File) => { + try { + const compressed = await compressImage(blob, { + maxHeight: 512, + maxWidth: 512, + }); + const attachment = await uploadFile(compressed, { + name: file.name, + preset: AttachmentPreset.Avatar, + }); + void onSuccess(attachment.url); + } catch (err) { + onError(err.message); + } finally { + setIsUploading(false); + setIsCropping(false); + dialogs.closeAllModals(); + } + }, + [dialogs, onSuccess, onError] + ); - const onDropAccepted = async (files: File[]) => { - setIsCropping(true); - setFile(files[0]); - }; + const handleUpload = React.useCallback( + (blob: Blob, file: File) => { + setIsUploading(true); + // allow the UI to update before converting the canvas to a Blob + // for large images this can cause the page rendering to hang. + setTimeout(() => uploadImage(blob, file), 0); + }, + [uploadImage] + ); - const handleCrop = () => { - setIsUploading(true); - // allow the UI to update before converting the canvas to a Blob - // for large images this can cause the page rendering to hang. - setTimeout(uploadImage, 0); - }; - - const uploadImage = async () => { - const canvas = avatarEditorRef.current?.getImage(); - invariant(canvas, "canvas is not defined"); - const imageBlob = dataUrlToBlob(canvas.toDataURL()); - - try { - const compressed = await compressImage(imageBlob, { - maxHeight: 512, - maxWidth: 512, - }); - const attachment = await uploadFile(compressed, { - name: file!.name, - preset: AttachmentPreset.Avatar, - }); - void onSuccess(attachment.url); - } catch (err) { - onError(err.message); - } finally { - setIsUploading(false); - setIsCropping(false); - } - }; - - const handleClose = () => { + const handleClose = React.useCallback(() => { setIsUploading(false); setIsCropping(false); - }; + }, []); - const handleZoom = (event: React.ChangeEvent) => { - const target = event.target; + const onDropAccepted = React.useCallback( + async (files: File[]) => { + setIsCropping(true); + dialogs.openModal({ + title: "", + content: ( + + ), + onClose: handleClose, + }); + }, + [ + t, + dialogs, + handleUpload, + handleClose, + isUploading, + borderRadius, + submitText, + ] + ); - if (target instanceof HTMLInputElement) { - setZoom(parseFloat(target.value)); - } - }; + const { getRootProps, getInputProps } = useDropzone({ + accept: AttachmentValidation.avatarContentTypes.join(", "), + onDropAccepted, + }); - const renderCropping = () => ( -  } - isOpen - > + if (isCropping) { + return null; // onDropAccepted would have opened a modal for cropping the image. + } + + return ( +
+ + {children} +
+ ); +}; + +type AvatarEditorDialogProps = { + file: File; + onUpload: (blob: Blob, file: File) => void; + isUploading: boolean; + borderRadius: number; + submitText: string; +}; + +const AvatarEditorDialog: React.FC = observer( + ({ file, onUpload, isUploading, borderRadius, submitText }) => { + const { ui } = useStores(); + const { t } = useTranslation(); + const [zoom, setZoom] = useState(1); + const avatarEditorRef = useRef(null); + + const handleUpload = React.useCallback(() => { + const canvas = avatarEditorRef.current?.getImage(); + invariant(canvas, "canvas is not defined"); + const blob = dataUrlToBlob(canvas.toDataURL()); + onUpload(blob, file); + }, [file, onUpload]); + + const handleZoom = React.useCallback( + (event: React.ChangeEvent) => { + const target = event.target; + + if (target instanceof HTMLInputElement) { + setZoom(parseFloat(target.value)); + } + }, + [] + ); + + return ( {isUploading && } = ({ onChange={handleZoom} />
- + {isUploading ? `${t(`Uploading`)}…` : submitText}
-
- ); - - if (isCropping && file) { - return renderCropping(); + ); } - - return ( - - {({ getRootProps, getInputProps }) => ( -
- - {children} -
- )} -
- ); -}; +); const AvatarEditorContainer = styled(Flex)` margin-bottom: 30px; diff --git a/app/scenes/Settings/components/MembersTable.tsx b/app/scenes/Settings/components/MembersTable.tsx index 962eb8ca68..690360c430 100644 --- a/app/scenes/Settings/components/MembersTable.tsx +++ b/app/scenes/Settings/components/MembersTable.tsx @@ -2,6 +2,7 @@ import compact from "lodash/compact"; import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; +import Text from "@shared/components/Text"; import User from "~/models/User"; import { Avatar, AvatarSize } from "~/components/Avatar"; import Badge from "~/components/Badge"; @@ -14,6 +15,7 @@ import { import { type Column as TableColumn } from "~/components/Table"; import Time from "~/components/Time"; import useCurrentUser from "~/hooks/useCurrentUser"; +import useMobile from "~/hooks/useMobile"; import UserMenu from "~/menus/UserMenu"; import { FILTER_HEIGHT } from "./StickyFilters"; @@ -27,6 +29,7 @@ type Props = Omit, "columns" | "rowHeight"> & { export function MembersTable({ canManage, ...rest }: Props) { const { t } = useTranslation(); const currentUser = useCurrentUser(); + const isMobile = useMobile(); const columns = React.useMemo[]>( () => @@ -38,13 +41,20 @@ export function MembersTable({ canManage, ...rest }: Props) { accessor: (user) => user.name, component: (user) => ( - {user.name}{" "} - {currentUser.id === user.id && `(${t("You")})`} + {" "} + + + {user.name} {currentUser.id === user.id && `(${t("You")})`} + + {isMobile && canManage && ( + {user.email} + )} + ), width: "4fr", }, - canManage + canManage && !isMobile ? { type: "data", id: "email", @@ -54,17 +64,19 @@ export function MembersTable({ canManage, ...rest }: Props) { width: "4fr", } : undefined, - { - type: "data", - id: "lastActiveAt", - header: t("Last active"), - accessor: (user) => user.lastActiveAt, - component: (user) => - user.lastActiveAt ? ( -