Skip to content

Commit

Permalink
[frontend] Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kedae committed Nov 28, 2023
1 parent 0ccd460 commit afebe21
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
7 changes: 7 additions & 0 deletions opencti-platform/opencti-front/src/components/Theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ declare module '@mui/material/Button' {
}
}

declare module '@mui/material/Button' {
interface ChipPropsColorOverrides {
ee: true
}
}

declare module '@mui/material/SvgIcon' {
interface SvgIconPropsColorOverrides {
ee: true
Expand All @@ -26,6 +32,7 @@ interface ExtendedColor extends PaletteColorOptions {
text: Partial<TypeText>
mode: PaletteMode
background: string
contrastText: string
}

interface ExtendedBackground extends TypeBackground {
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/src/components/ThemeDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const ThemeDark = (
ee: {
main: EE_COLOR,
background: hexToRGB(EE_COLOR, 0.3),
contrastText: '#ffffff',
},
background: {
default: background || THEME_DARK_DEFAULT_BACKGROUND,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ThemeLight = (
ee: {
main: EE_COLOR,
background: hexToRGB(EE_COLOR, 0.3),
contrastText: '#ffffff',
},
background: {
default: background || '#f3f6f9',
Expand Down
71 changes: 39 additions & 32 deletions opencti-platform/opencti-front/src/private/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StyledEngineProvider } from '@mui/material/styles';
import React, { FunctionComponent } from 'react';
import { graphql, PreloadedQuery, usePreloadedQuery } from 'react-relay';
import { graphql, PreloadedQuery, useFragment, usePreloadedQuery } from 'react-relay';
import { AnalyticsProvider } from 'use-analytics';
import Analytics from 'analytics';
import { ConnectedIntlProvider } from '../components/AppIntlProvider';
Expand All @@ -16,6 +16,41 @@ import useQueryLoading from '../utils/hooks/useQueryLoading';
import Loader from '../components/Loader';
import generateAnalyticsConfig from './Analytics';

const rootSettingsFragment = graphql`
fragment RootSettings on Settings {
id
platform_demo
platform_banner_text
platform_user_statuses {
status
message
}
platform_banner_level
platform_map_tile_server_dark
platform_map_tile_server_light
platform_theme
platform_whitemark
platform_session_idle_timeout
platform_session_timeout
platform_feature_flags {
id
enable
}
platform_modules {
id
enable
running
warning
}
enterprise_edition
...AppThemeProvider_settings
...AppIntlProvider_settings
...PasswordPolicies
...Policies
analytics_google_analytics_v4
}
`;

const rootPrivateQuery = graphql`
query RootPrivateQuery {
me {
Expand Down Expand Up @@ -62,36 +97,7 @@ const rootPrivateQuery = graphql`
}
}
settings {
id
platform_demo
platform_banner_text
platform_user_statuses {
status
message
}
platform_banner_level
platform_map_tile_server_dark
platform_map_tile_server_light
platform_theme
platform_whitemark
platform_session_idle_timeout
platform_session_timeout
platform_feature_flags {
id
enable
}
platform_modules {
id
enable
running
warning
}
enterprise_edition
...AppThemeProvider_settings
...AppIntlProvider_settings
...PasswordPolicies
...Policies
analytics_google_analytics_v4
...RootSettings
}
about {
version
Expand Down Expand Up @@ -170,7 +176,8 @@ interface RootComponentProps {

const RootComponent: FunctionComponent<RootComponentProps> = ({ queryRef }) => {
const queryData = usePreloadedQuery(rootPrivateQuery, queryRef);
const { me, settings, entitySettings, schemaSCOs, schemaSDOs, schemaSMOs, schemaSROs, schemaRelationsTypesMapping, schemaRelationsRefTypesMapping } = queryData;
const { me, settings: settingsFragment, entitySettings, schemaSCOs, schemaSDOs, schemaSMOs, schemaSROs, schemaRelationsTypesMapping, schemaRelationsRefTypesMapping } = queryData;
const settings = useFragment(rootSettingsFragment, settingsFragment);
const schema = {
scos: schemaSCOs.edges.map((sco) => sco.node),
sdos: schemaSDOs.edges.map((sco) => sco.node),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EETooltip = ({ children, title }: { children: ReactElement, title?: string
}
return (
<>
<Tooltip title={t('You need to activate OpenCTI enterprise edition to use this feature.')}>
<Tooltip title={title ? t(title) : undefined}>
<span onClick={(e) => {
setFeedbackCreation(true);
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const EnterpriseEditionAgreementMutationFieldPatch = graphql`
settingsEdit(id: $id) {
fieldPatch(input: $input) {
id
...RootSettings
}
}
}`;
Expand All @@ -42,9 +43,6 @@ const EnterpriseEditionAgreement: FunctionComponent<EnterpriseEditionAgreementPr
value: now(),
},
},
onCompleted: () => {
window.location.reload();
},
});
onClose();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ const Settings = () => {
: t('Community Edition (CC)')
}
color={
isEnterpriseEdition ? 'success' : 'warning'
isEnterpriseEdition ? 'ee' : 'warning'
}
style={{ borderRadius: 5 }}
/>
Expand Down

0 comments on commit afebe21

Please sign in to comment.