-
Notifications
You must be signed in to change notification settings - Fork 184
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
implement "server card" design #2839
Conversation
Are we completely removing the option of explicitly adding a server? |
|
Forgot to reference this issue: |
return new UproxyServerRepository( | ||
getLocalStorage(), core, vpnDevice); | ||
} catch (e) { | ||
console.warn('local storage unavailable'); |
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.
Why do you need this mock repository?
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 I have something to pass to UproxyServerRepository
when testing in Chrome.
chrome.app.window.create('index_vulcanized.html', null, (appWindow) => { | ||
chrome.app.window.create('index_vulcanized.html', { | ||
// When running as a Chrome extension for the first time, | ||
// open in a nice Nexus 5-like 16:9 aspect ratio (vertically). |
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.
Why Nexus 5 ratio?
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 figured it's a common aspect ratio. I replaced the explicit reference to a Nexus 5 with a pretty swish list of all common mobile devices.
@@ -0,0 +1,23 @@ | |||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
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 connected icon is svg, but the disconnected is png. Should we stick to svg?
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.
Yes, it's weird - but that's what I got with UX. I will follow up with them.
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.
Now 100% SVG!
@@ -82,3 +120,19 @@ Promise.all([serversListPagePromise, intents.GetGlobalIntentInterceptor()]).then | |||
} | |||
} | |||
); | |||
|
|||
// Add some mock servers if we are running as a Chrome extension. | |||
serversListPagePromise.then((serverListPage) => { |
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.
For platform-specific code, I think it's cleaner if we use implementation replacement.
In this case, we could replace the ServerRepository with one containing the two demo servers.
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.
Interesting idea. That would also let me mock out unreachable servers which is a limitation of the current approach. Let me get back to you on this one.
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.
OK, I did this - now if localStorage
is unavailable a mock ServerRepository
is returned. This allows me easily mock unreachable server behaviour and in doing so I discovered a bug in server_list.ts
- thanks :-)
})); | ||
} catch (e) { | ||
console.warn('could not load servers: ' + e.message); | ||
return Promise.resolve([]); |
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.
Let's throw and let the client decide how to handle.
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.
Done.
|
||
private disconnected(msg: string) { | ||
this.switchState(State.DISCONNECTED); | ||
this.status.innerHTML = msg; |
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.
Use this.status.textContent
instead.
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.
Done.
} | ||
|
||
this.switchState(State.CONNECTING); | ||
this.status.innerHTML = 'Connecting...'; |
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.
Use this.status.textContent
instead.
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.
Nice. Done throughout.
public pressAddServer(): Promise<ServerEntryComponent> { | ||
return this.servers.addServer(this.addTokenText.value).then((server) => { | ||
public enterAccessCode(code: string) { | ||
return this.servers.addServer(code).then((server) => { | ||
this.addServer(server); | ||
}); | ||
} | ||
|
||
private addServer(server: Server) { |
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.
Maybe call this addServerCard
and change enterAccessCode
to addServer
?
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.
Done.
resolve(new ServerListPage(appWindow.contentWindow.document.body, servers)); | ||
const listElem = appWindow.contentWindow.document.body.querySelector('#server-list') as HTMLElement; | ||
const serverListPage = new ServerListPage(listElem, servers); | ||
appWindow.contentWindow.addEventListener('resize', () => { |
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 would a resize trigger? Do we really need to listen to this event?
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.
Correct, it will never trigger on a mobile device. I found it useful during developing but would agree it's not strictly necessary and adding it was quite messy. Happy to remove if you'd prefer.
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 think we should instead use CSS + class names for the positioning of the elements.
For example, we could have a class for regular cards, and a class for when it's a single card.
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.
Hmm, might be possible. I'll have to experiment a bit with that.
} | ||
</style> | ||
|
||
<style is="custom-style"> |
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.
Why is this custom-style?
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'm using it so I can re-use the Material Design colour var
s.
I found some more info on this attribute here:
https://www.polymer-project.org/1.0/docs/api/custom-style
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.
Should we move all the style into this?
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 can't because those styles only to web components - if we try to hide, say, the scrollbar here then that fails. I don't very much like this limitation but was quite happy to be able to import colours and opacity...
d9bb8c8
to
1c7e4c8
Compare
Update: I had broken server persistence. It's now basically identical to master except it can handle the exceptions thrown by the new mock storage. |
Reviewed 4 of 8 files at r1. src/cca/scripts/background.ts, line 86 at r1 (raw file): Previously, trevj wrote…
I wonder if this is needed at all. If you resize the window, won't it accommodate things automatically? Comments from Reviewable |
Reviewed 1 of 1 files at r2, 1 of 2 files at r5, 2 of 2 files at r7. Comments from Reviewable |
OK, I was able to use only CSS to control the card height. PTAL! |
👍 Reviewed 3 of 4 files at r10, 3 of 4 files at r11. src/cca/index.html, line 83 at r11 (raw file):
Not for this PR, but we should move away from using src/cca/ui_components/server_card.ts, line 80 at r11 (raw file):
I think it's more maintainable if we avoid Comments from Reviewable |
I tried using I think we should leave that for a future PR. |
Sounds good to me 👍 |
This implements much of the final "server card" design:
Things to note:
This change is