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

feature/refactor-environment #339

Conversation

BrianWhitneyAI
Copy link
Contributor

@BrianWhitneyAI BrianWhitneyAI commented Nov 20, 2024

The purpose of this PR is to refactor the base urls that we are saving as global variables into one variable that can be mapped to various Urls. A few things occurred during this refactor

  1. removed existing FileExplorerServiceBaseURl and AicsLoadBalancerBaseUrl in favor of Environment
  2. renamed locations that had baseUrl to FileExplorerServiceBaseURl
  3. removed unnecessary state changes in tests where one of the URLs was unused
  4. Added mappings for FES,MMS, and LoadBalancer to interaction.selectors.ts
  5. added MMS base Url to HttpServiceBase

@BrianWhitneyAI BrianWhitneyAI marked this pull request as ready for review November 20, 2024 00:10
Copy link
Contributor

@SeanLeRoy SeanLeRoy left a comment

Choose a reason for hiding this comment

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

I think an enum type could simplify a bit of this. Also, please please make sure none of the unit tests actually make network calls to FES that would be bad

@@ -39,15 +39,11 @@ interface AppProps {
// Localhost: "https://localhost:9081"
// Stage: "http://stg-aics-api.corp.alleninstitute.org"
// From the web (behind load balancer): "/"
aicsLoadBalancerBaseUrl?: string;
fileExplorerServiceBaseUrl?: string;
environment?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use the enum as the type value here (Environment)

Suggested change
environment?: string;
environment?: Environment;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 07a2715

STAGING = "http://stg-aics.corp.alleninstitute.org",
PRODUCTION = "http://aics.corp.alleninstitute.org",
}
export const Environment = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be better as an enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 07a2715

packages/core/constants/index.ts Outdated Show resolved Hide resolved
applicationVersion?: string;
baseUrl?: string | keyof typeof FileExplorerServiceBaseUrl;
fileExplorerServiceBaseUrl?: string | keyof typeof FESBaseUrlMap;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see it is used here. You can use an enum type here to avoid having to do this complicated typing once you convert FESBaseUrlMap to an enum

Ex.

Suggested change
fileExplorerServiceBaseUrl?: string | keyof typeof FESBaseUrlMap;
fileExplorerServiceBaseUrl?: FESEnvironmentSpecificBaseUrl;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 07a2715

import ExecutionEnvServiceNoop from "../../services/ExecutionEnvService/ExecutionEnvServiceNoop";
import { UserSelectedApplication } from "../../services/PersistentConfigService";
import NotificationServiceNoop from "../../services/NotificationService/NotificationServiceNoop";
import DatabaseServiceNoop from "../../services/DatabaseService/DatabaseServiceNoop";
import PublicDataset from "../../../web/src/entity/PublicDataset";

import { Environment } from "../../constants";
Copy link
Contributor

Choose a reason for hiding this comment

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

Strange import, combine into above list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in 07a2715

packages/core/state/interaction/reducer.ts Show resolved Hide resolved
Copy link

@kmitcham kmitcham left a comment

Choose a reason for hiding this comment

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

Looked at least internally self-consistent

Copy link
Contributor

@aswallace aswallace left a comment

Choose a reason for hiding this comment

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

agree with Sean's suggestions, otherwise lgtm

const fileService = new HttpFileService({
baseUrl,
fileExplorerServiceBaseUrl: fileExplorerServiceBaseUrl,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to be extra javascripty, this and line 189 could just be fileExplorerServiceBaseUrl,

Copy link
Contributor Author

@BrianWhitneyAI BrianWhitneyAI Nov 22, 2024

Choose a reason for hiding this comment

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

Is it bad to say I don't want to be? I kept moving around variables and stuff broke.

Copy link
Contributor

@aswallace aswallace Nov 22, 2024

Choose a reason for hiding this comment

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

fair enough! just noted since elsewhere in file sometimes (or used to?) use this pattern

packages/core/state/interaction/reducer.ts Outdated Show resolved Hide resolved
@BrianWhitneyAI
Copy link
Contributor Author

I came across a bug where we save the selected data source (or at least what one is checked) in the desktop app but when we refresh the datasource returns to "Production". Now that we have write requests this is dangerous. In this PR I added a persistent 'Environment' as to align with the checked box. (even through a cache clear)

@BrianWhitneyAI BrianWhitneyAI merged commit 390a804 into feature/copy-to-local-cache-request Nov 22, 2024
7 checks passed
@BrianWhitneyAI BrianWhitneyAI deleted the feature/refactor-environment branch November 22, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants