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

Feat/persistent-docker-network #734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amovfx
Copy link
Contributor

@amovfx amovfx commented Jun 9, 2023

-NewNetwork now has an input to create/attach to an external docker network
-NetworkActions now has a modal for the user to
create/attach/clear to an external docker network.

Closes #(issue number goes here)
#525

Description

Allows for polar to attach or create an external docker network.

Steps to Test

  1. Create a new network.

  2. Fill out the Docker External Network field

  3. Check the docker-compose file or docker network ls

  4. In a current network, go to docker options in the hamburger menu
    of NetworkActions.

  5. In the modal, name your docker network. Hit okay

  6. Check the docker-compose file or docker network ls.

A status icon is also visible.

@amovfx
Copy link
Contributor Author

amovfx commented Jun 9, 2023

ANd just a heads up, this is a prototype, I dont have any tests or anything written yet.

@jamaljsr
Copy link
Owner

Apologies for the delay in reviewing this. I've been traveling. I'll test this out and provide feedback by the end of the week. Thanks for tackling this issue.

@amovfx
Copy link
Contributor Author

amovfx commented Sep 18, 2023

Hey, @jamaljsr could I get a quick review on its current roughed in ui? I'm worried it might be going out of scope.

Questions:
Should new network have the ability to create or attach a docker network. While remaining unattached and having used this feature already on my current project, this is something I like.

Screenshot 2023-09-17 at 5 47 38 PM

Is this badge a good idea?
Screenshot 2023-09-17 at 5 47 57 PM

Docker options, I think this is appropriate place for them while providing a place extend docker features.
Screenshot 2023-09-17 at 5 49 44 PM

Screenshot 2023-09-17 at 5 50 01 PM

@jamaljsr jamaljsr self-requested a review September 19, 2023 20:15
@jamaljsr
Copy link
Owner

Hey @amovfx thanks for the updates. I'll take a look at this in the next few days.

@jamaljsr
Copy link
Owner

I have tested the functionality. Great job querying for the list of existing networks. That's a great touch 👌

I do have some suggestions for improvement:

  1. When creating a new network, we should hide the external network field under a collapsible Advanced Options section. Since 99% of users will never use this, I don't think it should be front and center.
  2. I'm not a fan of the badge next to the network name. These messages would look better as alerts on the canvas, similar to this
    image
  3. Adding the Docker Options item to the dropdown menu is great placement. I would just suggest to put it above the Delete option. It's better UX to have delete at the bottom.
  4. I created a new Polar network and specified an existing docker network. Afterwards, I went to the Docker Options modal but the network I chose was not pre-filled in the dropdown.

@amovfx
Copy link
Contributor Author

amovfx commented Sep 25, 2023

Awesome feedback. Will make these adjustments asap. Thanks.

@amovfx
Copy link
Contributor Author

amovfx commented Sep 26, 2023

Made these changes if you want to give them a look over and give the thumbs up. I'm going start doing a code review and a git squash. This one got pretty hairy so I'll probably need quite a bit of feedback on the review to bring it up to spec.

This update allows for creating and/or attaching of docker external
 networks
@amovfx amovfx force-pushed the feat/persistent-docker-network branch from 9335722 to 2a4137f Compare September 27, 2023 22:12
@amovfx amovfx marked this pull request as ready for review September 27, 2023 23:12
@amovfx
Copy link
Contributor Author

amovfx commented Sep 27, 2023

Hey @jamaljsr, Looking forward to your review.

I think this is the start of docker functionality. I have a couple branches of this PR to prototype some behavior that is helping my project that is interacting with docker more. Right now docker service actions are being called from the network store. This has me wondering if a store/model/docker.ts is going to be required.

Copy link
Owner

@jamaljsr jamaljsr left a comment

Choose a reason for hiding this comment

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

Thanks so much for implementing this. I really like that you fetch the existing docker networks to make it easy to choose the correct one.

Great work on the implementation. I have a bunch of comments on the code, but I don't think there are any major changes.

You have a conflict with the yarn.lock file. I'd suggest reverting your changes there. I also noticed there are still some linter errors that pop up when running yarn tsc.

Copy link
Owner

Choose a reason for hiding this comment

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

The changes to this file aren't necessary for this PR. Was this committed by accident?

@@ -27,7 +27,7 @@
"prebuild": "tsc -p electron/tsconfig.json && yarn theme",
"prepare": "husky install",
"release": "standard-version --no-verify --skip.commit --skip.tag",
"start": "rescripts start",
"start": "rescripts --openssl-legacy-provider start",
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure why this change was needed for you, but I got this error when trying to start the app with it:

node: bad option: --openssl-legacy-provider

When I removed this option it worked fine.

yarn.lock Outdated
Copy link
Owner

Choose a reason for hiding this comment

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

Did you need to nuke the yarn.lock file? It's running fine on my machine without these changes.

@@ -37,10 +46,19 @@ class ComposeFile {
constructor(id: number) {
this.content = {
version: '3.3',
name: `polar-network-${id}`,
name: polarNetworkName(id),
Copy link
Owner

Choose a reason for hiding this comment

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

I would refrain from extracting this into a util function until it's used in multiple places.

services: {},
};
}
setExternalNetworkName(name: string | undefined) {
Copy link
Owner

Choose a reason for hiding this comment

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

nit: add a space above this line.

});
});
describe('when the input is invalid', () => {
it('should isabled the OK button', async () => {
Copy link
Owner

Choose a reason for hiding this comment

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

typo: isabled

Comment on lines +1 to +2
// @jest-ignore

Copy link
Owner

Choose a reason for hiding this comment

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

These empty lines aren't necessary.

const statusColors = {
[Status.Starting]: 'blue',
[Status.Started]: 'green',
[Status.Stopping]: 'blue',
[Status.Stopped]: statusTag.stopped,
[Status.Stopped]: 'red',
Copy link
Owner

Choose a reason for hiding this comment

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

This shouldn't be changed to red because stopped is not an error state.

@@ -3,33 +3,37 @@ import { Status } from 'shared/types';
import { renderWithProviders } from 'utils/tests';
import StatusTag from './StatusTag';

describe('StatusBadge Component', () => {
describe('StatusTag Component', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Why change this StatusBadge.tsx file to test the StatusTag component? Did you mean to create a new test file?

interface Props {
name: string;
defaultValue?: string;
validateCallback?: (value: boolean) => void;
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of bubbling up the validation status via props, you could use rules prop to specify a custom regex pattern. This would prevent the form from submitting, display the error message inline, and change the border color of the input field.

<Form.Item rules={[{ pattern: /^[a-zA-Z0-9][a-zA-Z0-9_.-]{1,63}$/, message: l('helpInvalid') }]}>

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.

None yet

2 participants