-
Notifications
You must be signed in to change notification settings - Fork 16
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for standalone mode (default in development) #70
Conversation
Deploy preview for dhis2-app-platform ready! Built with commit 27d38a0 |
Nice! Very nice to have.
I was thinking of filling this field with the DHIS2_BASE_URL if it exists, but still allowing the user to override it. Just so that you can still override it if you want to, seems nice. |
As long as it is hidden in production this is an OK option too. |
Thanks for the feedback @ismay @varl! I like the idea of keeping the "configurability" in dev mode by defaulting to the DHIS2_BASE_URL var, but I think the utility might be limited (unless we get rid of the "sticky" localStorage piece). It also feels a bit like "hard-coding" the default? Implementing that would require adding a new "internal" env var like DHIS2_STANDALONE to effect the dev/prod switch. I do worry that anyone who has already set I think we should promote the following workflow: no environment variables should be necessary for simple apps, though they should be allowed for configuration of the production bundle in rare cases. As such, I think I'd prefer not supporting DHIS2_BASE_URL defaults in development. @ismay does that make sense to you? How much utility would setting the default have for you? |
Going to go ahead and merge this as-is, we can update later if desired. |
# [1.5.0](v1.4.5...v1.5.0) (2019-09-30) ### Features * add support for standalone mode (default in development) ([#70](#70)) ([485b6da](485b6da))
馃帀 This PR is included in version 1.5.0 馃帀 The release is available on: Your semantic-release bot 馃摝馃殌 |
Sorry for the late reply, I was focusing on the Select and missed the notification.
I think we probably have different workflows in mind. The way I was envisioning it you'd always retain the ability to point it to a different backend. With the base_url being a way to supply a default. So if I understand correctly, you're aiming to have the standalone flag allow for entering a url if base_url isn't set, and if base_url is set to hide the input and point to that server, right? With the ultimate goal being to not use base_url at all. My suggestion was mostly for convenience, so it's not critical. The way I envisioned it, it would allow for us to deploy an app to netlify, point it to, say the debug backend by default, but still allow devs to point it at another backend if they want to. One thing I'm wondering while typing this, if we're intending to not set a default base url, does that also mean that you're not intending to ever expose the choose a server input for apps shipped with core? (Since we're then not able to set a default and it doesn't seem nice to ask users of those apps to know and enter the backend url.) |
@ismay no worries! Yeah, that's the idea. Basically, there are 3 situations where this comes into play:
|
I see, yeah that makes sense. Thanks for explaining! |
This is a pretty powerful feature that was impressively easy to implement in the platform 馃憤
This does three things:
yarn start
馃檶. The specified server URL is saved tolocalStorage
, so it's also stickly.d2.config.js
or with the--standalone
flag, which preserves this behavior in the production built artifact. This allows, for example, netlify deployments to also switch between backends (if desired).PUBLIC_URL
to.
in production builds, andDHIS2_BASE_URL
to../../..
, or just..
if the app is configured as a coreApp with the newd2.config.js
setting.One goal of this change is to remove the need to specify an environment variable at all in most cases - you either use the "standalone" version in development or you use the standard, automatic
..[/../..]
provided for you in production. The env var can still be used to override these settings, but shouldn't be necessary except in crazy edge cases.Two improvements for the future:
login.action
we use to set the cookie always redirects to another page and the fetch errors out.localStorage
, the app will startup logged in. You then have to logout before being able to select another server (probably ok) but this is a bit clunky because the logout link redirects to the server in question.