-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor(client): more config cleanup and consolidation #2265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits. I also have issues with the moved code but I assume that can be cleaned up later
@@ -23,6 +22,7 @@ export class AddAccessKeyDialog extends LitElement { | |||
) => string; | |||
@property({type: Boolean}) open: boolean; | |||
@property({type: String}) accessKey: string = ''; | |||
@property({type: Function}) isValidAccessKey: (accessKey: string) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: usually since this is a function not a boolean i'd give it an "action-based" name like validateAccessKey
or accessKeyValidator
for clarity but up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is a boolean though. I think it reads more clearly in tha call sites that way.
|
||
import * as errors from '../../model/errors'; | ||
|
||
export type TransportConfigJson = object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assume you just moved all this code w/o modifying, but maybe we make this type more explicit? would clean up some of the type casting below. maybe in a follow up pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type definition is intended to belong in the Go code. That's why I made it a generic object here.
The Typescript code is supposed to treat it as a black box and not dig into it. Though it does in the instances below.
At least now it's clearer where we violate the abstraction and what we still need to fix for advanced configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in the future these methods would belong in go? maybe worth a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to add a comment.
export type TransportConfigJson = object; | |
/** TransportConfigJson is an opaque config format defined in Go, TypeScript should not rely on its fields. */ | |
export type TransportConfigJson = object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@jyyi1 thoughts? |
|
||
import * as errors from '../../model/errors'; | ||
|
||
export type TransportConfigJson = object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to add a comment.
export type TransportConfigJson = object; | |
/** TransportConfigJson is an opaque config format defined in Go, TypeScript should not rely on its fields. */ | |
export type TransportConfigJson = object; |
* getAddressFromTransportConfig returns the address of the tunnel server, if there's a meaningful one. | ||
* This is used to show the server address in the UI when connected. | ||
*/ | ||
export function getAddressFromTransportConfig( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a TODO
to remind us moving this logic to Go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TODO is for most of this file. I think it's pointless to add TODOs everywhere here. Also this is in flux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! LGTM, thanks for the cleanup.
This PR further removes dependencies on the Shadowsocks format, and consolidates them, so it's clear what needs to be fixed. I have created the
config.ts
file to centralize all the config logic.One critical cleanup was the removal of Shadowsocks validation from the add access key view.