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

Import workflow #986

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Import workflow #986

merged 1 commit into from
Oct 16, 2024

Conversation

wintonzheng
Copy link
Contributor

@wintonzheng wintonzheng commented Oct 16, 2024

Important

Adds ImportWorkflowButton to import workflows from YAML/JSON files in the Workflows component, with server interaction and UI adjustments.

  • Feature Addition:
    • Adds ImportWorkflowButton component in ImportWorkflowButton.tsx to import workflows from YAML or JSON files.
    • Integrates ImportWorkflowButton into Workflows.tsx, allowing users to import workflows directly from the UI.
  • Functionality:
    • Uses useMutation from @tanstack/react-query to handle file upload and server interaction.
    • Converts JSON files to YAML before sending to the server.
    • On success, navigates to the workflow edit page; on error, displays a toast notification.
  • UI Changes:
    • Adds tooltip to ImportWorkflowButton explaining its functionality.
    • Adjusts layout in Workflows.tsx to accommodate the new import button.

This description was created by Ellipsis for cf2fc41. It will automatically update as commits are pushed.

…src/'

<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Add `ImportWorkflowButton` to import workflows from YAML/JSON files in the `Workflows` component.
>
>   - **Feature Addition**:
>     - Adds `ImportWorkflowButton` component in `ImportWorkflowButton.tsx` to import workflows from YAML or JSON files.
>     - Integrates `ImportWorkflowButton` into `Workflows.tsx`, allowing users to import workflows directly from the UI.
>   - **Functionality**:
>     - Uses `useMutation` from `@tanstack/react-query` to handle file upload and server interaction.
>     - Converts JSON files to YAML before sending to the server.
>     - On success, navigates to the workflow edit page; on error, displays a toast notification.
>   - **UI Changes**:
>     - Adds tooltip to `ImportWorkflowButton` explaining its functionality.
>     - Adjusts layout in `Workflows.tsx` to accommodate the new import button.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for 2dde8b1c11929940899737561b50d8f21daa0696. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on cf2fc41 in 16 seconds

More details
  • Looked at 169 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx:19
  • Draft comment:
    Consider renaming isJsonString to isValidJson for clarity. Also, directly return the result of the try-catch block for better readability.
function isValidJson(str: string): boolean {
  try {
    JSON.parse(str);
    return true;
  } catch (e) {
    return false;
  }
}
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function isJsonString is used to check if a string is a valid JSON. However, it can be improved for better readability and performance.
2. skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx:84
  • Draft comment:
    Use isLoading instead of isPending to check the mutation state.
{createWorkflowFromYamlMutation.isLoading ? (
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The createWorkflowFromYamlMutation uses isPending to check the mutation state, but useMutation provides isLoading for this purpose.
3. skyvern-frontend/src/routes/workflows/Workflows.tsx:190
  • Draft comment:
    Use isLoading instead of isPending to check the mutation state.
{createNewWorkflowMutation.isLoading ? (
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The createNewWorkflowMutation uses isPending to check the mutation state, but useMutation provides isLoading for this purpose.

Workflow ID: wflow_gUf6gA8i5avuc8l4


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to cf2fc41 in 35 seconds

More details
  • Looked at 169 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. skyvern-frontend/src/routes/workflows/ImportWorkflowButton.tsx:19
  • Draft comment:
    Consider renaming isJsonString to isValidJson for better readability. Additionally, you can simplify the function by returning the result of the try-catch directly:
function isValidJson(str: string): boolean {
  try {
    JSON.parse(str);
    return true;
  } catch (e) {
    return false;
  }
}
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The function isJsonString is used to check if a string is a valid JSON. However, it can be improved for better readability and performance.
2. skyvern-frontend/src/routes/workflows/Workflows.tsx:185
  • Draft comment:
    createNewWorkflowMutation.isPending should be createNewWorkflowMutation.isLoading for consistency with useMutation API. This also applies to line 191.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_QCE9BhYFhJ6JFoUc


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

}}
/>
<div className="flex h-full cursor-pointer items-center gap-2 rounded-md bg-secondary px-4 py-2 font-bold text-secondary-foreground hover:bg-secondary/90">
{createWorkflowFromYamlMutation.isPending ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

createWorkflowFromYamlMutation.isPending should be createWorkflowFromYamlMutation.isLoading for consistency with useMutation API.

@msalihaltun msalihaltun merged commit fd061d1 into main Oct 16, 2024
2 checks passed
@msalihaltun msalihaltun deleted the salih/import-workflow-from-file branch October 16, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants