Skip to content
Snippets Groups Projects
Commit b370f5a8 authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

add prettier

parent 04714acb
No related branches found
No related tags found
1 merge request!23add prettier
Pipeline #86929 passed
Showing
with 16264 additions and 16218 deletions
module.exports = { module.exports = {
root: true, root: true,
extends: ['@orchestrator-ui/eslint-config-custom'], extends: [
'@orchestrator-ui/eslint-config-custom',
'plugin:prettier/recommended'
],
plugins: ['prettier'],
rules: {
'prettier/prettier': 'error',
},
}; };
...@@ -13,6 +13,7 @@ tsc_lint_and_test: ...@@ -13,6 +13,7 @@ tsc_lint_and_test:
script: script:
- npm ci - npm ci
- npm run tsc - npm run tsc
- npm run prettier:check
- npm run lint - npm run lint
- npm run test - npm run test
tags: tags:
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
echo "---------- Running TSC ----------" echo "---------- Running TSC ----------"
npm run tsc npm run tsc
echo "---------- Running Prettier ----------"
npm run prettier
echo "---------- Running Linter ----------" echo "---------- Running Linter ----------"
npm run lint npm run lint
......
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2
}
import React, { ReactElement } from 'react'; import { getAppLogoStyles } from '@/components/AppLogo/styles';
import { EuiText } from '@elastic/eui'; import { EuiText } from '@elastic/eui';
import { useOrchestratorTheme } from '@orchestrator-ui/orchestrator-ui-components'; import { useOrchestratorTheme } from '@orchestrator-ui/orchestrator-ui-components';
import React, { ReactElement } from 'react';
import { getAppLogoStyles } from '@/components/AppLogo/styles';
export function getAppLogo(): ReactElement { export function getAppLogo(): ReactElement {
const { logoStyle } = getAppLogoStyles(); const { logoStyle } = getAppLogoStyles();
const AppLogo = () => { const AppLogo = () => {
const { theme } = useOrchestratorTheme(); const { theme } = useOrchestratorTheme();
return ( return (
<div css={logoStyle}> <div css={logoStyle}>
<EuiText color={theme.colors.emptyShade} size="xs"> <EuiText color={theme.colors.emptyShade} size="xs">
Workflow Workflow
</EuiText> </EuiText>
<EuiText color={theme.colors.emptyShade} size="xs"> <EuiText color={theme.colors.emptyShade} size="xs">
Orchestrator Orchestrator
</EuiText> </EuiText>
</div> </div>
); );
}; };
return <AppLogo />; return <AppLogo />;
} }
import { css } from '@emotion/css'; import { css } from '@emotion/css';
export const getAppLogoStyles = () => { export const getAppLogoStyles = () => {
const logoStyle = css({ const logoStyle = css({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}); });
return { logoStyle }; return { logoStyle };
}; };
import process from "process";
import { import {
Environment, Environment,
OrchestratorConfig, OrchestratorConfig,
} from "@orchestrator-ui/orchestrator-ui-components"; } from '@orchestrator-ui/orchestrator-ui-components';
import process from 'process';
export const DEFAULT_GRAPHQL_CORE_ENDPOINT = export const DEFAULT_GRAPHQL_CORE_ENDPOINT =
"http://localhost:8080/api/graphql"; 'http://localhost:8080/api/graphql';
export const DEFAULT_ORCHESTRATOR_API_BASE_URL = "http://localhost:8080/api"; export const DEFAULT_ORCHESTRATOR_API_BASE_URL = 'http://localhost:8080/api';
export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = "ws://localhost:8080"; export const DEFAULT_ORCHESTRATOR_WEBSOCKET_URL = 'ws://localhost:8080';
export const ENGINE_STATUS_ENDPOINT = "/settings/status"; export const ENGINE_STATUS_ENDPOINT = '/settings/status';
export const PROCESS_STATUS_COUNTS_ENDPOINT = "/processes/status-counts"; export const PROCESS_STATUS_COUNTS_ENDPOINT = '/processes/status-counts';
export const PROCESSES_ENDPOINT = "/processes"; export const PROCESSES_ENDPOINT = '/processes';
export const SUBSCRIPTION_ACTIONS_ENDPOINT = "/subscriptions/workflows"; export const SUBSCRIPTION_ACTIONS_ENDPOINT = '/subscriptions/workflows';
export const SUBSCRIPTION_PROCESSES_ENDPOINT = export const SUBSCRIPTION_PROCESSES_ENDPOINT =
"/processes/process-subscriptions-by-subscription-id"; '/processes/process-subscriptions-by-subscription-id';
export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = "http://localhost:8080"; export const DEFAULT_WORKFLOW_INFORMATION_LINK_URL = 'http://localhost:8080';
export const getInitialOrchestratorConfig = (): OrchestratorConfig => { export const getInitialOrchestratorConfig = (): OrchestratorConfig => {
const orchestratorGraphqlBaseUrl = const orchestratorGraphqlBaseUrl =
process.env.ORCHESTRATOR_GRAPHQL_HOST && process.env.ORCHESTRATOR_GRAPHQL_HOST &&
process.env.ORCHESTRATOR_GRAPHQL_PATH process.env.ORCHESTRATOR_GRAPHQL_PATH
? `${process.env.ORCHESTRATOR_GRAPHQL_HOST}${process.env.ORCHESTRATOR_GRAPHQL_PATH}` ? `${process.env.ORCHESTRATOR_GRAPHQL_HOST}${process.env.ORCHESTRATOR_GRAPHQL_PATH}`
: DEFAULT_GRAPHQL_CORE_ENDPOINT; : DEFAULT_GRAPHQL_CORE_ENDPOINT;
const orchestratorApiBaseUrl = const orchestratorApiBaseUrl =
process.env.ORCHESTRATOR_API_HOST && process.env.ORCHESTRATOR_API_PATH process.env.ORCHESTRATOR_API_HOST && process.env.ORCHESTRATOR_API_PATH
? `${process.env.ORCHESTRATOR_API_HOST}${process.env.ORCHESTRATOR_API_PATH}` ? `${process.env.ORCHESTRATOR_API_HOST}${process.env.ORCHESTRATOR_API_PATH}`
: DEFAULT_ORCHESTRATOR_API_BASE_URL; : DEFAULT_ORCHESTRATOR_API_BASE_URL;
return { return {
orchestratorApiBaseUrl, orchestratorApiBaseUrl,
engineStatusEndpoint: orchestratorApiBaseUrl + ENGINE_STATUS_ENDPOINT, engineStatusEndpoint: orchestratorApiBaseUrl + ENGINE_STATUS_ENDPOINT,
graphqlEndpointCore: orchestratorGraphqlBaseUrl, graphqlEndpointCore: orchestratorGraphqlBaseUrl,
processesEndpoint: orchestratorApiBaseUrl + PROCESSES_ENDPOINT, processesEndpoint: orchestratorApiBaseUrl + PROCESSES_ENDPOINT,
environmentName: environmentName: process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT,
process.env.ENVIRONMENT_NAME ?? Environment.DEVELOPMENT, // subscriptionActionsEndpoint: orchestratorApiBaseUrl + SUBSCRIPTION_ACTIONS_ENDPOINT,
// subscriptionActionsEndpoint: orchestratorApiBaseUrl + SUBSCRIPTION_ACTIONS_ENDPOINT, subscriptionProcessesEndpoint:
subscriptionProcessesEndpoint: orchestratorApiBaseUrl + SUBSCRIPTION_PROCESSES_ENDPOINT,
orchestratorApiBaseUrl + SUBSCRIPTION_PROCESSES_ENDPOINT, orchestratorWebsocketUrl:
orchestratorWebsocketUrl: process.env.ORCHESTRATOR_WEBSOCKET_URL ||
process.env.ORCHESTRATOR_WEBSOCKET_URL || DEFAULT_ORCHESTRATOR_WEBSOCKET_URL,
DEFAULT_ORCHESTRATOR_WEBSOCKET_URL, authActive: process.env.AUTH_ACTIVE?.toLowerCase() != 'false',
authActive: process.env.AUTH_ACTIVE?.toLowerCase() != "false", useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === 'true',
useWebSockets: process.env.USE_WEB_SOCKETS?.toLowerCase() === "true", useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === 'true',
useThemeToggle: process.env.USE_THEME_TOGGLE?.toLowerCase() === "true", workflowInformationLinkUrl:
workflowInformationLinkUrl: process.env.WORKFLOW_INFORMATION_LINK_URL ??
process.env.WORKFLOW_INFORMATION_LINK_URL ?? DEFAULT_WORKFLOW_INFORMATION_LINK_URL,
DEFAULT_WORKFLOW_INFORMATION_LINK_URL, showWorkflowInformationLink:
showWorkflowInformationLink: process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() === 'true',
process.env.SHOW_WORKFLOW_INFORMATION_LINK?.toLowerCase() === };
"true",
};
}; };
This diff is collapsed.
{ {
"name": "wfo-ui", "name": "wfo-ui",
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"test": "jest --passWithNoTests", "test": "jest --passWithNoTests",
"tsc": "tsc --noEmit", "tsc": "tsc --noEmit",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint",
"prepare": "husky" "prettier": "prettier --write \"{components,configuration,contexts,pages,translations,public}/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
"prettier:check": "prettier --check \"{components,configuration,contexts,pages,translations,public}/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
"prepare": "husky install"
},
"dependencies": {
"@elastic/datemath": "^5.0.3",
"@elastic/eui": "^93.1.1",
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.1",
"@orchestrator-ui/orchestrator-ui-components": "1.20.0",
"@reduxjs/toolkit": "^2.0.1",
"moment": "^2.29.4",
"next": "^14.0.4",
"next-auth": "^4.24.5",
"next-intl": "^3.4.1",
"next-query-params": "^5.0.0",
"process": "0.11.10",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-no-ssr": "^1.1.0",
"react-query": "3.39.3",
"react-redux": "^9.1.0",
"use-query-params": "2.2.1"
},
"devDependencies": {
"@orchestrator-ui/eslint-config-custom": "*",
"@orchestrator-ui/jest-config": "*",
"@orchestrator-ui/tsconfig": "*",
"@testing-library/jest-dom": "^6.2.0",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@types/react-no-ssr": "^1.1.7",
"esbuild-jest": "^0.5.0",
"husky": "^9.0.11",
"typescript": "^5.3.2",
"prettier": "^2.3.2",
"eslint-plugin-prettier": "^3.4.0",
"eslint-config-prettier": "^8.3.0"
},
"overrides": {
"@elastic/eui": {
"typescript": "^5.3.2"
}, },
"dependencies": { "react-no-ssr": {
"@elastic/datemath": "^5.0.3", "react": "^18.2.0"
"@elastic/eui": "^93.1.1",
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.1",
"@orchestrator-ui/orchestrator-ui-components": "1.20.0",
"@reduxjs/toolkit": "^2.0.1",
"moment": "^2.29.4",
"next": "^14.0.4",
"next-auth": "^4.24.5",
"next-intl": "^3.4.1",
"next-query-params": "^5.0.0",
"process": "0.11.10",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-no-ssr": "^1.1.0",
"react-query": "3.39.3",
"react-redux": "^9.1.0",
"use-query-params": "2.2.1"
},
"devDependencies": {
"@orchestrator-ui/eslint-config-custom": "*",
"@orchestrator-ui/jest-config": "*",
"@orchestrator-ui/tsconfig": "*",
"@testing-library/jest-dom": "^6.2.0",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@types/react-no-ssr": "^1.1.7",
"esbuild-jest": "^0.5.0",
"husky": "^9.0.11",
"typescript": "^5.3.2"
},
"overrides": {
"@elastic/eui": {
"typescript": "^5.3.2"
},
"react-no-ssr": {
"react": "^18.2.0"
}
} }
}
} }
import '../font/inter.css';
import { getAppLogo } from '@/components/AppLogo/AppLogo';
import { getInitialOrchestratorConfig } from '@/configuration';
import { TranslationsProvider } from '@/translations/translationsProvider';
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
import '@elastic/eui/dist/eui_theme_dark.min.css';
import '@elastic/eui/dist/eui_theme_light.min.css';
import {
ApiClientContextProvider,
ColorModes,
ConfirmationDialogContextWrapper,
OrchestratorConfig,
OrchestratorConfigProvider,
StoreProvider,
WfoAuth,
WfoErrorBoundary,
WfoPageTemplate,
WfoToastsList,
defaultOrchestratorTheme,
} from '@orchestrator-ui/orchestrator-ui-components';
import { SessionProvider } from 'next-auth/react';
import { NextAdapter } from 'next-query-params';
import App, { AppContext, AppInitialProps, AppProps } from 'next/app';
import Head from 'next/head';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import NoSSR from 'react-no-ssr'; import NoSSR from 'react-no-ssr';
import { QueryClient, QueryClientProvider } from 'react-query'; import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools'; import { ReactQueryDevtools } from 'react-query/devtools';
import { QueryClientConfig } from 'react-query/types/core/types'; import { QueryClientConfig } from 'react-query/types/core/types';
import { SessionProvider } from 'next-auth/react';
import { NextAdapter } from 'next-query-params';
import App, { AppContext, AppInitialProps, AppProps } from 'next/app';
import Head from 'next/head';
import { QueryParamProvider } from 'use-query-params'; import { QueryParamProvider } from 'use-query-params';
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
import '@elastic/eui/dist/eui_theme_dark.min.css';
import '@elastic/eui/dist/eui_theme_light.min.css';
import {
ApiClientContextProvider,
ColorModes,
ConfirmationDialogContextWrapper,
OrchestratorConfig,
OrchestratorConfigProvider,
StoreProvider,
WfoAuth,
WfoErrorBoundary,
WfoPageTemplate,
WfoToastsList,
defaultOrchestratorTheme,
} from '@orchestrator-ui/orchestrator-ui-components';
import { getAppLogo } from '@/components/AppLogo/AppLogo';
import { getInitialOrchestratorConfig } from '@/configuration';
import { TranslationsProvider } from '@/translations/translationsProvider';
import '../font/inter.css';
type AppOwnProps = { orchestratorConfig: OrchestratorConfig }; type AppOwnProps = { orchestratorConfig: OrchestratorConfig };
const queryClientConfig: QueryClientConfig = { const queryClientConfig: QueryClientConfig = {
defaultOptions: { defaultOptions: {
queries: { queries: {
cacheTime: 5 * 1000, cacheTime: 5 * 1000,
refetchOnWindowFocus: true, refetchOnWindowFocus: true,
},
}, },
},
}; };
function CustomApp({ function CustomApp({
Component, Component,
pageProps, pageProps,
orchestratorConfig, orchestratorConfig,
}: AppProps & AppOwnProps) { }: AppProps & AppOwnProps) {
const [queryClient] = useState(() => new QueryClient(queryClientConfig)); const [queryClient] = useState(() => new QueryClient(queryClientConfig));
const [themeMode, setThemeMode] = useState<EuiThemeColorMode>( const [themeMode, setThemeMode] = useState<EuiThemeColorMode>(
ColorModes.LIGHT, ColorModes.LIGHT,
); );
const handleThemeSwitch = (newThemeMode: EuiThemeColorMode) => { const handleThemeSwitch = (newThemeMode: EuiThemeColorMode) => {
setThemeMode(newThemeMode); setThemeMode(newThemeMode);
localStorage.setItem('themeMode', newThemeMode); localStorage.setItem('themeMode', newThemeMode);
}; };
useEffect(() => { useEffect(() => {
// Initialize theme mode from localStorage or set it to 'light' if not present // Initialize theme mode from localStorage or set it to 'light' if not present
const storedTheme = localStorage.getItem('themeMode'); const storedTheme = localStorage.getItem('themeMode');
if ( if (
!storedTheme || !storedTheme ||
(storedTheme !== ColorModes.LIGHT && (storedTheme !== ColorModes.LIGHT && storedTheme !== ColorModes.DARK)
storedTheme !== ColorModes.DARK) ) {
) { handleThemeSwitch(ColorModes.LIGHT);
handleThemeSwitch(ColorModes.LIGHT); }
} }, []);
}, []);
return ( return (
<WfoErrorBoundary> <WfoErrorBoundary>
<OrchestratorConfigProvider <OrchestratorConfigProvider
initialOrchestratorConfig={orchestratorConfig} initialOrchestratorConfig={orchestratorConfig}
> >
<StoreProvider initialOrchestratorConfig={orchestratorConfig}> <StoreProvider initialOrchestratorConfig={orchestratorConfig}>
<SessionProvider session={pageProps.session}> <SessionProvider session={pageProps.session}>
<NoSSR> <NoSSR>
<WfoAuth> <WfoAuth>
<EuiProvider <EuiProvider
colorMode={themeMode} colorMode={themeMode}
modify={defaultOrchestratorTheme} modify={defaultOrchestratorTheme}
> >
<ApiClientContextProvider> <ApiClientContextProvider>
<QueryClientProvider <QueryClientProvider
client={queryClient} client={queryClient}
contextSharing={true} contextSharing={true}
> >
<TranslationsProvider> <TranslationsProvider>
<Head> <Head>
<link <link rel="icon" href="/favicon.png" />
rel="icon" <title>Welcome to example-orchestrator-ui!</title>
href="/favicon.png" </Head>
/> <main className="app">
<title> <ConfirmationDialogContextWrapper>
Welcome to <WfoPageTemplate
example-orchestrator-ui! getAppLogo={getAppLogo}
</title> onThemeSwitch={handleThemeSwitch}
</Head> >
<main className="app"> <QueryParamProvider
<ConfirmationDialogContextWrapper> adapter={NextAdapter}
<WfoPageTemplate options={{
getAppLogo={ removeDefaultsFromUrl: false,
getAppLogo enableBatching: true,
} }}
onThemeSwitch={ >
handleThemeSwitch <Component {...pageProps} />
} </QueryParamProvider>
> </WfoPageTemplate>
<QueryParamProvider <WfoToastsList />
adapter={ </ConfirmationDialogContextWrapper>
NextAdapter <ReactQueryDevtools initialIsOpen={false} />
} </main>
options={{ </TranslationsProvider>
removeDefaultsFromUrl: </QueryClientProvider>
false, </ApiClientContextProvider>
enableBatching: </EuiProvider>
true, </WfoAuth>
}} </NoSSR>
> </SessionProvider>
<Component </StoreProvider>
{...pageProps} </OrchestratorConfigProvider>
/> </WfoErrorBoundary>
</QueryParamProvider> );
</WfoPageTemplate>
<WfoToastsList />
</ConfirmationDialogContextWrapper>
<ReactQueryDevtools
initialIsOpen={false}
/>
</main>
</TranslationsProvider>
</QueryClientProvider>
</ApiClientContextProvider>
</EuiProvider>
</WfoAuth>
</NoSSR>
</SessionProvider>
</StoreProvider>
</OrchestratorConfigProvider>
</WfoErrorBoundary>
);
} }
CustomApp.getInitialProps = async ( CustomApp.getInitialProps = async (
context: AppContext, context: AppContext,
): Promise<AppOwnProps & AppInitialProps> => { ): Promise<AppOwnProps & AppInitialProps> => {
const ctx = await App.getInitialProps(context); const ctx = await App.getInitialProps(context);
return { return {
...ctx, ...ctx,
orchestratorConfig: getInitialOrchestratorConfig(), orchestratorConfig: getInitialOrchestratorConfig(),
}; };
}; };
export default CustomApp; export default CustomApp;
import {
WfoSession,
WfoUserProfile,
} from '@orchestrator-ui/orchestrator-ui-components';
import NextAuth, { AuthOptions } from 'next-auth'; import NextAuth, { AuthOptions } from 'next-auth';
import { JWT } from 'next-auth/jwt'; import { JWT } from 'next-auth/jwt';
import { OAuthConfig } from 'next-auth/providers'; import { OAuthConfig } from 'next-auth/providers';
import {
WfoSession,
WfoUserProfile,
} from '@orchestrator-ui/orchestrator-ui-components';
const token_endpoint_auth_method = process.env.NEXTAUTH_CLIENT_SECRET const token_endpoint_auth_method = process.env.NEXTAUTH_CLIENT_SECRET
? 'client_secret_basic' ? 'client_secret_basic'
: 'none'; : 'none';
const authActive = process.env.AUTH_ACTIVE?.toLowerCase() != 'false'; const authActive = process.env.AUTH_ACTIVE?.toLowerCase() != 'false';
const wfoProvider: OAuthConfig<WfoUserProfile> = { const wfoProvider: OAuthConfig<WfoUserProfile> = {
id: process.env.NEXTAUTH_ID || '', id: process.env.NEXTAUTH_ID || '',
name: process.env.NEXTAUTH_ID || '', name: process.env.NEXTAUTH_ID || '',
type: 'oauth', type: 'oauth',
clientId: process.env.NEXTAUTH_CLIENT_ID || '', clientId: process.env.NEXTAUTH_CLIENT_ID || '',
clientSecret: process.env.NEXTAUTH_CLIENT_SECRET || undefined, clientSecret: process.env.NEXTAUTH_CLIENT_SECRET || undefined,
wellKnown: wellKnown:
process.env.NEXTAUTH_WELL_KNOWN_OVERRIDE ?? process.env.NEXTAUTH_WELL_KNOWN_OVERRIDE ??
`${process.env.NEXTAUTH_ISSUER || ''}/.well-known/openid-configuration`, `${process.env.NEXTAUTH_ISSUER || ''}/.well-known/openid-configuration`,
authorization: { authorization: {
params: { params: {
scope: scope:
process.env.NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE ?? process.env.NEXTAUTH_AUTHORIZATION_SCOPE_OVERRIDE ?? 'openid profile',
'openid profile',
},
}, },
idToken: true, },
checks: ['pkce', 'state'], idToken: true,
userinfo: { checks: ['pkce', 'state'],
request: async (context) => { userinfo: {
const { client, tokens } = context; request: async (context) => {
const { client, tokens } = context;
if (!context.provider.wellKnown || !tokens.access_token) { if (!context.provider.wellKnown || !tokens.access_token) {
return {}; return {};
} }
return await client.userinfo(tokens.access_token); return await client.userinfo(tokens.access_token);
},
},
profile(profile) {
return {
id: profile.sub,
name: profile.name ?? profile.preferred_username,
email: profile.email,
};
},
client: {
token_endpoint_auth_method,
response_types: ['code'],
}, },
},
profile(profile) {
return {
id: profile.sub,
name: profile.name ?? profile.preferred_username,
email: profile.email,
};
},
client: {
token_endpoint_auth_method,
response_types: ['code'],
},
}; };
export const authOptions: AuthOptions = { export const authOptions: AuthOptions = {
providers: authActive ? [wfoProvider] : [], providers: authActive ? [wfoProvider] : [],
callbacks: { callbacks: {
async jwt({ token, account, profile }) { async jwt({ token, account, profile }) {
// The "account" is only available right after signing in -- adding useful data to the token // The "account" is only available right after signing in -- adding useful data to the token
if (account) { if (account) {
token.accessToken = account.access_token; token.accessToken = account.access_token;
token.profile = profile; token.profile = profile;
} }
return token; return token;
}, },
async session({ session, token }: { session: WfoSession; token: JWT }) { async session({ session, token }: { session: WfoSession; token: JWT }) {
// Assign data to the session to be available in the client through the useSession hook // Assign data to the session to be available in the client through the useSession hook
session.profile = token.profile as WfoUserProfile | undefined; session.profile = token.profile as WfoUserProfile | undefined;
session.accessToken = token.accessToken session.accessToken = token.accessToken ? String(token.accessToken) : '';
? String(token.accessToken)
: '';
return session; return session;
},
}, },
},
}; };
export default NextAuth(authOptions); export default NextAuth(authOptions);
import React from 'react';
import { EuiHorizontalRule, EuiPageHeader, EuiSpacer } from '@elastic/eui'; import { EuiHorizontalRule, EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { CreateForm } from '@orchestrator-ui/orchestrator-ui-components'; import { CreateForm } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export function FormsPage() { export function FormsPage() {
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
const handleSubmit = (userInputs: any) => { const handleSubmit = (userInputs: any) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Submitted: ', userInputs); console.log('Submitted: ', userInputs);
}; };
return ( return (
<> <>
<EuiPageHeader pageTitle="Form test" /> <EuiPageHeader pageTitle="Form test" />
<EuiHorizontalRule /> <EuiHorizontalRule />
<EuiSpacer /> <EuiSpacer />
<CreateForm <CreateForm formKey={'all_form_fields'} handleSubmit={handleSubmit} />
formKey={'all_form_fields'} <EuiSpacer />
handleSubmit={handleSubmit} </>
/> );
<EuiSpacer />
</>
);
} }
export default FormsPage; export default FormsPage;
import React from 'react';
import { useTranslations } from 'next-intl';
import { EuiPageHeader, EuiSpacer } from '@elastic/eui'; import { EuiPageHeader, EuiSpacer } from '@elastic/eui';
import { import {
WfoStartPage, WfoStartPage,
useWfoSession, useWfoSession,
} from '@orchestrator-ui/orchestrator-ui-components'; } from '@orchestrator-ui/orchestrator-ui-components';
import { useTranslations } from 'next-intl';
import React from 'react';
export function Index() { export function Index() {
const { session } = useWfoSession(); const { session } = useWfoSession();
const t = useTranslations('main'); const t = useTranslations('main');
const username = session?.user?.name || ''; const username = session?.user?.name || '';
return ( return (
<> <>
<EuiPageHeader pageTitle={`${t('welcome')} ${username}`} /> <EuiPageHeader pageTitle={`${t('welcome')} ${username}`} />
<EuiSpacer /> <EuiSpacer />
<WfoStartPage /> <WfoStartPage />
</> </>
); );
} }
export default Index; export default Index;
import React from 'react';
import { useRouter } from 'next/router';
import { import {
PolicyResource, PolicyResource,
WfoPageUnauthorized, WfoPageUnauthorized,
usePolicy, usePolicy,
} from '@orchestrator-ui/orchestrator-ui-components'; } from '@orchestrator-ui/orchestrator-ui-components';
import { useRouter } from 'next/router';
import React from 'react';
export const IndexPage = () => { export const IndexPage = () => {
const router = useRouter(); const router = useRouter();
const { isAllowed } = usePolicy(); const { isAllowed } = usePolicy();
if (!isAllowed(PolicyResource.NAVIGATION_METADATA)) { if (!isAllowed(PolicyResource.NAVIGATION_METADATA)) {
return <WfoPageUnauthorized />; return <WfoPageUnauthorized />;
} }
router.push('/metadata/products'); router.push('/metadata/products');
}; };
export default IndexPage; export default IndexPage;
import React from 'react';
import { WfoProductBlocksPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoProductBlocksPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export const ProductBlocksPage = () => <WfoProductBlocksPage />; export const ProductBlocksPage = () => <WfoProductBlocksPage />;
......
import React from 'react';
import { WfoProductsPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoProductsPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export const ProductsPage = () => <WfoProductsPage />; export const ProductsPage = () => <WfoProductsPage />;
......
import React from 'react';
import { WfoResourceTypesPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoResourceTypesPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export const ResourceTypesPage = () => <WfoResourceTypesPage />; export const ResourceTypesPage = () => <WfoResourceTypesPage />;
......
import React from 'react';
import { WfoTasksPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoTasksPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export const TasksPage = () => <WfoTasksPage />; export const TasksPage = () => <WfoTasksPage />;
......
import React from 'react';
import { WfoWorkflowsPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoWorkflowsPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export const WorkflowsPage = () => <WfoWorkflowsPage />; export const WorkflowsPage = () => <WfoWorkflowsPage />;
......
import React from 'react';
import { WfoSettingsPage } from '@orchestrator-ui/orchestrator-ui-components'; import { WfoSettingsPage } from '@orchestrator-ui/orchestrator-ui-components';
import React from 'react';
export function SettingsPage() { export function SettingsPage() {
return <WfoSettingsPage />; return <WfoSettingsPage />;
} }
export default SettingsPage; export default SettingsPage;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment