Skip to content

Commit

Permalink
[backend/frontend] Add EE identity support (#4765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kedae committed Nov 22, 2023
1 parent 901fb10 commit 9143ea0
Show file tree
Hide file tree
Showing 49 changed files with 927 additions and 557 deletions.
7 changes: 0 additions & 7 deletions opencti-platform/opencti-front/jsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ const ColorPickerField = (props) => {
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const id = open ? 'color-popover' : undefined;

const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};

const {
form: { setFieldValue, setTouched },
field: { name },
Expand Down Expand Up @@ -52,16 +51,17 @@ const ColorPickerField = (props) => {
},
[setTouched, onSubmit, name],
);
const handleChange = (color) => {
const handleChange = () => {
setTouched(true);
setFieldValue(name, color && color.hex ? color.hex : '');
setAnchorEl(null);
if (typeof onChange === 'function') {
onChange(name, color && color.hex ? color.hex : '');
onChange(name, meta.value || '');
}
if (typeof onSubmit === 'function') {
onSubmit(name, color && color.hex ? color.hex : '');
onSubmit(name, meta.value || '');
}
};

return (
<>
<MuiTextField
Expand All @@ -86,15 +86,15 @@ const ColorPickerField = (props) => {
id={id}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
onClose={handleChange}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'left',
}}
>
<SketchPicker
color={meta.value || ''}
onChangeComplete={(color) => handleChange(color)}
onChangeComplete={(color) => setFieldValue(name, color.hex)}
/>
</Popover>
</>
Expand Down
22 changes: 19 additions & 3 deletions opencti-platform/opencti-front/src/components/ItemBoolean.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import withStyles from '@mui/styles/withStyles';
import Chip from '@mui/material/Chip';
import { compose } from 'ramda';
import CircularProgress from '@mui/material/CircularProgress';
import { useTheme } from '@mui/styles';
import inject18n from './i18n';

const styles = () => ({
Expand All @@ -27,7 +28,7 @@ const styles = () => ({
},
});

const inlineStyles = {
const computeInlineStyles = (theme) => ({
green: {
backgroundColor: 'rgba(76, 175, 80, 0.08)',
color: '#4caf50',
Expand All @@ -40,11 +41,17 @@ const inlineStyles = {
backgroundColor: 'rgba(92, 123, 245, 0.08)',
color: '#5c7bf5',
},
};
ee: {
backgroundColor: theme.palette.ee.background,
color: theme.palette.ee.main,
},
});

const ItemBoolean = (props) => {
const { classes, label, neutralLabel, status, variant, t, reverse } = props;
const theme = useTheme();
const style = variant === 'inList' ? classes.chipInList : classes.chip;
const inlineStyles = computeInlineStyles(theme);
if (status === true) {
return (
<Chip
Expand All @@ -63,6 +70,15 @@ const ItemBoolean = (props) => {
/>
);
}
if (status === 'ee') {
return (
<Chip
classes={{ root: style }}
style={inlineStyles.ee}
label={neutralLabel || t('EE')}
/>
);
}
if (status === undefined) {
return (
<Chip
Expand All @@ -83,7 +99,7 @@ const ItemBoolean = (props) => {

ItemBoolean.propTypes = {
classes: PropTypes.object.isRequired,
status: PropTypes.bool,
status: PropTypes.oneOf([PropTypes.bool, PropTypes.string]),
label: PropTypes.string,
neutralLabel: PropTypes.string,
variant: PropTypes.string,
Expand Down
71 changes: 43 additions & 28 deletions opencti-platform/opencti-front/src/components/Theme.d.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
import {
CommonColors,
PaletteColorOptions,
PaletteMode,
PaletteOptions,
TypeBackground,
TypeText,
} from '@mui/material/styles/createPalette';
import { CommonColors, PaletteColorOptions, PaletteMode, PaletteOptions, TypeBackground, TypeText } from '@mui/material/styles/createPalette';
import { Theme as MuiTheme, ThemeOptions } from '@mui/material/styles/createTheme';

declare module '@mui/material/IconButton' {
interface IconButtonPropsColorOverrides {
ee: true
}
}

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

declare module '@mui/material/SvgIcon' {
interface SvgIconPropsColorOverrides {
ee: true
}
}

interface ExtendedColor extends PaletteColorOptions {
main: string;
dark: string;
palette: ExtendedPaletteOptions;
text: Partial<TypeText>;
mode: PaletteMode;
main: string
dark: string
palette: ExtendedPaletteOptions
text: Partial<TypeText>
mode: PaletteMode
background: string
}

interface ExtendedBackground extends TypeBackground {
nav: string;
accent: string;
shadow: string;
nav: string
accent: string
shadow: string
}

interface ExtendedPaletteOptions extends PaletteOptions {
common: Partial<CommonColors>;
background: Partial<ExtendedBackground>;
primary: Partial<ExtendedColor>;
error: Partial<ExtendedColor>;
success: Partial<ExtendedColor>;
chip: Partial<ExtendedColor>;
secondary: Partial<ExtendedColor>;
mode: PaletteMode;
common: Partial<CommonColors>
background: Partial<ExtendedBackground>
primary: Partial<ExtendedColor>
error: Partial<ExtendedColor>
success: Partial<ExtendedColor>
chip: Partial<ExtendedColor>
ee: Partial<ExtendedColor>
secondary: Partial<ExtendedColor>
mode: PaletteMode
}

interface ExtendedThemeOptions extends ThemeOptions {
logo: string | null;
logo_collapsed: string | null;
palette: ExtendedPaletteOptions;
logo: string | null
logo_collapsed: string | null
palette: ExtendedPaletteOptions
borderRadius: number
}

export interface Theme extends MuiTheme {
logo: string | undefined
logo_collapsed: string | undefined
palette: ExtendedPaletteOptions;
borderRadius: number
palette: ExtendedPaletteOptions
}
6 changes: 6 additions & 0 deletions opencti-platform/opencti-front/src/components/ThemeDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ExtendedThemeOptions } from './Theme';
import LogoText from '../static/images/logo_text.png';
import LogoCollapsed from '../static/images/logo.png';
import { fileUri } from '../relay/environment';
import { EE_COLOR, hexToRGB } from '../utils/Colors';

export const THEME_DARK_DEFAULT_BACKGROUND = '#0a1929';

Expand All @@ -17,6 +18,7 @@ const ThemeDark = (
): ExtendedThemeOptions => ({
logo: logo || fileUri(LogoText),
logo_collapsed: logo_collapsed || fileUri(LogoCollapsed),
borderRadius: 2,
palette: {
mode: 'dark',
common: { white: '#ffffff' },
Expand All @@ -28,6 +30,10 @@ const ThemeDark = (
primary: { main: primary || '#00b1ff' },
secondary: { main: secondary || '#ec407a' },
chip: { main: '#ffffff' },
ee: {
main: EE_COLOR,
background: hexToRGB(EE_COLOR, 0.3),
},
background: {
default: background || THEME_DARK_DEFAULT_BACKGROUND,
paper: paper || '#001e3c',
Expand Down
6 changes: 6 additions & 0 deletions opencti-platform/opencti-front/src/components/ThemeLight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ExtendedThemeOptions } from './Theme';
import { fileUri } from '../relay/environment';
import LogoText from '../static/images/logo_text.png';
import LogoCollapsed from '../static/images/logo.png';
import { EE_COLOR, hexToRGB } from '../utils/Colors';

const ThemeLight = (
logo: string | null,
Expand All @@ -15,6 +16,7 @@ const ThemeLight = (
): ExtendedThemeOptions => ({
logo: logo || fileUri(LogoText),
logo_collapsed: logo_collapsed || fileUri(LogoCollapsed),
borderRadius: 2,
palette: {
mode: 'light',
common: { white: '#ffffff' },
Expand All @@ -26,6 +28,10 @@ const ThemeLight = (
primary: { main: primary || '#007fff' },
secondary: { main: secondary || '#d81b60' },
chip: { main: '#000000' },
ee: {
main: EE_COLOR,
background: hexToRGB(EE_COLOR, 0.3),
},
background: {
default: background || '#ffffff',
paper: paper || '#f3f6f9',
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/src/components/i18n.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const inject18n = (WrappedComponent) => {

export const useFormatter = () => {
const intl = useIntl();
const translate = (message) => intl.formatMessage({ id: message });
const translate = (message, { id, values } = {}) => intl.formatMessage({ id: id ?? message }, values);
const formatNumber = (number) => {
if (number === null || number === '') {
return '-';
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/src/private/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const rootPrivateQuery = graphql`
platform_map_tile_server_dark
platform_map_tile_server_light
platform_theme
platform_whitemark
platform_session_idle_timeout
platform_session_timeout
platform_feature_flags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ interface FormikFeedbackAddInput {
const FEEDBACK_TYPE = 'Feedback';

const FeedbackCreation: FunctionComponent<{
openDrawer: boolean;
handleCloseDrawer: () => void;
}> = ({ openDrawer, handleCloseDrawer }) => {
openDrawer: boolean
handleCloseDrawer: () => void
initialValue?: Partial<FormikFeedbackAddInput>
}> = ({ openDrawer, handleCloseDrawer, initialValue }) => {
const classes = useStyles();
const { t } = useFormatter();
const { me } = useAuth();
Expand Down Expand Up @@ -106,6 +107,7 @@ const FeedbackCreation: FunctionComponent<{
objects: [],
file: undefined,
objectLabel: [],
...initialValue,
},
{ rating: 5 },
);
Expand Down

This file was deleted.

0 comments on commit 9143ea0

Please sign in to comment.