diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx index 68237119d..56c858505 100644 --- a/app/actions/definitions/documents.tsx +++ b/app/actions/definitions/documents.tsx @@ -17,6 +17,7 @@ import { TrashIcon, CrossIcon, ArchiveIcon, + ShuffleIcon, } from "outline-icons"; import * as React from "react"; 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: , + 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) => createAction({ id: "search", @@ -566,6 +585,7 @@ export const rootDocumentActions = [ unsubscribeDocument, duplicateDocument, moveDocument, + openRandomDocument, permanentlyDeleteDocument, printDocument, pinDocumentToCollection, diff --git a/package.json b/package.json index 7367fb9a2..2dc785ca6 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "natural-sort": "^1.0.0", "node-fetch": "2.6.7", "nodemailer": "^6.6.1", - "outline-icons": "^1.44.0", + "outline-icons": "^1.45.1", "oy-vey": "^0.11.2", "passport": "^0.6.0", "passport-google-oauth2": "^0.2.0", diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index e0437b7af..b24ff167e 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -31,6 +31,7 @@ "Import document": "Import document", "Templatize": "Templatize", "Create template": "Create template", + "Open random document": "Open random document", "Search documents for \"{{searchQuery}}\"": "Search documents for \"{{searchQuery}}\"", "Move": "Move", "Move {{ documentName }}": "Move {{ documentName }}", diff --git a/yarn.lock b/yarn.lock index 93879b0cc..01b6b4d64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11379,10 +11379,10 @@ os-browserify@^0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= -outline-icons@^1.44.0: - version "1.44.0" - resolved "https://registry.yarnpkg.com/outline-icons/-/outline-icons-1.44.0.tgz#ce9fd272f0556db9b05b5615f87c12b16bd18ea0" - integrity sha512-nkKGXuGbOgZjPkyVpZZu7CIDrfmt2eER+3RWfE1LU/GqHkuUt0c5JpCsEyhxXAPMUW09q4sDvHjLVge7DUWeYg== +outline-icons@^1.45.1: + version "1.45.1" + resolved "https://registry.yarnpkg.com/outline-icons/-/outline-icons-1.45.1.tgz#5da1280057e3922e4db5282718d017ba66ff5dcd" + integrity sha512-L982CsD573pEZRwMLvwcAP2XSu0HS+ITwuD1vncM6JyLhcGNA1M6IXX8OTW99BouU05gsIO1eV9rYmpBlaOVcg== oy-vey@^0.11.2: version "0.11.2"