Skip to content

Adding Team functionality in Asana - #3262

Closed
stanty522 wants to merge 0 commit into
raycast:mainfrom
stanty522:main
Closed

stanty522 wants to merge 0 commit into
raycast:mainfrom
stanty522:main

Conversation

@stanty522

Copy link
Copy Markdown
Contributor

Description

Made changes to the Asana extension to include Teams. This creates a filter for Projects to only be searched under the selected Team.

This addresses an earlier issue where the query for Projects would time out if a workspace had too many existing Projects.

Screencast

CleanShot 2022-10-17 at 14 31 14

Checklist

[ ✅] I read the extension guidelines
[ ✅] I read the documentation about publishing
[ ✅] I ran npm run build and tested this distribution build in Raycast
[✅ ] I checked that files in the assets folder are used by the extension itself
[ ✅] I checked that assets used by the README are placed outside of the metadata folder

@raycastbot raycastbot added the extension fix / improvement Label for PRs with extension's fix improvements label Oct 17, 2022
@raycastbot

Copy link
Copy Markdown
Collaborator

Thank you for your first contribution! 🎉

🔔 @thomaslombart you might want to have a look.

@thomaslombart thomaslombart left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried it on my test workspace and it seemed to work but I'm a bit confused about how the teams are supposed to work when you don't have an organization in Asana.

Here's what I have in Asana:

CleanShot 2022-10-18 at 10 44 04@2x

As you can see, I don't have teams. So, I'm wondering if the teams field should not be there only if the users do have teams in their workspace.

Comment thread extensions/asana/src/api/teams.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the hardcoded number is supposed to be there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oop! yeah my bad there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If storeValue is used for teams, then the autofocus should be kept for the "Task Name" field as the team value will be remembered for the subsequent creations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried putting autoFocus on the Task Name like you said but it still wouldn't remember the value for Teams or Projects for the next time I create a task.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it does remember the value when there's autoFocus on the projects field? It doesn't seem related to me 🤔

@stanty522

stanty522 commented Oct 18, 2022 •

Copy link
Copy Markdown
Contributor Author

The documentation makes the distinction that if it's just a personal workspace there's just one team possible.

image

Maybe a logic check if the person is in an organisation or a workspace and therefore changes it accordingly?

Or another clunky solution - have an Asana for organisations extension and another one for personal workspaces.

@thomaslombart

Copy link
Copy Markdown
Contributor

Oh, didn't know that. Then I guess, the team's field can simply be hidden if there's only one team available for the user and if the experience is the same when you add a task to a team instead of a workspace for a personal use 🙂

@stanty522

Copy link
Copy Markdown
Contributor Author

Hey here's my attempt at trying to fix this. Unfortunately I'm running into some basic syntax error :(

However I think the logic will work. Basically in the Asana documentation there is a boolean property for workspaces that informs us if its an organization or not. So basically I've added this to the workspaces.ts and then I plan to use this as a variable in the CreatTaskForm.tsx which will be a conditional if statement to return the form drop down for teams or not. If true (i,e, workspace is an organization) then return teams form drop down, else don't return.

const isOrganization = workspaces?.map((workspace) => workspace.is_organization);

  if (isOrganization === true) {
      return 
        <Form.Dropdown title="Teams" storeValue {...itemProps.team}>
        {teams?.map((teams) => {
          return (
          <Form.Dropdown.Item 
            key={teams.gid} 
            value={teams.gid} 
            title={teams.name} 
            />
          );
        })}
      </Form.Dropdown>

@stanty522

stanty522 commented Oct 31, 2022 •

Copy link
Copy Markdown
Contributor Author

@thomaslombart

I figured out the logic of checking if the workspace is an organisation or not. While this works, it unfortunately creates a new issue whereby the workspaces that are NOT organisations cannot select a team, and if a team is not selected a project cannot be selected.

        {workspaces?.map((workspace) => {
            if (workspace.is_organization) {
              return (
                <Form.Dropdown title="Teams" storeValue {...itemProps.team}>
                {teams?.map((teams) => {
                  return (
                  <Form.Dropdown.Item 
                    key={teams.gid} 
                    value={teams.gid} 
                    title={teams.name} 
                    />
                  );
                })}
              </Form.Dropdown>
              );
            }
          })
        }

      <Form.TagPicker title="Projects" placeholder="Select one or more projects" storeValue {...itemProps.projects}>
        {allProjects?.map((project) => {
          return (
            <Form.TagPicker.Item
              key={project.gid}
              icon={getProjectIcon(project)}
              title={project.name}
              value={project.gid}
            />
          );
        })}
      </Form.TagPicker>

@thomaslombart

Copy link
Copy Markdown
Contributor

and if a team is not selected a project cannot be selected.

But in that case, the projects can be retrieved based on a workspace instead of a team?

@stanty522

Copy link
Copy Markdown
Contributor Author

But in that case, the projects can be retrieved based on a workspace instead of a team?

Yes that's possible but I'm not sure how I'd go about that without over complicating the structure :(

@thomaslombart

Copy link
Copy Markdown
Contributor

Then, I'll take a look at that probably end of next week. I'm focusing on another project at the moment 😊

@thomaslombart

Copy link
Copy Markdown
Contributor

After taking a look, I think it can be done in a few steps:

  • useProjects and getProjects should be modified to handle an additional workspace parameter. The algorithm would be pretty simple: the team is used first to retrieve the projects. But, if it's undefined (in the case you mentioned), then the workspace is used to retrieve it.
  • Then in CreateTaskForm, you could pass the workspace and the team to useProjects: useProjects({ workspace, team })

Otherwise, someone from the Raycast team told me the API call to retrieve the projects in the native extension was different than the one used here. Here we use the /projects endpoint whereas in the native extension it's /workspaces/{workspaceId}/typeahead with the resource_type param specified as project. It may be easier to switch to it to remove the project's pagination issue here.

@stanty522

Copy link
Copy Markdown
Contributor Author

So I tried the typeahead thing first, and I'm not sure if I did it correctly, but I just ended up with the same issue of having too many projects and for it to even work I had to put the optional parameter of limit. I'm not sure if there's a way to only start the query after X characters have been typed so it won't try to query everything from the start.

The steps you suggested, I only got as far as to add the additional workspace parameter to getProjects and useProjects. Im still quite new to typescript and async programming so not exactly sure how to implement the if then statement check that would retrieve workspace. Is there a similar piece of code where this is done so I can learn from that?

@thomaslombart

Copy link
Copy Markdown
Contributor

Hey there, I'm not sure where this could have been done...
Unfortunately, I won't have enough bandwidth to work on that this week. I'll take another look at it probably next week or maybe the week after.

@stanty522 stanty522 closed this Nov 21, 2022
arguiot added a commit to arguiot/raycast-extensions that referenced this pull request Sep 6, 2025
- Update package.json
- Remove card hover animations (raycast#3298)
- Raycast extension V1 (raycast#3238)
- (Part 2) Notification system (raycast#3120)
- Fix cannot access meeting while starting a new meeting (raycast#3246)
- Fix issue with auto-start being triggered when you go to new meeting (raycast#3295)
- Enable commenting on external meetings (raycast#3294)
- Remove command menu divider (raycast#3293)
- Fix for not showing selected screen in record panel (raycast#3290)
- Fix bug with comments not being associated with words (raycast#3291)
- Fix command menu colour in dark mode (raycast#3292)
- Fix for meeting having no attendees/participants (raycast#3279)
- Fix for screen showing at the end (raycast#3287)
- Floating panel component (raycast#3266)
- Update raycast oauth scope (raycast#3289)
- LLM language response prompt update (raycast#3286)
- Fix for not able to update meeting (raycast#3272)
- Fix for screen syncing issue (raycast#3255)
- Fix account disconnects (raycast#3285)
- Delete meeting window detection/notification hook (raycast#3283)
- Only remux for our recordings, don\'t remux recall (raycast#3235)
- ical_uid fix (raycast#3281)
- Fix spacing for last action item (raycast#3280)
- Dedup calendar meetings across different calendars (raycast#3268)
- Do not autostart when recording (raycast#3278)
- Always use inputUri as fileUrl for `detect-language` (raycast#3276)
- Use inputUri as default fileUrl on detect language receiver (raycast#3275)
- Fix missing header in GCS finish upload path (future meetings) (raycast#3264)
- Fix keyboard issues on mobile (raycast#3274)
- Mobile web fixes for multi-select (raycast#3263)
- Exclude device recording meetings from recall check (raycast#3270)
- Update mobile labeler (raycast#3269)
- Update left nav badge (raycast#3256)
- Fix bug with missing attendees in people tab (raycast#3265)
- Moved discard changes to a shared hook (raycast#3262)
- Minor style updates for nested subcommands (raycast#3260)
- Awaiting for router to complete after discarding automation (raycast#3261)
- Add Cmd/Ctrl+N for new meeting (raycast#3257)
- Define relevant attendees before usage (raycast#3259)
- Prorated seat charge comments (raycast#3254)
- Add email sender attribution Posthog events (raycast#3045)
- Preparing for store
- Remove default val for `excludeRecallMeetings` (raycast#3253)
- Onboarding V2: Prompt for calendar access (raycast#3183)
- Schedule team seat update on deactivate/invite/make viewer/etc (raycast#3234)
- Update oauth.ts
- Update search-meetings.tsx
- Remove duplicate maxDuration config (raycast#3250)
- Clean up imports and meeting URL construction
- Fix assistant submit button alignment (raycast#3251)
- Add fire icon and improve Raycast extension text
- Add new db alerts to github actions [1 liner] (raycast#3249)
- Add better DB alerts (raycast#3248)
- Update package.json
- Lint
- Merge branch \'main\' into arthur/raycast
- Connect input field (raycast#3195)
- Fix last unmatched attendee when calendar invitee has diff email (raycast#3240)
- cleanup
- Improved extension
- Merge branch \'arthur/oauth-pkce\' into arthur/raycast
- Update oauth.ts
- [DB Migration] Adds OAuth PKCE authorization flow
- [wip]
- Merge branch \'main\' into arthur/raycast
- setting up OAuth
- [wip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension fix / improvement Label for PRs with extension's fix improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants