-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Feature/tags and subtasks #24346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/tags and subtasks #24346
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dfe2c82
add/remove tags
abcd-ca 0719ea5
view subtasks for a task
abcd-ca 15f426f
add subtask, convert between task/subtask
abcd-ca b69cff1
can now rename a task/subtask
abcd-ca b527b06
Updated changelog
abcd-ca 4e820ca
Update extensions/asana/src/components/TaskDetail.tsx
abcd-ca 1405c35
refinements, suggested by Greptile bot
abcd-ca 11efbcc
Merge branch 'main' of github.com:raycast/extensions into feature/tag…
abcd-ca 529d6ff
Merge branch 'feature/tags-and-subtasks' of github.com:abcd-ca/ray-ca…
abcd-ca cef6584
prettier
abcd-ca 96c7f79
fix orphaned subtask
abcd-ca 84fa15f
create task bug fix
abcd-ca 374a21a
Apply suggestion from @greptile-apps[bot]
pernielsentikaer 68f2ca2
Update CHANGELOG.md
raycastbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,13 @@ | ||||||
| # Asana Changelog | ||||||
|
|
||||||
| ## [Add subtasks support and tag management] - 2026-01-09 | ||||||
|
||||||
| ## [Add subtasks support and tag management] - 2026-01-09 | |
| ## [Add subtasks support and tag management] - 2025-01-09 |
pernielsentikaer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
pernielsentikaer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { Action, ActionPanel, Form, Icon, useNavigation, Toast, showToast } from "@raycast/api"; | ||
| import { format } from "date-fns"; | ||
| import { FormValidation, getAvatarIcon, useForm, MutatePromise } from "@raycast/utils"; | ||
| import { useUsers } from "../hooks/useUsers"; | ||
| import { useMe } from "../hooks/useMe"; | ||
| import { useSections } from "../hooks/useSections"; | ||
| import { getErrorMessage } from "../helpers/errors"; | ||
| import { escapeHtml } from "../helpers/task"; | ||
| import TaskDetail from "./TaskDetail"; | ||
| import { Task, createSubtask, SubtaskPayload } from "../api/tasks"; | ||
|
|
||
| type SubtaskFormValues = { | ||
| name: string; | ||
| description: string; | ||
| assignee: string; | ||
| due_date: Date | null; | ||
| section: string; | ||
| }; | ||
|
|
||
| type CreateSubtaskFormProps = { | ||
| parentTask: Task; | ||
| workspace?: string; | ||
| mutateSubtasks?: MutatePromise<Task[] | undefined>; | ||
| }; | ||
|
|
||
| export default function CreateSubtaskForm({ parentTask, workspace, mutateSubtasks }: CreateSubtaskFormProps) { | ||
| const { push } = useNavigation(); | ||
|
|
||
| const { data: users, isLoading: isLoadingUsers } = useUsers(workspace); | ||
| const { data: me, isLoading: isLoadingMe } = useMe(); | ||
|
|
||
| const parentProjectId = parentTask.projects[0]?.gid; | ||
| const { data: sections, isLoading: isLoadingSections } = useSections(parentProjectId); | ||
|
|
||
| const { handleSubmit, itemProps, reset, focus } = useForm<SubtaskFormValues>({ | ||
| async onSubmit(values) { | ||
| const toast = await showToast({ style: Toast.Style.Animated, title: "Creating subtask" }); | ||
|
|
||
| try { | ||
| const payload: SubtaskPayload = { | ||
| name: values.name, | ||
| ...(values.description ? { html_notes: `<body>${escapeHtml(values.description)}</body>` } : {}), | ||
| ...(values.assignee ? { assignee: values.assignee } : {}), | ||
| ...(values.due_date ? { due_on: format(values.due_date, "yyyy-MM-dd") } : {}), | ||
| ...(parentProjectId | ||
| ? { | ||
| memberships: [{ project: parentProjectId, ...(values.section ? { section: values.section } : {}) }], | ||
| } | ||
| : {}), | ||
| }; | ||
|
|
||
| const subtask = await createSubtask(parentTask.gid, payload); | ||
|
|
||
| if (mutateSubtasks) { | ||
| mutateSubtasks(); | ||
| } | ||
|
|
||
| toast.style = Toast.Style.Success; | ||
| toast.title = "Created subtask"; | ||
|
|
||
| toast.primaryAction = { | ||
| title: "Open Subtask", | ||
| shortcut: { modifiers: ["cmd", "shift"], key: "o" }, | ||
| onAction: () => push(<TaskDetail task={subtask} workspace={workspace} />), | ||
| }; | ||
|
|
||
| reset({ | ||
| name: "", | ||
| description: "", | ||
| due_date: null, | ||
| assignee: values.assignee, | ||
| section: values.section, | ||
| }); | ||
|
|
||
| focus("name"); | ||
| } catch (error) { | ||
| toast.style = Toast.Style.Failure; | ||
| toast.title = "Failed to create subtask"; | ||
| toast.message = getErrorMessage(error); | ||
| } | ||
| }, | ||
| validation: { | ||
| name: FormValidation.Required, | ||
| }, | ||
| initialValues: { | ||
| name: "", | ||
| description: "", | ||
| assignee: "", | ||
| due_date: null, | ||
| section: "", | ||
| }, | ||
| }); | ||
|
|
||
| const projectInfo = parentTask.projects.length > 0 ? parentTask.projects.map((p) => p.name).join(", ") : "No project"; | ||
|
|
||
| return ( | ||
| <Form | ||
| navigationTitle={`Add subtask to "${parentTask.name}"`} | ||
| isLoading={isLoadingUsers || isLoadingMe || isLoadingSections} | ||
| actions={ | ||
| <ActionPanel> | ||
| <Action.SubmitForm title="Create Subtask" onSubmit={handleSubmit} /> | ||
| </ActionPanel> | ||
| } | ||
| > | ||
| <Form.Description title="Parent Task" text={parentTask.name} /> | ||
| <Form.Description title="Project" text={projectInfo} /> | ||
|
|
||
| {parentProjectId && sections && sections.length > 0 && ( | ||
| <Form.Dropdown title="Section" {...itemProps.section}> | ||
| <Form.Dropdown.Item title="No section" value="" icon={Icon.Tray} /> | ||
| {sections.map((section) => ( | ||
| <Form.Dropdown.Item key={section.gid} value={section.gid} title={section.name} icon={Icon.Tray} /> | ||
| ))} | ||
| </Form.Dropdown> | ||
| )} | ||
|
|
||
| <Form.Separator /> | ||
|
|
||
| <Form.TextField title="Subtask Name" placeholder="What needs to be done?" autoFocus {...itemProps.name} /> | ||
|
|
||
| <Form.TextArea title="Description" placeholder="Add more detail (optional)" {...itemProps.description} /> | ||
|
|
||
| <Form.Dropdown title="Assignee" {...itemProps.assignee}> | ||
| <Form.Dropdown.Item title="Unassigned" value="" icon={Icon.Person} /> | ||
| {users?.map((user) => ( | ||
| <Form.Dropdown.Item | ||
| key={user.gid} | ||
| value={user.gid} | ||
| title={user.gid === me?.gid ? `${user.name} (me)` : user.name} | ||
| icon={getAvatarIcon(user.name)} | ||
| /> | ||
| ))} | ||
| </Form.Dropdown> | ||
|
|
||
| <Form.DatePicker title="Due Date" type={Form.DatePicker.Type.Date} {...itemProps.due_date} /> | ||
| </Form> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { useState } from "react"; | ||
| import { List, Action, ActionPanel, Icon, showToast, Toast, useNavigation } from "@raycast/api"; | ||
| import { MutatePromise } from "@raycast/utils"; | ||
| import { Task, setTaskParent } from "../api/tasks"; | ||
| import { useSearchTasks } from "../hooks/useSearchTasks"; | ||
| import { getErrorMessage } from "../helpers/errors"; | ||
|
|
||
| type ParentTaskPickerProps = { | ||
| task: Task; | ||
| workspace: string; | ||
| mutateList?: MutatePromise<Task[] | undefined>; | ||
| mutateDetail?: MutatePromise<Task>; | ||
| }; | ||
|
|
||
| export default function ParentTaskPicker({ task, workspace, mutateList, mutateDetail }: ParentTaskPickerProps) { | ||
| const { pop } = useNavigation(); | ||
| const [searchText, setSearchText] = useState(""); | ||
| const { data: tasks, isLoading } = useSearchTasks(workspace, searchText); | ||
|
|
||
| // Filter out the current task from potential parents | ||
| const availableTasks = tasks?.filter((t) => t.gid !== task.gid); | ||
|
|
||
| async function selectParent(parentTask: Pick<Task, "gid" | "name">) { | ||
| try { | ||
| await showToast({ style: Toast.Style.Animated, title: "Converting to subtask" }); | ||
|
|
||
| const asyncUpdate = setTaskParent(task.gid, parentTask.gid); | ||
|
|
||
| if (mutateList) { | ||
| mutateList(asyncUpdate, { | ||
| optimisticUpdate(data) { | ||
| if (!data) { | ||
| return; | ||
| } | ||
| return data.map((t) => | ||
| t.gid === task.gid ? { ...t, parent: { gid: parentTask.gid, name: parentTask.name } } : t, | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| if (mutateDetail) { | ||
| mutateDetail(asyncUpdate, { | ||
| optimisticUpdate(data) { | ||
| return { ...data, parent: { gid: parentTask.gid, name: parentTask.name } }; | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| await asyncUpdate; | ||
|
|
||
| await showToast({ | ||
| style: Toast.Style.Success, | ||
| title: "Converted to subtask", | ||
| message: `Now a subtask of "${parentTask.name}"`, | ||
| }); | ||
|
|
||
| pop(); | ||
| } catch (error) { | ||
| await showToast({ | ||
| style: Toast.Style.Failure, | ||
| title: "Failed to convert to subtask", | ||
| message: getErrorMessage(error), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <List | ||
| navigationTitle={`Select parent for "${task.name}"`} | ||
| searchBarPlaceholder="Search for a task..." | ||
| onSearchTextChange={setSearchText} | ||
| isLoading={isLoading} | ||
| throttle | ||
| > | ||
| <List.EmptyView title="No tasks found" description="Try a different search term" /> | ||
| {availableTasks?.map((parentTask) => ( | ||
| <List.Item | ||
| key={parentTask.gid} | ||
| title={parentTask.name} | ||
| icon={Icon.Circle} | ||
| actions={ | ||
| <ActionPanel> | ||
| <Action title="Set as Parent" icon={Icon.ArrowUp} onAction={() => selectParent(parentTask)} /> | ||
| </ActionPanel> | ||
| } | ||
| /> | ||
| ))} | ||
| </List> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.