Skip to content
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

Toggl Client & Project Creation #13884

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Toggl Client & Project Creation #13884

merged 1 commit into from
Sep 12, 2024

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Sep 10, 2024

Resolves #7928
Resolves #8973

Summary by CodeRabbit

  • New Features

    • Introduced actions for creating and updating clients and projects in Toggl.
    • Added methods for retrieving client and project details.
    • Enhanced the Toggl application with structured data types for better management of client and project information.
  • Bug Fixes

    • Minor version updates for existing actions indicating potential enhancements or fixes.
  • Documentation

    • Updated version numbers across various modules to reflect recent changes and improvements.

Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pipedream ❌ Failed (Inspect) Sep 10, 2024 7:02pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Sep 10, 2024 7:02pm
pipedream-docs ⬜️ Ignored (Inspect) Sep 10, 2024 7:02pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Sep 10, 2024 7:02pm

Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Walkthrough

The changes introduce new actions for creating and updating clients and projects in the Toggl application, enhancing the integration with Toggl's API. New files for client and project actions have been added, along with updates to existing modules to support these functionalities. The versioning of several components has been incremented, reflecting enhancements or bug fixes. Additionally, the main Toggl application module has been updated to include methods for retrieving and managing client and project data.

Changes

Files Change Summary
components/toggl/actions/create-client/create-client.mjs Added a new action for creating clients with required properties and an asynchronous run method.
components/toggl/actions/create-project/create-project.mjs Added a new action for creating projects with defined properties and an asynchronous run method.
components/toggl/actions/update-client/update-client.mjs Added a new action for updating clients, retrieving current details before applying updates.
components/toggl/actions/update-project/update-project.mjs Added a new action for updating projects, similar to the client update action.
components/toggl/actions/get-current-time-entry/get-current-time-entry.mjs Updated version from 0.0.5 to 0.0.6.
components/toggl/actions/get-time-entries/get-time-entries.mjs Updated version from 0.0.5 to 0.0.6.
components/toggl/actions/get-time-entry/get-time-entry.mjs Updated version from 0.0.5 to 0.0.6.
components/toggl/package.json Updated package version from 0.0.6 to 0.1.0.
components/toggl/sources/new-start-time-entry/new-start-time-entry.mjs Updated version from 0.0.3 to 0.0.4.
components/toggl/sources/new-time-entry/new-time-entry.mjs Updated version from 0.0.3 to 0.0.4.
components/toggl/sources/new-update-time-entry/new-update-time-entry.mjs Updated version from 0.0.3 to 0.0.4.
components/toggl/sources/new-webhook-event/new-webhook-event.mjs Updated version from 0.0.3 to 0.0.4.
components/toggl/toggl.app.mjs Added new properties and methods for managing clients and projects, enhancing API interactions.

Assessment against linked issues

