Skip to content
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

chore: make environment adaptor globally available #855

Merged
merged 4 commits into from
Oct 14, 2021

Conversation

josephaxisa
Copy link
Contributor

This eliminates the need for the envAdaptor context and paves the way for envAdaptor usage in sagas

- eliminates the need for the envAdaptor context
- Paves the way for envAdaptor usage in sagas
@google-cla google-cla bot added the cla: yes label Oct 13, 2021
@github-actions
Copy link
Contributor

APIX Tests

0 files   -     1  0 suites   - 80   0s ⏱️ - 2m 28s
0 tests  - 320  0 ✔️  - 307  0 💤  - 13  0 ❌ ±0 
0 runs   - 336  0 ✔️  - 323  0 💤  - 13  0 ❌ ±0 

Results for commit 6a1973d. ± Comparison against base commit 474ee93.

This pull request removes 320 tests.
 DocTitle renders a heading with title prop content ‑  DocTitle renders a heading with title prop content
 MethodBadge renders with the provided verb ‑  MethodBadge renders with the provided verb
ApiSpecSelector it fires a SELECT_SPEC action when another spec is selected ‑ ApiSpecSelector it fires a SELECT_SPEC action when another spec is selected
ApiSpecSelector it lists all available specs ‑ ApiSpecSelector it lists all available specs
ApiSpecSelector the default spec is selected by default ‑ ApiSpecSelector the default spec is selected by default
CodeCopy displays code and clipboard UI ‑ CodeCopy displays code and clipboard UI
CodeDisplay it highlights text matching search pattern ‑ CodeDisplay it highlights text matching search pattern
CodeDisplay it syntax highlights ‑ CodeDisplay it syntax highlights
CodeDisplay utils it can syntax highlight all supported sdk langs ‑ CodeDisplay utils it can syntax highlight all supported sdk langs
CodeDisplay utils it highlights as markup for unsupported/undefined language ‑ CodeDisplay utils it highlights as markup for unsupported/undefined language
…

ensures registration happens after mounting, during the initialization phase, and not on every rerender
registerEnvAdaptor(envAdaptor)
setInitializing(false)

return () => unregisterEnvAdaptor()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is only needed in the dev portal because in the standalone mode unmounting means a reload happened. May also be applicable in extensions. In any case, better to have it than not to. @bryans99

Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to have in my opinion if only to future proof

@github-actions
Copy link
Contributor

APIX Tests

    1 files  ±0    80 suites  ±0   2m 24s ⏱️ -4s
320 tests ±0  307 ✔️ ±0  13 💤 ±0  0 ❌ ±0 
336 runs  ±0  323 ✔️ ±0  13 💤 ±0  0 ❌ ±0 

Results for commit 4374d97. ± Comparison against base commit 474ee93.

registerEnvAdaptor(envAdaptor)
setInitializing(false)

return () => unregisterEnvAdaptor()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to have in my opinion if only to future proof

@@ -71,10 +72,10 @@ const ApiExplorer: FC<ApiExplorerProps> = ({
declarationsLodeUrl = `${apixFilesHost}/declarationsIndex.json`,
headless = false,
}) => {
const [initializing, setInitializing] = useState(true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally this should be the redux.

I would expect an initializeExplorer action (perhaps loadExplorer instead), Consider sending the env as the property of the action (okay cos not storing in the reducer) and have a saga call the register. Have an unloadExplorer called when the component is unloaded.

The initialize/loadExplorer action gives us an opportunity to load the versions and initial spec as well.

Copy link
Contributor Author

@josephaxisa josephaxisa Oct 13, 2021

Choose a reason for hiding this comment

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

Good point. The PR following this addresses this.

packages/api-explorer/src/ApiExplorer.tsx Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

APIX Tests

    1 files  ±0    80 suites  ±0   2m 31s ⏱️ +3s
320 tests ±0  307 ✔️ ±0  13 💤 ±0  0 ❌ ±0 
336 runs  ±0  323 ✔️ ±0  13 💤 ±0  0 ❌ ±0 

Results for commit 235c05b. ± Comparison against base commit 474ee93.

@jkaster
Copy link
Contributor

jkaster commented Oct 13, 2021

Is Bryn's feedback going to be address in a different PR, or will this PR be updated for it?

@josephaxisa
Copy link
Contributor Author

I addressed and resolved all comments already except for 1 which is part of a follow up PR.

@josephaxisa josephaxisa dismissed bryans99’s stale review October 13, 2021 19:05

The "initialization" status will be part of the next PR. All other feedback has been addressed.

Copy link
Contributor

@jkaster jkaster left a comment

Choose a reason for hiding this comment

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

Looks good for this PR

Copy link
Collaborator

@bryans99 bryans99 left a comment

Choose a reason for hiding this comment

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

LGTM aside from comment around Loader. That can be fixed in the future

>
<ErrorBoundary logError={envAdaptor.logError.bind(envAdaptor)}>
<EnvAdaptorContext.Provider value={{ envAdaptor }}>
{initializing ? (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry to jerk you around but I just realized that Loader instantiates its own version of component provider. What you had before was okay.

Having said that, I think there is opportunity to eliminate the need for ComponentsProvider in Loader at some point in the future so leave this as is.

Once redux in place, I think we can eliminate the need for the Loader in the StandaloneApiExplorer and ExtensionApiExplorer and push the logic down to here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for looking Bryn. I agree, let's leave the change in. I'll eliminate the use of Loader from the standalone and extension top level components once it's possible.

@josephaxisa josephaxisa merged commit 9a9d9fe into main Oct 14, 2021
@josephaxisa josephaxisa deleted the jax/global-env-adaptor branch October 14, 2021 09:04
@github-actions

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants