feat: Open random document in command menu
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
|||||||
TrashIcon,
|
TrashIcon,
|
||||||
CrossIcon,
|
CrossIcon,
|
||||||
ArchiveIcon,
|
ArchiveIcon,
|
||||||
|
ShuffleIcon,
|
||||||
} from "outline-icons";
|
} from "outline-icons";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { getEventFiles } from "@shared/utils/files";
|
import { getEventFiles } from "@shared/utils/files";
|
||||||
@@ -416,6 +417,24 @@ export const createTemplate = createAction({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const openRandomDocument = createAction({
|
||||||
|
id: "random",
|
||||||
|
section: DocumentSection,
|
||||||
|
name: ({ t }) => t(`Open random document`),
|
||||||
|
icon: <ShuffleIcon />,
|
||||||
|
perform: ({ stores, activeDocumentId }) => {
|
||||||
|
const documentPaths = stores.collections.pathsToDocuments.filter(
|
||||||
|
(path) => path.type === "document" && path.id !== activeDocumentId
|
||||||
|
);
|
||||||
|
const documentPath =
|
||||||
|
documentPaths[Math.round(Math.random() * documentPaths.length)];
|
||||||
|
|
||||||
|
if (documentPath) {
|
||||||
|
history.push(documentPath.url);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export const searchDocumentsForQuery = (searchQuery: string) =>
|
export const searchDocumentsForQuery = (searchQuery: string) =>
|
||||||
createAction({
|
createAction({
|
||||||
id: "search",
|
id: "search",
|
||||||
@@ -566,6 +585,7 @@ export const rootDocumentActions = [
|
|||||||
unsubscribeDocument,
|
unsubscribeDocument,
|
||||||
duplicateDocument,
|
duplicateDocument,
|
||||||
moveDocument,
|
moveDocument,
|
||||||
|
openRandomDocument,
|
||||||
permanentlyDeleteDocument,
|
permanentlyDeleteDocument,
|
||||||
printDocument,
|
printDocument,
|
||||||
pinDocumentToCollection,
|
pinDocumentToCollection,
|
||||||
|
|||||||
@@ -138,7 +138,7 @@
|
|||||||
"natural-sort": "^1.0.0",
|
"natural-sort": "^1.0.0",
|
||||||
"node-fetch": "2.6.7",
|
"node-fetch": "2.6.7",
|
||||||
"nodemailer": "^6.6.1",
|
"nodemailer": "^6.6.1",
|
||||||
"outline-icons": "^1.44.0",
|
"outline-icons": "^1.45.1",
|
||||||
"oy-vey": "^0.11.2",
|
"oy-vey": "^0.11.2",
|
||||||
"passport": "^0.6.0",
|
"passport": "^0.6.0",
|
||||||
"passport-google-oauth2": "^0.2.0",
|
"passport-google-oauth2": "^0.2.0",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"Import document": "Import document",
|
"Import document": "Import document",
|
||||||
"Templatize": "Templatize",
|
"Templatize": "Templatize",
|
||||||
"Create template": "Create template",
|
"Create template": "Create template",
|
||||||
|
"Open random document": "Open random document",
|
||||||
"Search documents for \"{{searchQuery}}\"": "Search documents for \"{{searchQuery}}\"",
|
"Search documents for \"{{searchQuery}}\"": "Search documents for \"{{searchQuery}}\"",
|
||||||
"Move": "Move",
|
"Move": "Move",
|
||||||
"Move {{ documentName }}": "Move {{ documentName }}",
|
"Move {{ documentName }}": "Move {{ documentName }}",
|
||||||
|
|||||||
@@ -11379,10 +11379,10 @@ os-browserify@^0.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27"
|
resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27"
|
||||||
integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=
|
integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=
|
||||||
|
|
||||||
outline-icons@^1.44.0:
|
outline-icons@^1.45.1:
|
||||||
version "1.44.0"
|
version "1.45.1"
|
||||||
resolved "https://registry.yarnpkg.com/outline-icons/-/outline-icons-1.44.0.tgz#ce9fd272f0556db9b05b5615f87c12b16bd18ea0"
|
resolved "https://registry.yarnpkg.com/outline-icons/-/outline-icons-1.45.1.tgz#5da1280057e3922e4db5282718d017ba66ff5dcd"
|
||||||
integrity sha512-nkKGXuGbOgZjPkyVpZZu7CIDrfmt2eER+3RWfE1LU/GqHkuUt0c5JpCsEyhxXAPMUW09q4sDvHjLVge7DUWeYg==
|
integrity sha512-L982CsD573pEZRwMLvwcAP2XSu0HS+ITwuD1vncM6JyLhcGNA1M6IXX8OTW99BouU05gsIO1eV9rYmpBlaOVcg==
|
||||||
|
|
||||||
oy-vey@^0.11.2:
|
oy-vey@^0.11.2:
|
||||||
version "0.11.2"
|
version "0.11.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user