Objective Addressed Explanation
Create new client / Update client (#[7928])
Create project / Update project (#[7928])
Enhance Toggl API integration with CRUD operations (#[7928])

🐰 In the fields where clients grow,
New projects bloom, and updates flow.
With actions fresh, our tasks align,
In Toggl's world, our work will shine!
Let's hop along, with joy we sing,
For every change, a new beginning! 🌼

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0748914 and da5c98d.

Files selected for processing (13)
  • components/toggl/actions/create-client/create-client.mjs (1 hunks)
  • components/toggl/actions/create-project/create-project.mjs (1 hunks)
  • components/toggl/actions/get-current-time-entry/get-current-time-entry.mjs (1 hunks)
  • components/toggl/actions/get-time-entries/get-time-entries.mjs (1 hunks)
  • components/toggl/actions/get-time-entry/get-time-entry.mjs (1 hunks)
  • components/toggl/actions/update-client/update-client.mjs (1 hunks)
  • components/toggl/actions/update-project/update-project.mjs (1 hunks)
  • components/toggl/package.json (1 hunks)
  • components/toggl/sources/new-start-time-entry/new-start-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-time-entry/new-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-update-time-entry/new-update-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-webhook-event/new-webhook-event.mjs (1 hunks)
  • components/toggl/toggl.app.mjs (3 hunks)
Files skipped from review due to trivial changes (8)
  • components/toggl/actions/get-current-time-entry/get-current-time-entry.mjs
  • components/toggl/actions/get-time-entries/get-time-entries.mjs
  • components/toggl/actions/get-time-entry/get-time-entry.mjs
  • components/toggl/package.json
  • components/toggl/sources/new-start-time-entry/new-start-time-entry.mjs
  • components/toggl/sources/new-time-entry/new-time-entry.mjs
  • components/toggl/sources/new-update-time-entry/new-update-time-entry.mjs
  • components/toggl/sources/new-webhook-event/new-webhook-event.mjs
Additional comments not posted (8)
components/toggl/actions/update-project/update-project.mjs (1)

1-101: LGTM!

The code changes are approved.

The code follows a clear and modular structure, defining the action's metadata and input properties in the exported object. The run method uses the toggl app's methods to retrieve and update the project, handling the API interaction effectively.

The use of optional chaining and logical OR operators to provide default values for the updateProject method's input data ensures that existing project data is preserved if not provided in the input properties, which is a good practice.

The code also exports a summary message if the project is successfully updated, providing useful feedback to the user.

components/toggl/toggl.app.mjs (7)

42-56: LGTM!

The code changes are approved.

The clientId property is defined correctly with appropriate metadata, including the label, description, and type. The options method provides a dynamic list of clients based on the selected workspace, enhancing the user experience by allowing users to select from available clients.


57-71: LGTM!

The code changes are approved.

The projectId property is defined correctly with appropriate metadata, including the label, description, and type. The options method provides a dynamic list of projects based on the selected workspace, enhancing the user experience by allowing users to select from available projects.


72-97: LGTM!

The code changes are approved.

The clientName, notes, projectName, startDate, and endDate properties are defined correctly with appropriate metadata, including labels, descriptions, and types. Marking the notes property as optional provides flexibility to the user.

The descriptions for the startDate and endDate properties specify the expected date format (YYYY-MM-DD), which is helpful for users to ensure they provide the correct input.


138-147: LGTM!

The code changes are approved.

The getClients and getProjects methods are implemented correctly, accepting the necessary parameters (workspaceId and $). They use the _makeRequest method to make API requests, which is consistent with other methods in the file.

The API endpoints used in the methods (workspaces/${workspaceId}/clients and workspaces/${workspaceId}/projects) are correct according to the Toggl API documentation.


166-175: LGTM!

The code changes are approved.

The getClient and getProject methods are implemented correctly, accepting the necessary parameters (workspaceId, clientId/projectId, and $). They use the _makeRequest method to make API requests, which is consistent with other methods in the file.

The API endpoints used in the methods (workspaces/${workspaceId}/clients/${clientId} and workspaces/${workspaceId}/projects/${projectId}) are correct according to the Toggl API documentation.


176-191: LGTM!

The code changes are approved.

The createClient and createProject methods are implemented correctly, accepting the necessary parameters (workspaceId, data, and $). They use the _makeRequest method to make API requests with the post method, which is appropriate for creating new resources.

The API endpoints used in the methods (workspaces/${workspaceId}/clients and workspaces/${workspaceId}/projects) are correct according to the Toggl API documentation.


192-207: LGTM!

The code changes are approved.

The updateClient and updateProject methods are implemented correctly, accepting the necessary parameters (workspaceId, clientId/projectId, data, and $). They use the _makeRequest method to make API requests with the put method, which is appropriate for updating existing resources.

The API endpoints used in the methods (workspaces/${workspaceId}/clients/${clientId} and workspaces/${workspaceId}/projects/${projectId}) are correct according to the Toggl API documentation.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michelle0927 michelle0927 self-assigned this Sep 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (6)
components/toggl/actions/create-client/create-client.mjs (2)

1-45: Add JSDoc comments to document the action and its props.

To improve the maintainability and readability of the code, consider adding JSDoc comments to document the action and its props. This will provide a clear understanding of the action's purpose and the expected input.


9-29: Use object destructuring for the action props.

Consider using object destructuring for the action props to make the code more concise and readable. For example:

props: {
  toggl,
  workspaceId: {
    propDefinition: [toggl, "workspaceId"],
  },
  name: {
    propDefinition: [toggl, "clientName"],
  },
  notes: {
    propDefinition: [toggl, "notes"],
  },
},
components/toggl/actions/update-client/update-client.mjs (2)

1-61: Add JSDoc comments to document the action and its props.

To improve the maintainability and readability of the code, consider adding JSDoc comments to document the action and its props. This will provide a clear understanding of the action's purpose and the expected input.


9-39: Use object destructuring for the action props.

Consider using object destructuring for the action props to make the code more concise and readable. For example:

props: {
  toggl,
  workspaceId: {
    propDefinition: [toggl, "workspaceId"],
  },
  clientId: {
    propDefinition: [
      toggl,
      "clientId",
      (c) => ({ workspaceId: c.workspaceId }),
    ],
  },
  name: {
    propDefinition: [toggl, "clientName"],
    optional: true,
  },
  notes: {
    propDefinition: [toggl, "notes"],
  },
},
components/toggl/actions/create-project/create-project.mjs (2)

1-86: Add JSDoc comments to document the action and its props.

To improve the maintainability and readability of the code, consider adding JSDoc comments to document the action and its props. This will provide a clear understanding of the action's purpose and the expected input.


9-66: Use object destructuring for the action props.

Consider using object destructuring for the action props to make the code more concise and readable. For example:

props: {
  toggl,
  workspaceId: {
    propDefinition: [toggl, "workspaceId"],
  },
  name: {
    propDefinition: [toggl, "projectName"],
  },
  startDate: {
    propDefinition: [toggl, "startDate"],
  },
  endDate: {
    propDefinition: [toggl, "endDate"],
  },
  active: {
    type: "boolean",
    label: "Active",
    description: "Whether the project is active or archived. Defaults to `true`.",
    optional: true,
    default: true,
  },
  isPrivate: {
    type: "boolean",
    label: "Is Private?",
    description: "Whether the project is private or not. Defaults to `false`.",
    optional: true,
    default: false,
  },
  isShared: {
    type: "boolean",
    label: "Is Shared?",
    description: "Whether the project is shared or not. Defaults to `false`.",
    optional: true,
    default: false,
  },
  clientId: {
    propDefinition: [
      toggl,
      "clientId",
      (c) => ({ workspaceId: c.workspaceId }),
    ],
    optional: true,
  },
},
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0748914 and da5c98d.

Files selected for processing (13)
  • components/toggl/actions/create-client/create-client.mjs (1 hunks)
  • components/toggl/actions/create-project/create-project.mjs (1 hunks)
  • components/toggl/actions/get-current-time-entry/get-current-time-entry.mjs (1 hunks)
  • components/toggl/actions/get-time-entries/get-time-entries.mjs (1 hunks)
  • components/toggl/actions/get-time-entry/get-time-entry.mjs (1 hunks)
  • components/toggl/actions/update-client/update-client.mjs (1 hunks)
  • components/toggl/actions/update-project/update-project.mjs (1 hunks)
  • components/toggl/package.json (1 hunks)
  • components/toggl/sources/new-start-time-entry/new-start-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-time-entry/new-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-update-time-entry/new-update-time-entry.mjs (1 hunks)
  • components/toggl/sources/new-webhook-event/new-webhook-event.mjs (1 hunks)
  • components/toggl/toggl.app.mjs (3 hunks)
Files skipped from review due to trivial changes (8)
  • components/toggl/actions/get-current-time-entry/get-current-time-entry.mjs
  • components/toggl/actions/get-time-entries/get-time-entries.mjs
  • components/toggl/actions/get-time-entry/get-time-entry.mjs
  • components/toggl/package.json
  • components/toggl/sources/new-start-time-entry/new-start-time-entry.mjs
  • components/toggl/sources/new-time-entry/new-time-entry.mjs
  • components/toggl/sources/new-update-time-entry/new-update-time-entry.mjs
  • components/toggl/sources/new-webhook-event/new-webhook-event.mjs
Additional comments not posted (8)
components/toggl/actions/update-project/update-project.mjs (1)

1-101: LGTM!

The code changes are approved.

The code follows a clear and modular structure, defining the action's metadata and input properties in the exported object. The run method uses the toggl app's methods to retrieve and update the project, handling the API interaction effectively.

The use of optional chaining and logical OR operators to provide default values for the updateProject method's input data ensures that existing project data is preserved if not provided in the input properties, which is a good practice.

The code also exports a summary message if the project is successfully updated, providing useful feedback to the user.

components/toggl/toggl.app.mjs (7)

42-56: LGTM!

The code changes are approved.

The clientId property is defined correctly with appropriate metadata, including the label, description, and type. The options method provides a dynamic list of clients based on the selected workspace, enhancing the user experience by allowing users to select from available clients.


57-71: LGTM!

The code changes are approved.

The projectId property is defined correctly with appropriate metadata, including the label, description, and type. The options method provides a dynamic list of projects based on the selected workspace, enhancing the user experience by allowing users to select from available projects.


72-97: LGTM!

The code changes are approved.

The clientName, notes, projectName, startDate, and endDate properties are defined correctly with appropriate metadata, including labels, descriptions, and types. Marking the notes property as optional provides flexibility to the user.

The descriptions for the startDate and endDate properties specify the expected date format (YYYY-MM-DD), which is helpful for users to ensure they provide the correct input.


138-147: LGTM!

The code changes are approved.

The getClients and getProjects methods are implemented correctly, accepting the necessary parameters (workspaceId and $). They use the _makeRequest method to make API requests, which is consistent with other methods in the file.

The API endpoints used in the methods (workspaces/${workspaceId}/clients and workspaces/${workspaceId}/projects) are correct according to the Toggl API documentation.


166-175: LGTM!

The code changes are approved.

The getClient and getProject methods are implemented correctly, accepting the necessary parameters (workspaceId, clientId/projectId, and $). They use the _makeRequest method to make API requests, which is consistent with other methods in the file.

The API endpoints used in the methods (workspaces/${workspaceId}/clients/${clientId} and workspaces/${workspaceId}/projects/${projectId}) are correct according to the Toggl API documentation.


176-191: LGTM!

The code changes are approved.

The createClient and createProject methods are implemented correctly, accepting the necessary parameters (workspaceId, data, and $). They use the _makeRequest method to make API requests with the post method, which is appropriate for creating new resources.

The API endpoints used in the methods (workspaces/${workspaceId}/clients and workspaces/${workspaceId}/projects) are correct according to the Toggl API documentation.


192-207: LGTM!

The code changes are approved.

The updateClient and updateProject methods are implemented correctly, accepting the necessary parameters (workspaceId, clientId/projectId, data, and $). They use the _makeRequest method to make API requests with the put method, which is appropriate for updating existing resources.

The API endpoints used in the methods (workspaces/${workspaceId}/clients/${clientId} and workspaces/${workspaceId}/projects/${projectId}) are correct according to the Toggl API documentation.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test report
https://vunguyenhung.notion.site/Toggl-Client-Project-Creation-4c62c42f9dd84c0382eeea6ada0e4201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[ACTION] Toggl Client & Project Creation
3 participants