11import React from "react" ;
22import PropTypes from "prop-types" ;
3- import { Button , Modal , ModalHeader , ModalBody } from "reactstrap" ;
3+ import {
4+ Button ,
5+ Modal ,
6+ ModalHeader ,
7+ ModalBody ,
8+ UncontrolledTooltip ,
9+ } from "reactstrap" ;
410import { RiHeartPulseLine } from "react-icons/ri" ;
5- import { MdDelete , MdFileDownload , MdEdit } from "react-icons/md" ;
11+ import {
12+ MdDelete ,
13+ MdFileDownload ,
14+ MdEdit ,
15+ MdInfoOutline ,
16+ } from "react-icons/md" ;
617import { BsPeopleFill } from "react-icons/bs" ;
718import { AiFillSetting } from "react-icons/ai" ;
819import { FaDiagramProject } from "react-icons/fa6" ;
20+ import { VscJson } from "react-icons/vsc" ;
21+ import { Link } from "react-router-dom" ;
922
10- import { IconButton } from "@certego/certego-ui" ;
23+ import { IconButton , CustomJsonInput } from "@certego/certego-ui" ;
1124
1225import { useAuthStore } from "../../../stores/useAuthStore" ;
1326import { useOrganizationStore } from "../../../stores/useOrganizationStore" ;
@@ -17,6 +30,10 @@ import { deleteConfiguration } from "../pluginsApi";
1730import { PluginsTypes } from "../../../constants/pluginConst" ;
1831import { PluginConfigModal } from "../PluginConfigModal" ;
1932import { PlaybookFlows } from "../flows/PlaybookFlows" ;
33+ import {
34+ INTELOWL_DOCS_URL ,
35+ INTELOWL_REPO_URL ,
36+ } from "../../../constants/environment" ;
2037
2138export function PluginHealthCheckButton ( { pluginName, pluginType_ } ) {
2239 const { checkPluginHealth } = usePluginConfigurationStore (
@@ -459,3 +476,100 @@ export function PlaybookFlowsButton({ playbook }) {
459476PlaybookFlowsButton . propTypes = {
460477 playbook : PropTypes . object . isRequired ,
461478} ;
479+
480+ export function MappingDataModel ( { data, type, pythonModule } ) {
481+ // state
482+ const [ showModal , setShowModal ] = React . useState ( false ) ;
483+ const pythonModuleName = pythonModule . split ( "." ) [ 0 ] ;
484+
485+ return (
486+ < div className = "d-flex flex-column align-items-center p-1" >
487+ < IconButton
488+ id = { `mapping-data-model__${ pythonModuleName } ` }
489+ color = "info"
490+ size = "sm"
491+ Icon = { VscJson }
492+ title = "View data model mapping"
493+ onClick = { ( ) => setShowModal ( ! showModal ) }
494+ titlePlacement = "top"
495+ disabled = { Object . keys ( data ) . length === 0 }
496+ />
497+ { showModal && (
498+ < Modal
499+ id = "mapping-data-model-modal"
500+ autoFocus
501+ centered
502+ zIndex = "1050"
503+ size = "lg"
504+ keyboard = { false }
505+ backdrop = "static"
506+ labelledBy = "Data model modal"
507+ isOpen = { showModal }
508+ style = { { minWidth : "50%" } }
509+ >
510+ < ModalHeader className = "mx-2" toggle = { ( ) => setShowModal ( false ) } >
511+ < small className = "text-info" >
512+ Data model mapping
513+ < MdInfoOutline
514+ id = "dataModelMapping_infoicon"
515+ fontSize = "16"
516+ className = "ms-2"
517+ />
518+ < UncontrolledTooltip
519+ trigger = "hover"
520+ target = "dataModelMapping_infoicon"
521+ placement = "right"
522+ fade = { false }
523+ autohide = { false }
524+ innerClassName = "p-2 text-start text-nowrap md-fit-content"
525+ >
526+ The main functionality of a `DataModel` is to model an
527+ `Analyzer` result to a set of prearranged keys, allowing users
528+ to easily search, evaluate and use the analyzer result.
529+ < br />
530+ For more info check the{ " " }
531+ < Link
532+ to = { `${ INTELOWL_DOCS_URL } IntelOwl/usage/#datamodels` }
533+ target = "_blank"
534+ >
535+ official doc.
536+ </ Link >
537+ </ UncontrolledTooltip >
538+ </ small >
539+ </ ModalHeader >
540+ < ModalBody className = "d-flex flex-column mx-2" >
541+ < small >
542+ The < strong className = "text-info" > keys </ strong >
543+ represent the path used to retrieve the value in the analyzer
544+ report and the < strong className = "text-info" > value</ strong > the
545+ path of the data model.
546+ </ small >
547+ < small >
548+ For more info check the{ " " }
549+ < Link
550+ to = { `${ INTELOWL_REPO_URL } tree/master/api_app/analyzers_manager/${ type } _analyzers/${ pythonModuleName } .py` }
551+ target = "_blank"
552+ >
553+ analyzer's source code.
554+ </ Link >
555+ </ small >
556+ < div className = "my-2 d-flex justify-content-center" >
557+ < CustomJsonInput
558+ id = "data_model_mapping_json"
559+ placeholder = { data }
560+ viewOnly
561+ confirmGood = { false }
562+ />
563+ </ div >
564+ </ ModalBody >
565+ </ Modal >
566+ ) }
567+ </ div >
568+ ) ;
569+ }
570+
571+ MappingDataModel . propTypes = {
572+ type : PropTypes . string . isRequired ,
573+ data : PropTypes . object . isRequired ,
574+ pythonModule : PropTypes . string . isRequired ,
575+ } ;
0 commit comments