Skip to content

Commit

Permalink
fix: getFileStream
Browse files Browse the repository at this point in the history
  • Loading branch information
tommoor committed May 19, 2024
2 parents 26f87a1 + cd4f3f9 commit 0553e12
Show file tree
Hide file tree
Showing 242 changed files with 7,168 additions and 3,665 deletions.
20 changes: 19 additions & 1 deletion app/actions/definitions/collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
EditIcon,
PadlockIcon,
PlusIcon,
SearchIcon,
StarredIcon,
TrashIcon,
UnstarredIcon,
Expand All @@ -15,9 +16,13 @@ import { CollectionEdit } from "~/components/Collection/CollectionEdit";
import { CollectionNew } from "~/components/Collection/CollectionNew";
import CollectionDeleteDialog from "~/components/CollectionDeleteDialog";
import DynamicCollectionIcon from "~/components/Icons/CollectionIcon";
import { getHeaderExpandedKey } from "~/components/Sidebar/components/Header";
import { createAction } from "~/actions";
import { CollectionSection } from "~/actions/sections";
import { setPersistedState } from "~/hooks/usePersistedState";
import { Feature, FeatureFlags } from "~/utils/FeatureFlags";
import history from "~/utils/history";
import { searchPath } from "~/utils/routeHelpers";

const ColorCollectionIcon = ({ collection }: { collection: Collection }) => (
<DynamicCollectionIcon collection={collection} />
Expand Down Expand Up @@ -95,7 +100,8 @@ export const editCollectionPermissions = createAction({
icon: <PadlockIcon />,
visible: ({ stores, activeCollectionId }) =>
!!activeCollectionId &&
stores.policies.abilities(activeCollectionId).update,
stores.policies.abilities(activeCollectionId).update &&
!FeatureFlags.isEnabled(Feature.newCollectionSharing),
perform: ({ t, activeCollectionId }) => {
if (!activeCollectionId) {
return;
Expand All @@ -109,6 +115,17 @@ export const editCollectionPermissions = createAction({
},
});

export const searchInCollection = createAction({
name: ({ t }) => t("Search in collection"),
analyticsName: "Search collection",
section: CollectionSection,
icon: <SearchIcon />,
visible: ({ activeCollectionId }) => !!activeCollectionId,
perform: ({ activeCollectionId }) => {
history.push(searchPath(undefined, { collectionId: activeCollectionId }));
},
});

export const starCollection = createAction({
name: ({ t }) => t("Star"),
analyticsName: "Star collection",
Expand All @@ -132,6 +149,7 @@ export const starCollection = createAction({

const collection = stores.collections.get(activeCollectionId);
await collection?.star();
setPersistedState(getHeaderExpandedKey("starred"), true);
},
});

Expand Down
40 changes: 36 additions & 4 deletions app/actions/definitions/developer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import copy from "copy-to-clipboard";
import { CopyIcon, ToolsIcon, TrashIcon, UserIcon } from "outline-icons";
import {
BeakerIcon,
CopyIcon,
ToolsIcon,
TrashIcon,
UserIcon,
} from "outline-icons";
import * as React from "react";
import { toast } from "sonner";
import { createAction } from "~/actions";
import { DeveloperSection } from "~/actions/sections";
import env from "~/env";
import { client } from "~/utils/ApiClient";
import { Feature, FeatureFlags } from "~/utils/FeatureFlags";
import Logger from "~/utils/Logger";
import { deleteAllDatabases } from "~/utils/developer";
import history from "~/utils/history";
Expand Down Expand Up @@ -104,7 +111,7 @@ export const createToast = createAction({
name: "Create toast",
section: DeveloperSection,
visible: () => env.ENVIRONMENT === "development",
perform: async () => {
perform: () => {
toast.message("Hello world", {
duration: 30000,
});
Expand All @@ -115,7 +122,7 @@ export const toggleDebugLogging = createAction({
name: ({ t }) => t("Toggle debug logging"),
icon: <ToolsIcon />,
section: DeveloperSection,
perform: async ({ t }) => {
perform: ({ t }) => {
Logger.debugLoggingEnabled = !Logger.debugLoggingEnabled;
toast.message(
Logger.debugLoggingEnabled
Expand All @@ -125,6 +132,30 @@ export const toggleDebugLogging = createAction({
},
});

export const toggleFeatureFlag = createAction({
name: "Toggle feature flag",
icon: <BeakerIcon />,
section: DeveloperSection,
visible: () => env.ENVIRONMENT === "development",
children: Object.values(Feature).map((flag) =>
createAction({
id: `flag-${flag}`,
name: flag,
selected: () => FeatureFlags.isEnabled(flag),
section: DeveloperSection,
perform: () => {
if (FeatureFlags.isEnabled(flag)) {
FeatureFlags.disable(flag);
toast.success(`Disabled feature flag: ${flag}`);
} else {
FeatureFlags.enable(flag);
toast.success(`Enabled feature flag: ${flag}`);
}
},
})
),
});

export const developer = createAction({
name: ({ t }) => t("Development"),
keywords: "debug",
Expand All @@ -133,10 +164,11 @@ export const developer = createAction({
section: DeveloperSection,
children: [
copyId,
clearIndexedDB,
toggleDebugLogging,
toggleFeatureFlag,
createToast,
createTestUsers,
clearIndexedDB,
],
});

Expand Down
66 changes: 60 additions & 6 deletions app/actions/definitions/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ import DocumentDelete from "~/scenes/DocumentDelete";
import DocumentMove from "~/scenes/DocumentMove";
import DocumentPermanentDelete from "~/scenes/DocumentPermanentDelete";
import DocumentPublish from "~/scenes/DocumentPublish";
import DeleteDocumentsInTrash from "~/scenes/Trash/components/DeleteDocumentsInTrash";
import DocumentTemplatizeDialog from "~/components/DocumentTemplatizeDialog";
import DuplicateDialog from "~/components/DuplicateDialog";
import SharePopover from "~/components/Sharing";
import SharePopover from "~/components/Sharing/Document";
import { getHeaderExpandedKey } from "~/components/Sidebar/components/Header";
import { createAction } from "~/actions";
import { DocumentSection } from "~/actions/sections";
import { DocumentSection, TrashSection } from "~/actions/sections";
import env from "~/env";
import { setPersistedState } from "~/hooks/usePersistedState";
import history from "~/utils/history";
import {
documentInsightsPath,
Expand All @@ -52,6 +55,7 @@ import {
searchPath,
documentPath,
urlify,
trashPath,
} from "~/utils/routeHelpers";

export const openDocument = createAction({
Expand Down Expand Up @@ -88,8 +92,18 @@ export const createDocument = createAction({
section: DocumentSection,
icon: <NewDocumentIcon />,
keywords: "create",
visible: ({ currentTeamId, stores }) =>
!!currentTeamId && stores.policies.abilities(currentTeamId).createDocument,
visible: ({ currentTeamId, activeCollectionId, stores }) => {
if (
activeCollectionId &&
!stores.policies.abilities(activeCollectionId).createDocument
) {
return false;
}

return (
!!currentTeamId && stores.policies.abilities(currentTeamId).createDocument
);
},
perform: ({ activeCollectionId, inStarredSection }) =>
history.push(newDocumentPath(activeCollectionId), {
starred: inStarredSection,
Expand Down Expand Up @@ -160,6 +174,7 @@ export const starDocument = createAction({

const document = stores.documents.get(activeDocumentId);
await document?.star();
setPersistedState(getHeaderExpandedKey("starred"), true);
},
});

Expand Down Expand Up @@ -591,14 +606,31 @@ export const pinDocument = createAction({
children: [pinDocumentToCollection, pinDocumentToHome],
});

export const searchInDocument = createAction({
name: ({ t }) => t("Search in document"),
analyticsName: "Search document",
section: DocumentSection,
icon: <SearchIcon />,
visible: ({ stores, activeDocumentId }) => {
if (!activeDocumentId) {
return false;
}
const document = stores.documents.get(activeDocumentId);
return !!document?.isActive;
},
perform: ({ activeDocumentId }) => {
history.push(searchPath(undefined, { documentId: activeDocumentId }));
},
});

export const printDocument = createAction({
name: ({ t, isContextMenu }) =>
isContextMenu ? t("Print") : t("Print document"),
analyticsName: "Print document",
section: DocumentSection,
icon: <PrintIcon />,
visible: ({ activeDocumentId }) => !!(activeDocumentId && window.print),
perform: async () => {
perform: () => {
queueMicrotask(window.print);
},
});
Expand Down Expand Up @@ -660,7 +692,7 @@ export const createTemplate = createAction({
!!activeCollectionId &&
stores.policies.abilities(activeCollectionId).update &&
!document?.isTemplate &&
!document?.isDeleted
!!document?.isActive
);
},
perform: ({ activeDocumentId, stores, t, event }) => {
Expand Down Expand Up @@ -828,6 +860,27 @@ export const permanentlyDeleteDocument = createAction({
},
});

export const permanentlyDeleteDocumentsInTrash = createAction({
name: ({ t }) => t("Empty trash"),
analyticsName: "Empty trash",
section: TrashSection,
icon: <TrashIcon />,
dangerous: true,
visible: ({ stores }) =>
stores.documents.deleted.length > 0 && !!stores.auth.user?.isAdmin,
perform: ({ stores, t, location }) => {
stores.dialogs.openModal({
title: t("Permanently delete documents in trash"),
content: (
<DeleteDocumentsInTrash
onSubmit={stores.dialogs.closeAllModals}
shouldRedirect={location.pathname === trashPath()}
/>
),
});
},
});

export const openDocumentComments = createAction({
name: ({ t }) => t("Comments"),
analyticsName: "Open comments",
Expand Down Expand Up @@ -952,6 +1005,7 @@ export const rootDocumentActions = [
moveDocument,
openRandomDocument,
permanentlyDeleteDocument,
permanentlyDeleteDocumentsInTrash,
printDocument,
pinDocumentToCollection,
pinDocumentToHome,
Expand Down
10 changes: 10 additions & 0 deletions app/actions/definitions/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export const navigateToAccountPreferences = createAction({
perform: () => history.push(settingsPath("preferences")),
});

export const openDocumentation = createAction({
name: ({ t }) => t("Documentation"),
analyticsName: "Open documentation",
section: NavigationSection,
iconInContextMenu: false,
icon: <OpenIcon />,
perform: () => window.open(UrlHelper.guide),
});

export const openAPIDocumentation = createAction({
name: ({ t }) => t("API documentation"),
analyticsName: "Open API documentation",
Expand Down Expand Up @@ -218,6 +227,7 @@ export const rootNavigationActions = [
navigateToArchive,
navigateToTrash,
downloadApp,
openDocumentation,
openAPIDocumentation,
openFeedbackUrl,
openBugReportUrl,
Expand Down
24 changes: 22 additions & 2 deletions app/actions/definitions/teams.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { PlusIcon } from "outline-icons";
import { ArrowIcon, PlusIcon } from "outline-icons";
import * as React from "react";
import styled from "styled-components";
import { stringToColor } from "@shared/utils/color";
import RootStore from "~/stores/RootStore";
import { LoginDialog } from "~/scenes/Login/components/LoginDialog";
import TeamNew from "~/scenes/TeamNew";
import TeamLogo from "~/components/TeamLogo";
import { createAction } from "~/actions";
import { ActionContext } from "~/types";
import Desktop from "~/utils/Desktop";
import { TeamSection } from "../sections";

export const createTeamsList = ({ stores }: { stores: RootStore }) =>
Expand Down Expand Up @@ -66,9 +68,27 @@ export const createTeam = createAction({
},
});

export const desktopLoginTeam = createAction({
name: ({ t }) => t("Login to workspace"),
analyticsName: "Login to workspace",
keywords: "change switch workspace organization team",
section: TeamSection,
icon: <ArrowIcon />,
visible: () => Desktop.isElectron(),
perform: ({ t, event, stores }) => {
event?.preventDefault();
event?.stopPropagation();

stores.dialogs.openModal({
title: t("Login to workspace"),
content: <LoginDialog />,
});
},
});

const StyledTeamLogo = styled(TeamLogo)`
border-radius: 2px;
border: 0;
`;

export const rootTeamActions = [switchTeam, createTeam];
export const rootTeamActions = [switchTeam, createTeam, desktopLoginTeam];
43 changes: 42 additions & 1 deletion app/actions/definitions/users.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { PlusIcon } from "outline-icons";
import * as React from "react";
import { UserRole } from "@shared/types";
import { UserRoleHelper } from "@shared/utils/UserRoleHelper";
import stores from "~/stores";
import User from "~/models/User";
import Invite from "~/scenes/Invite";
import { UserDeleteDialog } from "~/components/UserDialogs";
import {
UserChangeRoleDialog,
UserDeleteDialog,
} from "~/components/UserDialogs";
import { createAction } from "~/actions";
import { UserSection } from "~/actions/sections";

Expand All @@ -22,6 +28,41 @@ export const inviteUser = createAction({
},
});

export const updateUserRoleActionFactory = (user: User, role: UserRole) =>
createAction({
name: ({ t }) =>
UserRoleHelper.isRoleHigher(role, user!.role)
? `${t("Promote to {{ role }}", {
role: UserRoleHelper.displayName(role, t),
})}…`
: `${t("Demote to {{ role }}", {
role: UserRoleHelper.displayName(role, t),
})}…`,
analyticsName: "Update user role",
section: UserSection,
visible: ({ stores }) => {
const can = stores.policies.abilities(user.id);

return UserRoleHelper.isRoleHigher(role, user.role)
? can.promote
: UserRoleHelper.isRoleLower(role, user.role)
? can.demote
: false;
},
perform: ({ t }) => {
stores.dialogs.openModal({
title: t("Update role"),
content: (
<UserChangeRoleDialog
user={user}
role={role}
onSubmit={stores.dialogs.closeAllModals}
/>
),
});
},
});

export const deleteUserActionFactory = (userId: string) =>
createAction({
name: ({ t }) => `${t("Delete user")}…`,
Expand Down

0 comments on commit 0553e12

Please sign in to comment.