Skip to content

Commit

Permalink
Merge branch 'Aiven-Open:main' into 2001-use-id-instead-of-name-for-q…
Browse files Browse the repository at this point in the history
…uerying-teams
  • Loading branch information
MovieTone authored Jan 11, 2024
2 parents c696919 + deb1c31 commit dcca327
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
12 changes: 9 additions & 3 deletions coral/src/app/components/AsyncNativeSelectWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NativeSelect, NativeSelectProps, useToast } from "@aivenio/aquarium";
import { isValidElement, ReactElement, ReactNode, useEffect } from "react";
import { parseErrorMsg } from "src/services/mutation-utils";
import { isDevMode } from "src/services/is-dev-mode";

function isNativeSelectComponent(
child: ReactNode
Expand Down Expand Up @@ -39,9 +40,14 @@ function AsyncNativeSelectWrapper(props: AsyncNativeSelectWrapperProps) {
// <NativeSelect> as a child component
useEffect(() => {
if (!isNativeSelectComponent(children)) {
throw new Error(
"Invalid child component. `AsyncNativeSelectWrapper` only accepts `NativeSelect` as a child."
);
const errorMessage =
"Invalid child component. `AsyncNativeSelectWrapper` only accepts `NativeSelect` as a child.";

if (isDevMode()) {
throw new Error(errorMessage);
} else {
console.error(errorMessage);
}
}
}, [children]);

Expand Down
3 changes: 2 additions & 1 deletion coral/src/app/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { AuthProvider } from "src/app/context-provider/AuthProvider";
import { BasePage } from "src/app/layout/page/BasePage";
// https://github.com/microsoft/monaco-editor/tree/main/samples/browser-esm-vite-react
import "/src/services/configure-monaco-editor";
import { isDevMode } from "src/services/is-dev-mode";

const DEV_MODE = import.meta.env.DEV;
const DEV_MODE = isDevMode();

const root = createRoot(document.getElementById("root") as HTMLElement);

Expand Down
5 changes: 5 additions & 0 deletions coral/src/services/is-dev-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function isDevMode() {
return import.meta.env.DEV;
}

export { isDevMode };
4 changes: 4 additions & 0 deletions coral/test-setup/setup-files-after-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ Object.defineProperty(global, "crypto", {

process.env.API_BASE_URL = "http://localhost:8080";
process.env.FEATURE_FLAG_TOPIC_REQUEST = "true";

jest.mock("src/services/is-dev-mode", () => ({
isDevMode: () => true,
}));

0 comments on commit dcca327

Please sign in to comment.