-
Notifications
You must be signed in to change notification settings - Fork 12
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: create config page for sw settings #24
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.
quick review. still in draft cause it can use a bit more cleanup
if (isConfigExpanded) { | ||
return (<Config />) |
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.
eventually, this landing page should only be the config page....?
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Okay, so I found out that if you empty the config (gateways and routers to "[]"), it works fine; I will investigate further. I think ff7bafe fixed this. |
question here: do we want the user to be able to override all of the gateways & routers? currently the config.gateways and routers are appended:
|
IMO getting shown a status page with a lot of options on initial load is a little unfriendly. Maybe just a "hey welcome to the service worker gateway, if you want to change settings or for more information go to " |
Other opinions welcome I'd probably start with append, and then we can figure out removal. Right now it's a bit tempting to just show the list of URLs to modify, but we may have some routers that are more complicated (e.g. a validating ENS router, or if IPNI federation gets off the ground) |
I can leave it collapsed by default and have autoReload default to true? |
also see #19 (comment) |
chatted with lidel
|
const [isCollapsed, setCollapsed] = useState(collapsed) | ||
|
||
return ( | ||
<React.Fragment> |
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.
vscode was being weird in this file yelling about all types of syntax errors that didn't exist after closing it and re-opening. ¯\_(ツ)_/¯
const buttonClasses = new Set(['button-reset', 'pv3', 'tc', 'bn', 'white', 'w-100', 'cursor-disabled', 'bg-gray']) | ||
if (isServiceWorkerRegistered) { | ||
buttonClasses.delete('bg-gray') | ||
buttonClasses.delete('cursor-disabled') | ||
buttonClasses.add('bg-animate') | ||
buttonClasses.add('bg-black-80') | ||
buttonClasses.add('hover-bg-aqua') | ||
buttonClasses.add('pointer') | ||
} |
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.
this should probably be a useMemo and two distinct string values
root.render( | ||
<React.StrictMode> | ||
<ServiceWorkerProvider> | ||
<ConfigProvider expanded={window.location.pathname === '/config'}> | ||
<App /> | ||
</ConfigProvider> | ||
</ServiceWorkerProvider> | ||
</React.StrictMode> | ||
) |
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.
simplified root logic. page rendering determined in app.tsx
* Intended only for pushing from SW to the UI output terminal | ||
*/ | ||
SHOW_STATUS = 'SHOW_STATUS', | ||
RELOAD_CONFIG = 'RELOAD_CONFIG', |
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.
we probably need a RELOAD_CONFIG_DONE
here that SW emits so we can block on config saving until the SW is refreshed with any updated config. This should prevent any confusion when adding a new gateway and not seeing requests go to that gateway.
|
||
export interface ConfigDb { | ||
gateways: string[] | ||
routers: string[] | ||
autoReload: boolean | ||
debug: string |
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.
you can use https://npmjs.com/package/debug strings to set debug levels on the service worker. similar to setting DEBUG=...
env var in the terminal
export interface UrlParts { | ||
id: string | null | ||
protocol: string | null | ||
parentDomain: string |
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.
moved this over from sw mostly so i could use this for iframe rendering of the config page now that we dont have BASE_URL. Only change is the addition of this parentDomain
channel.postMessage({ target: 'SW', action: 'RELOAD_CONFIG' }) | ||
// try to preload the content | ||
setTimeout(() => { | ||
fetch(window.location.href, { method: 'GET' }).then((response) => { |
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.
when user is done on config page, "load content" or refresh should result in immediate rendering (or at least less wait time)
will merge this so we can iterate on any changes people want. lots of cleanup done in this PR |
partially addresses #22
Todo