Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.

KIALI-2426 Get serverConfig from static env.js#1012

Closed
jotak wants to merge 2 commits intokiali:masterfrom
jotak:kiali-2426
Closed

KIALI-2426 Get serverConfig from static env.js#1012
jotak wants to merge 2 commits intokiali:masterfrom
jotak:kiali-2426

Conversation

@jotak
Copy link
Copy Markdown
Contributor

@jotak jotak commented Feb 21, 2019

serverConfig is removed from redux (which makes a lot of changes) and used instead as a standard constant.
This constant is written in 'window' object, in env.js, by the server. File is imported in index.html as static js.

Valid durations are now computed statically once for all.
Also, window.WEB_ROOT is now window.serverConfig.webRoot

JIRA: https://issues.jboss.org/browse/KIALI-2426
backend PR: kiali/kiali#863

@jotak jotak added the requires server PR A PR sent to the frontend kiali/kiali-ui requires changes on backend kiali/kiali label Feb 21, 2019
@jotak jotak force-pushed the kiali-2426 branch 2 times, most recently from 2516fce to 6834173 Compare February 21, 2019 12:40
}
};

const tmpConfig: ServerConfig = process.env.TEST_RUNNER
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note, I'm rewriting here for tests what is basically the content of env.js ... if someone has a better solution, I don't know how I could make jest tests load "/public/env.js" as a pre-requisite.

Copy link
Copy Markdown
Contributor

@israel-hdez israel-hdez left a comment

Choose a reason for hiding this comment

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

I just quickly checked. It looks good, but I'll let @jshaughn to do final approval.

label={String(validDurations[validDuration])}
options={validDurations}
handleSelect={key => this.props.setDuration(Number(key))}
value={this.props.duration}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am more comfortable using the validDuration. It' at least, was preventing errors when kiali pages are bookmarked. But this is minor. I won't complain if it's merged as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see, ok, I'll put it back

Copy link
Copy Markdown
Contributor Author

@jotak jotak Feb 22, 2019

Choose a reason for hiding this comment

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

Looking at that more closely, I'm not sure it's really recommended to change duration in "render" like that. It would mean that, if I set an incorrect value from the URL, the dropdown will show something different that what is actually used to perform the prometheus queries. Which could really be misleading.

Or we would have to make a broader refactor to validate durations not on rendering, but on URL parsing.

If we keep without validating the duration from URL, it doesn't work too bad: metrics are fetched using that "custom" time, which works, the UI just shows an empty dropdown, but it's still functional and the list of options is there to allow to switch to a "recognized" duration. I think that's better because we're not like "cheating" with the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, you are right in that it's better a layer of URL validation. I think that's under the scope of this Jira: https://issues.jboss.org/browse/KIALI-420

In the meantime, I think it's not bad to do that here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, so moving this validation to URL parsing : see commit 914d7a2

So this is removed from redux (lot of changes) and used instead as a standard constant.
This constant is written in 'window' object, in env.js, by the server. File is imported in index.html as static js.

Valid durations are now computed statically once for all.
While adding functions in HistoryManager to validate URL, taking that opportunity to do some refactoring here:
- Graph components were calling functions from ListPageHelper, which it isn't supposed to do, so moving these functions to HistoryManager
- Rename enum URLParams => URLParam
- More homogene usage of "undefined" instead of "null" in getting URL params
Copy link
Copy Markdown
Contributor

@jshaughn jshaughn left a comment

Choose a reason for hiding this comment

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

@jotak, see kiali/kiali#863 (comment) before merging. Although you must also resolve conflicts.

@jshaughn jshaughn added the do not merge A PR is not ready to merge label Feb 28, 2019
@jotak
Copy link
Copy Markdown
Contributor Author

jotak commented Mar 1, 2019

closing in favor of KIALI-2479

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

do not merge A PR is not ready to merge requires server PR A PR sent to the frontend kiali/kiali-ui requires changes on backend kiali/kiali

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants