Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend/frontend] Add Import from XTM Hub button in Custom Dashboards #10100

Merged
merged 13 commits into from
Mar 4, 2025

Conversation

jbanety
Copy link
Contributor

@jbanety jbanety commented Feb 27, 2025

Proposed changes

  • Add a xtm:xtmhub_url config value
  • Create a GradientButton component to add a gradient bordered button to show Import from Hub with theme colors.
  • Update Settings GraphQL type to add platform_xtmhub_url
  • Update WorkspaceCreation component to add the Import from Hub button opening a new tab with a forged URL based on platform_xtmhub_url root URI.
  • Add XTM Hub logo in Top Bar and remove OpenERM and OpenMTD.

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

@jbanety jbanety added feature use for describing a new feature to develop filigran team use to identify PR from the Filigran team labels Feb 27, 2025
@jbanety jbanety self-assigned this Feb 27, 2025
@jbanety jbanety linked an issue Feb 27, 2025 that may be closed by this pull request
5 tasks
@jbanety jbanety marked this pull request as draft February 27, 2025 10:44
@jbanety jbanety marked this pull request as ready for review February 27, 2025 14:29
@jbanety jbanety changed the title Draft: [backend/frontend] Add Import from XTM Hub button in Custom Dashboards [backend/frontend] Add Import from XTM Hub button in Custom Dashboards Feb 27, 2025
@jbanety jbanety requested review from labo-flg and Kedae February 27, 2025 14:34
@@ -123,6 +127,17 @@ const WorkspaceCreation = ({ paginationOptions, type }) => {

const createDashboardButton = FAB_REPLACED ? (props) => (
<>
<GradientButton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I find it better to always have this button and no speeddial

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.
Does that mean we're going to change the UI all the time?
I admit that I don't really know how feature flags are managed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the behavior to always show the button on top of the datatable

withShadow?: boolean;
}

const GradientButton = styled(Button, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to have a Button with style props I think. You could check with Landry

Copy link
Contributor Author

@jbanety jbanety Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lndrtrbn any thoughts on this ?

Copy link
Member

@lndrtrbn lndrtrbn Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have decided in OCTI to not use this because even if it is categorized in their doc as the way to do Reusable component, this syntax is horrible to read.

We can achieve exactly the same (i.e. creating reusable component) with the first bloc of the documentation you shared using sx props which is better in terms of readability (imo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oki doki. I'll change that

lightModeEndColor?: string;
darkModeStartColor?: string;
darkModeEndColor?: string;
withShadow?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it for the example in Filigran-UI, we need to choose only one in OCTI and remove that boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -337,6 +335,15 @@ const TopBarComponent: FunctionComponent<TopBarProps> = ({
<Box sx={{ width: '300px', padding: '15px', textAlign: 'center' }}>
<div className={classes.subtitle}>{t_i18n('Filigran eXtended Threat Management')}</div>
<Grid container={true} spacing={3}>
<Grid item xs={12}>
<Tooltip title="XTM Hub">
<a className={classes.xtmItem} href="https://xtmhub.filigran.io" target="_blank" rel="noreferrer" onClick={handleCloseXtm}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded link ?
not from config ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 😁

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.35%. Comparing base (e1fee54) to head (dba676e).
Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10100      +/-   ##
==========================================
+ Coverage   64.30%   64.35%   +0.04%     
==========================================
  Files         656      656              
  Lines       63046    63086      +40     
  Branches     6988     7038      +50     
==========================================
+ Hits        40541    40597      +56     
+ Misses      22505    22489      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbanety jbanety requested review from lndrtrbn and Kedae February 27, 2025 16:05
}) => {
const theme = useTheme();
const isDarkMode = theme.palette.mode === 'dark';
const startColor = isDarkMode ? darkModeStartColor : lightModeStartColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add them in the theme (ThemeDark.ts and ThemeLight.ts) and remove all the props.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
I created a single xtmhub gradientVariant on the gradientButton.
In the future we could add some other variants.

@@ -102,6 +106,10 @@ const Workspaces: FunctionComponent<WorkspacesProps> = ({
const { isFeatureEnable } = useHelper();
const FAB_REPLACED = isFeatureEnable('FAB_REPLACEMENT');

const theme = useTheme();
const { settings } = useContext(UserContext);
const importFromHubUrl = isNotEmptyField(settings) ? `${settings.platform_xtmhub_url}/redirect/custom_dashboard?octi_instance_id=${settings.id}`.replaceAll('//', '/') : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should decide what to do if the url si not present. Display the button with no href ? Hide the button ? I can't recall what we have decided regarded airgapped platform (that could have a conf with no xtmhub url)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this because settings can be undefined during the loading time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway I can only show the button if the value is not empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The button is hidden if url is empty.

@@ -188,7 +214,8 @@
"openerm_url": "",
"openrm_token": "",
"openmtd_url": "",
"openmtd_token": ""
"openmtd_token": "",
"xtmhub_url": "https://xtmhub.filigran.io"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want it easily removable ? I can't recall what we discussed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This value is more to be able to align apps between different environments.
i.e. locahost:3000 > localhost:3001 or my-octi-instance.prod.fr > xtmhub.filigran.io

>
{t_i18n('Import dashboard')}
<FileUploadOutlined />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check that with Product team. @romain-filigran

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what was requested in Ellyn's brief => #10027

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kedae @jbanety : Can we schedule a demonstration to understand ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kedae : Seen with JB. Ok with a FileUpload icon button once the FAB replacement is merged.

@jbanety jbanety force-pushed the issue/10027 branch 2 times, most recently from 34084c2 to aaa69d1 Compare February 27, 2025 16:46
@jbanety jbanety merged commit fbfcc97 into master Mar 4, 2025
5 of 7 checks passed
@labo-flg labo-flg deleted the issue/10027 branch March 4, 2025 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature use for describing a new feature to develop filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XTM Hub launch - Add XTM Hub CTAs
5 participants