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 config JSON or YAML #143

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Import config JSON or YAML #143

wants to merge 14 commits into from

Conversation

lotif
Copy link
Collaborator

@lotif lotif commented Dec 24, 2024

PR Type

Feature

Short Description

Clickup Ticket(s): https://app.clickup.com/t/868b1x701

Adding a button on the edit page to import a JSON or YAML file to populate the server configuration.

Screenshot 2024-12-24 at 11 52 46

Screenshot 2024-12-24 at 11 53 00

Screenshot 2024-12-24 at 11 53 09

Tests Added

Fully unit tested

@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.02%. Comparing base (1ed0b38) to head (227fd7d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #143      +/-   ##
==========================================
+ Coverage   93.83%   94.02%   +0.18%     
==========================================
  Files          24       24              
  Lines        2221     2291      +70     
  Branches      120      128       +8     
==========================================
+ Hits         2084     2154      +70     
  Misses        137      137              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -54,7 +54,7 @@ repos:
- id: prettier-js-format
name: prettier-js-format
entry: yarn prettier
files: "florist/app"
files: "(florist/app|florist/tests/unit/app)"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shoehorning this here so prettier can also format the unit test files as well.

Copy link
Collaborator

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

This generally LGTM. I'll have more questions and comments once I get more into the code and wipe some rust off of next.js and typescript "skills".

I'll get setup on the codebase by eow.

} else if (file.name.endsWith(".yaml") || file.name.endsWith(".yml")) {
data = yaml.load(fileText);
} else {
console.error(`file extension not supported: ${file.name}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we popup a modal to notify the user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about that but I didn't want to come up with a whole modal or to pop up an alert. Maybe there is a way to limit to only .json or .yaml file types on the upload dialog?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay, i think then this fine for now. In some past projects we used "ready-made" components that we can just use or at least adapt to make fit with our app style.

I think we could just chalk this up as part of something we look to do post milestone 1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added an attribute to the input file to only accept yaml and json files, now the error will only happen if the user goes out of their way to upload something that's not supported. I think that makes it better and prevents us from doing some extra work that doesn't add a lot to the app. Let me know what you think.
Screenshot 2025-01-23 at 16 45 09

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nerdai yes, we can also do this as part of the next milestone. About ready-made components, the CSS template I'm using has a modal component and that's what I used on #130 to display the logs modal, but JS part of it is not perfectly integrated with NextJS and it turned out to be a bit more work than I expected to make it work well. I think it will be easier to do once that PR is merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah okay, thanks for the context!

Copy link
Collaborator

@nerdai nerdai left a comment

Choose a reason for hiding this comment

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

lgtm!

ref={buttonRef}
id="job-server-config-uploader"
onChange={handleFileUpload}
accept=".json,.yaml,.yml,application/json,application/x-yaml,text/yaml"
Copy link
Collaborator

Choose a reason for hiding this comment

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

noice!

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

Successfully merging this pull request may close these issues.

3 participants