Skip to content

Commit

Permalink
Live Configurations (#782)
Browse files Browse the repository at this point in the history
* Create getLiveConfig request

* Created LiveConfigAppProvider component

* Added Live Configs in apps

* Remove automatic Drive App deploy

* Created Checkbox component

* Created TextField component

* Added interactive overlay and label to the Checkbox component

* Added description in the live config interface

* Added theme handling with Live Configs

* Added a no cache URL param in the API request

* Added additionalTasks in CaptureAppConfig

* Fix conflicts
  • Loading branch information
souyahia-monk authored Jun 10, 2024
1 parent b4dc81d commit be49e75
Show file tree
Hide file tree
Showing 70 changed files with 2,394 additions and 1,074 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/deploy-drive-app.yml

This file was deleted.

11 changes: 6 additions & 5 deletions apps/demo-app/.env-cmdrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"HTTPS": "true",
"ESLINT_NO_DEV_ERRORS": "true",
"REACT_APP_ENVIRONMENT": "local",
"REACT_APP_API_DOMAIN": "api.preview.monk.ai/v1",
"REACT_APP_LIVE_CONFIG_ID": "demo-app-development",
"REACT_APP_USE_LOCAL_CONFIG": "true",
"REACT_APP_AUTH_DOMAIN": "idp.preview.monk.ai",
"REACT_APP_AUTH_AUDIENCE": "https://api.monk.ai/v1/",
"REACT_APP_AUTH_CLIENT_ID": "O7geYcPM6zEJrHw0WvQVzSIzw4WzrAtH",
Expand All @@ -14,7 +15,7 @@
},
"development": {
"REACT_APP_ENVIRONMENT": "development",
"REACT_APP_API_DOMAIN": "api.preview.monk.ai/v1",
"REACT_APP_LIVE_CONFIG_ID": "demo-app-development",
"REACT_APP_AUTH_DOMAIN": "idp.preview.monk.ai",
"REACT_APP_AUTH_AUDIENCE": "https://api.monk.ai/v1/",
"REACT_APP_AUTH_CLIENT_ID": "O7geYcPM6zEJrHw0WvQVzSIzw4WzrAtH",
Expand All @@ -23,7 +24,7 @@
},
"staging": {
"REACT_APP_ENVIRONMENT": "staging",
"REACT_APP_API_DOMAIN": "api.preview.monk.ai/v1",
"REACT_APP_LIVE_CONFIG_ID": "demo-app-staging",
"REACT_APP_AUTH_DOMAIN": "idp.preview.monk.ai",
"REACT_APP_AUTH_AUDIENCE": "https://api.monk.ai/v1/",
"REACT_APP_AUTH_CLIENT_ID": "O7geYcPM6zEJrHw0WvQVzSIzw4WzrAtH",
Expand All @@ -32,7 +33,7 @@
},
"preview": {
"REACT_APP_ENVIRONMENT": "preview",
"REACT_APP_API_DOMAIN": "api.preview.monk.ai/v1",
"REACT_APP_LIVE_CONFIG_ID": "demo-app-preview",
"REACT_APP_AUTH_DOMAIN": "idp.preview.monk.ai",
"REACT_APP_AUTH_AUDIENCE": "https://api.monk.ai/v1/",
"REACT_APP_AUTH_CLIENT_ID": "O7geYcPM6zEJrHw0WvQVzSIzw4WzrAtH",
Expand All @@ -41,7 +42,7 @@
},
"backend-staging-qa": {
"REACT_APP_ENVIRONMENT": "backend-staging-qa",
"REACT_APP_API_DOMAIN": "api.staging.monk.ai/v1",
"REACT_APP_LIVE_CONFIG_ID": "demo-app-backend-staging-qa",
"REACT_APP_AUTH_DOMAIN": "idp.staging.monk.ai",
"REACT_APP_AUTH_AUDIENCE": "https://api.monk.ai/v1/",
"REACT_APP_AUTH_CLIENT_ID": "DAeZWqeeOfgItYBcQzFeFwSrlvmUdN7L",
Expand Down
23 changes: 15 additions & 8 deletions apps/demo-app/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { Outlet, useNavigate } from 'react-router-dom';
import { MonkAppStateProvider, MonkProvider, useMonkTheme } from '@monkvision/common';
import { getEnvOrThrow, MonkProvider } from '@monkvision/common';
import { useTranslation } from 'react-i18next';
import { LiveConfigAppProvider } from '@monkvision/common-ui-web';
import { CaptureAppConfig } from '@monkvision/types';
import { Page } from '../pages';
import { AppConfig } from '../config';
import * as config from '../local-config.json';
import { AppContainer } from './AppContainer';

const localConfig =
process.env['REACT_APP_USE_LOCAL_CONFIG'] === 'true' ? (config as CaptureAppConfig) : undefined;

export function App() {
const navigate = useNavigate();
const { i18n } = useTranslation();
const { rootStyles } = useMonkTheme();

return (
<MonkAppStateProvider
config={AppConfig}
<LiveConfigAppProvider
id={getEnvOrThrow('REACT_APP_LIVE_CONFIG_ID')}
localConfig={localConfig}
onFetchAuthToken={() => navigate(Page.CREATE_INSPECTION)}
onFetchLanguage={(lang) => i18n.changeLanguage(lang)}
lang={i18n.language}
>
<MonkProvider>
<div className='app-container' style={rootStyles}>
<AppContainer>
<Outlet />
</div>
</AppContainer>
</MonkProvider>
</MonkAppStateProvider>
</LiveConfigAppProvider>
);
}
22 changes: 22 additions & 0 deletions apps/demo-app/src/components/AppContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PropsWithChildren } from 'react';
import { MonkThemeProvider, useMonkAppState, useMonkTheme } from '@monkvision/common';

function RootStylesContainer({ children }: PropsWithChildren<unknown>) {
const { rootStyles } = useMonkTheme();

return (
<div className='app-container' style={rootStyles}>
{children}
</div>
);
}

export function AppContainer({ children }: PropsWithChildren<unknown>) {
const { config } = useMonkAppState();

return (
<MonkThemeProvider palette={config.palette}>
<RootStylesContainer>{children}</RootStylesContainer>
</MonkThemeProvider>
);
}
1 change: 1 addition & 0 deletions apps/demo-app/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './App';
export * from './AppRouter';
export * from './AppContainer';
187 changes: 0 additions & 187 deletions apps/demo-app/src/config.ts

This file was deleted.

6 changes: 2 additions & 4 deletions apps/demo-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ReactDOM from 'react-dom';
import { MonitoringProvider } from '@monkvision/monitoring';
import { AnalyticsProvider } from '@monkvision/analytics';
import { Auth0Provider } from '@auth0/auth0-react';
import { getEnvOrThrow, MonkThemeProvider } from '@monkvision/common';
import { getEnvOrThrow } from '@monkvision/common';
import { sentryMonitoringAdapter } from './sentry';
import { posthogAnalyticsAdapter } from './posthog';
import { AppRouter } from './components';
Expand All @@ -21,9 +21,7 @@ ReactDOM.render(
prompt: 'login',
}}
>
<MonkThemeProvider>
<AppRouter />
</MonkThemeProvider>
<AppRouter />
</Auth0Provider>
</AnalyticsProvider>
</MonitoringProvider>,
Expand Down
Loading

0 comments on commit be49e75

Please sign in to comment.