diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index cee261c4..19efbc83 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Your tasks' durations will now be rendered with the due date. - You can now set a task duration when creating a new task. - Project icons in the task creation modal will now show that project's color. +- You can now select whether to include a link to the current page in the task creation modal. ### 🔁 Changes diff --git a/docs/docs/translation-status.json b/docs/docs/translation-status.json index 4ff6066c..5befd300 100644 --- a/docs/docs/translation-status.json +++ b/docs/docs/translation-status.json @@ -2,7 +2,7 @@ { "name": "English", "code": "en", - "completed": 157, + "completed": 163, "missing": 0, "percent": 100 }, @@ -10,7 +10,7 @@ "name": "Nederlands", "code": "nl", "completed": 148, - "missing": 9, - "percent": 94 + "missing": 15, + "percent": 91 } ] \ No newline at end of file diff --git a/plugin/src/commands/addTask.ts b/plugin/src/commands/addTask.ts index fb6a0984..67d56b07 100644 --- a/plugin/src/commands/addTask.ts +++ b/plugin/src/commands/addTask.ts @@ -18,7 +18,7 @@ export const addTaskWithPageInContent: MakeCommand = ( return { id: "add-task-page-content", name: i18n.addTaskPageContent, - callback: makeCallback(plugin, { appendLinkToContent: true }), + callback: makeCallback(plugin, { appendLinkTo: "content" }), }; }; @@ -29,7 +29,7 @@ export const addTaskWithPageInDescription: MakeCommand = ( return { id: "add-task-page-description", name: i18n.addTaskPageDescription, - callback: makeCallback(plugin, { appendLinkToDescription: true }), + callback: makeCallback(plugin, { appendLinkTo: "description" }), }; }; @@ -39,8 +39,6 @@ const makeCallback = (plugin: TodoistPlugin, opts?: Partial initialContent: grabSelection(plugin), fileContext: getFileContext(plugin), options: { - appendLinkToContent: false, - appendLinkToDescription: false, ...(opts ?? {}), }, }); diff --git a/plugin/src/i18n/langs/en.ts b/plugin/src/i18n/langs/en.ts index 72f717ea..17ec456e 100644 --- a/plugin/src/i18n/langs/en.ts +++ b/plugin/src/i18n/langs/en.ts @@ -143,6 +143,13 @@ export const en: Translations = { placeholder: "Type a project name", }, }, + optionsSelector: { + buttonLabel: "Set options", + optionsLabel: "Task options", + addLinkToContent: "Add link to content", + addLinkToDescription: "Add link to description", + doNotAddLink: "Do not add link", + }, }, onboardingModal: { failureNoticeMessage: "Failed to save API token", diff --git a/plugin/src/i18n/translation.ts b/plugin/src/i18n/translation.ts index ca4e2b9e..ae046fee 100644 --- a/plugin/src/i18n/translation.ts +++ b/plugin/src/i18n/translation.ts @@ -127,6 +127,13 @@ export type Translations = { placeholder: string; }; }; + optionsSelector: { + buttonLabel: string; + optionsLabel: string; + addLinkToContent: string; + addLinkToDescription: string; + doNotAddLink: string; + }; }; onboardingModal: { failureNoticeMessage: string; diff --git a/plugin/src/ui/createTaskModal/DueDateSelector.tsx b/plugin/src/ui/createTaskModal/DueDateSelector.tsx index d6aba436..fd794adb 100644 --- a/plugin/src/ui/createTaskModal/DueDateSelector.tsx +++ b/plugin/src/ui/createTaskModal/DueDateSelector.tsx @@ -104,7 +104,7 @@ export const DueDateSelector: React.FC = ({ selected, setSelected }) => { diff --git a/plugin/src/ui/createTaskModal/LabelSelector.tsx b/plugin/src/ui/createTaskModal/LabelSelector.tsx index a20e9691..5d7aa867 100644 --- a/plugin/src/ui/createTaskModal/LabelSelector.tsx +++ b/plugin/src/ui/createTaskModal/LabelSelector.tsx @@ -36,7 +36,7 @@ export const LabelSelector: React.FC = ({ selected, setSelected }) => { void; +}; + +export const OptionsSelector: React.FC = ({ selected, setSelected }) => { + const i18n = t().createTaskModal.optionsSelector; + + const onAction = (key: Key) => { + if (key === "add-link-to-content") { + setSelected({ ...selected, appendLinkTo: "content" }); + } else if (key === "add-link-to-description") { + setSelected({ ...selected, appendLinkTo: "description" }); + } else if (key === "do-not-add-link") { + setSelected({ ...selected, appendLinkTo: undefined }); + } + }; + + const items: Array<{ + key: string; + label: string; + isSelected: boolean; + }> = [ + { + key: "add-link-to-content", + label: i18n.addLinkToContent, + isSelected: selected.appendLinkTo === "content", + }, + { + key: "add-link-to-description", + label: i18n.addLinkToDescription, + isSelected: selected.appendLinkTo === "description", + }, + { + key: "do-not-add-link", + label: i18n.doNotAddLink, + isSelected: selected.appendLinkTo === undefined, + }, + ]; + + return ( + + + + + {items.map((item) => ( + + {item.label} + + ))} + + + + ); +}; diff --git a/plugin/src/ui/createTaskModal/PrioritySelector.tsx b/plugin/src/ui/createTaskModal/PrioritySelector.tsx index 9820b6e3..48f9000f 100644 --- a/plugin/src/ui/createTaskModal/PrioritySelector.tsx +++ b/plugin/src/ui/createTaskModal/PrioritySelector.tsx @@ -32,7 +32,7 @@ export const PrioritySelector: React.FC = ({ selected, setSelected }) => { + switch (destination) { + case "content": + return i18n.appendedLinkToContentMessage; + case "description": + return i18n.appendedLinkToDescriptionMessage; + default: + return undefined; + } +}; + export const CreateTaskModal: React.FC = (props) => { const plugin = PluginContext.use(); @@ -75,7 +92,7 @@ const CreateTaskModalContent: React.FC = ({ const [options, setOptions] = useState(initialOptions); - const isSubmitButtonDisabled = content === "" && !options.appendLinkToContent; + const isSubmitButtonDisabled = content === "" && options.appendLinkTo !== "content"; const i18n = t().createTaskModal; @@ -103,7 +120,7 @@ const CreateTaskModalContent: React.FC = ({ modal.close(); const params: CreateTaskParams = { - description: buildWithLink(description, options.appendLinkToDescription), + description: buildWithLink(description, options.appendLinkTo === "description"), priority: priority, labels: labels.map((l) => l.name), projectId: project.projectId, @@ -123,7 +140,7 @@ const CreateTaskModalContent: React.FC = ({ try { await plugin.services.todoist.actions.createTask( - buildWithLink(content, options.appendLinkToContent), + buildWithLink(content, options.appendLinkTo === "content"), params, ); new Notice(i18n.successNotice); @@ -133,6 +150,8 @@ const CreateTaskModalContent: React.FC = ({ } }; + const linkDestinationMessage = getLinkDestinationMessage(options.appendLinkTo, i18n); + return (
= ({ onChange={setDescription} />
- - - +
+ + + +
+
+ +
-
    - {options.appendLinkToContent &&
  • {i18n.appendedLinkToContentMessage}
  • } - {options.appendLinkToDescription &&
  • {i18n.appendedLinkToDescriptionMessage}
  • } -
+
    {linkDestinationMessage &&
  • {linkDestinationMessage}
  • }

diff --git a/plugin/src/ui/createTaskModal/styles.scss b/plugin/src/ui/createTaskModal/styles.scss index f76c3ab1..f0981748 100644 --- a/plugin/src/ui/createTaskModal/styles.scss +++ b/plugin/src/ui/createTaskModal/styles.scss @@ -34,9 +34,15 @@ margin-top: 0.5em; display: flex; align-items: center; + justify-content: space-between; - &>*+* { - margin-left: 0.5em; + .task-creation-selectors-group { + display: flex; + align-items: center; + + &>*+* { + margin-left: 0.5em; + } } button { @@ -45,8 +51,8 @@ border: 1px solid var(--color-base-25); color: var(--text-muted); - .obsidian-icon { - margin-right: 0.5em; + &>*+* { + margin-left: 0.5em; } &:hover, @@ -275,6 +281,23 @@ } } + +.task-options-menu { + .task-option-dialog-item { + padding: 8px 1em; + font-size: var(--font-smaller); + + &:hover { + background-color: var(--background-modifier-cover); + } + + &.is-selected { + background-color: var(--interactive-accent); + color: var(--text-on-accent); + } + } +} + button.project-selector { box-shadow: none; background-color: unset;