skipped 6 lines 7 7 import Typography from '@mui/material/Typography'; 8 8 import IconButton from '@mui/material/IconButton'; 9 9 import Slide from '@mui/material/Slide'; 10 + import Tooltip from '@mui/material/Tooltip'; 10 11 import { Add, Close, Delete } from '@mui/icons-material'; 11 12 import { DotsHorizontalCircleOutline } from 'mdi-material-ui'; 12 13 import Dialog from '@mui/material/Dialog'; skipped 19 lines 32 33 import StixCoreObjectEnrichment from '../stix_core_objects/StixCoreObjectEnrichment'; 33 34 import CommitMessage from '../form/CommitMessage'; 34 35 import StixCoreObjectSharing from '../stix_core_objects/StixCoreObjectSharing'; 36 + import { truncate } from '../../../../utils/String'; 35 37 36 38 const Transition = React.forwardRef((props, ref) => ( 37 39 <Slide direction="up" ref={ref} {...props} /> skipped 238 lines 276 278 disablePopover, 277 279 enableReferences, 278 280 disableSharing, 281 + noAliases, 279 282 } = this.props; 280 283 const aliases = R.propOr( 281 284 [], skipped 2 lines 284 287 ); 285 288 return ( 286 289 <div> 287 - <Typography 288 - variant="h1" 289 - gutterBottom={true} 290 - classes={{ root: classes.title }} 291 - > 292 - {stixDomainObject.name} 293 - </Typography> 290 + <Tooltip title={stixDomainObject.name}> 291 + <Typography 292 + variant="h1" 293 + gutterBottom={true} 294 + classes={{ root: classes.title }} 295 + > 296 + {truncate(stixDomainObject.name, 80)} 297 + </Typography> 298 + </Tooltip> 294 299 <Security needs={[KNOWLEDGE_KNUPDATE]}> 295 300 <div className={classes.popover}> 296 301 {React.cloneElement(PopoverComponent, { skipped 24 lines 321 326 </FormControl> 322 327 </div> 323 328 )} 324 - <div 325 - className={classes.aliases} 326 - style={{ marginLeft: typeof onViewAs === 'function' ? 10 : 0 }} 327 - > 328 - {R.take(5, aliases).map( 329 - (label) => label.length > 0 && ( 330 - <Security 331 - needs={[KNOWLEDGE_KNUPDATE]} 332 - key={label} 333 - placeholder={ 334 - <Chip classes={{ root: classes.alias }} label={label} /> 335 - } 336 - > 337 - <Chip 338 - classes={{ root: classes.alias }} 339 - label={label} 340 - onDelete={ 341 - enableReferences 342 - ? this.handleOpenCommitDelete.bind(this, label) 343 - : this.deleteAlias.bind(this, label) 329 + {!noAliases && ( 330 + <div 331 + className={classes.aliases} 332 + style={{ marginLeft: typeof onViewAs === 'function' ? 10 : 0 }} 333 + > 334 + {R.take(5, aliases).map( 335 + (label) => label.length > 0 && ( 336 + <Security 337 + needs={[KNOWLEDGE_KNUPDATE]} 338 + key={label} 339 + placeholder={ 340 + <Chip classes={{ root: classes.alias }} label={label} /> 344 341 } 345 - / > 346 - </Security> 347 - ), 348 - )} 349 - </div> 350 - <Slide 351 - direction="right" 352 - in={this.state.openAlias} 353 - mountOnEnter={true} 354 - unmountOnExit={true} 355 - > 356 - <div style={{ float: 'left', marginTop: -5 }}> 357 - <Formik 358 - initialValues={{ new_alias: '' }} 359 - onSubmit={this.onSubmitCreateAlias.bind(this, 'main')} 360 - validationSchema={enableReferences ? aliasValidation(t) : null} 361 - > 362 - {({ 363 - submitForm, 364 - isSubmitting, 365 - validateForm, 366 - setFieldValue, 367 - values, 368 - }) => ( 369 - <Form style={{ float: 'right' }}> 370 - <Field 371 - component={TextField} 372 - variant="standard" 373 - name="new_alias" 374 - autoFocus={true} 375 - placeholder={t('New alias')} 376 - className={classes.aliasesInput} 377 - onChange={this.handleChangeNewAlias.bind(this)} 378 - value={this.state.newAlias} 379 - onKeyDown={(e) => { 380 - if (e.keyCode === 13) { 381 - if (enableReferences && !this.state.openCommitCreate) { 382 - return this.handleOpenCommitCreate(); 383 - } 384 - return submitForm(); 342 + > 343 + <Chip 344 + classes={{ root: classes.alias }} 345 + label={label} 346 + onDelete={ 347 + enableReferences 348 + ? this.handleOpenCommitDelete.bind(this, label) 349 + : this.deleteAlias.bind(this, label) 385 350 } 386 - return true; 387 - }} 388 - /> 389 - {enableReferences && ( 390 - <CommitMessage 391 - handleClose={this.openCommitCreate.bind(this)} 392 - open={this.state.openCommitCreate} 393 - submitForm={submitForm} 394 - disabled={isSubmitting} 395 - validateForm={validateForm} 396 - setFieldValue={setFieldValue} 397 - values={values} 398 - id={stixDomainObject.id} 399 351 /> 400 - )} 401 - </Form> 402 - )} 403 - </Formik> 352 + </Security> 353 + ), 354 + )} 404 355 </div> 405 - </Slide> 406 - <Security needs={[KNOWLEDGE_KNUPDATE]}> 407 - {aliases.length > 5 ? ( 408 - <IconButton 409 - style={{ float: 'left', marginTop: -8 }} 410 - color="primary" 411 - aria-label="More" 412 - onClick={this.handleToggleOpenAliases.bind(this)} 413 - size="large" 414 - > 415 - <DotsHorizontalCircleOutline fontSize="small" /> 416 - </IconButton> 417 - ) : ( 418 - <IconButton 419 - style={{ float: 'left', marginTop: -8 }} 420 - color={this.state.openAlias ? 'primary' : 'secondary'} 421 - aria-label="Alias" 422 - onClick={this.handleToggleCreateAlias.bind(this)} 423 - size="large" 424 - > 425 - {this.state.openAlias ? ( 426 - <Close fontSize="small" color="primary" /> 427 - ) : ( 428 - <Add fontSize="small" /> 429 - )} 430 - </IconButton> 431 - )} 432 - </Security> 356 + )} 357 + {!noAliases && ( 358 + <Slide 359 + direction="right" 360 + in={this.state.openAlias} 361 + mountOnEnter={true} 362 + unmountOnExit={true} 363 + > 364 + <div style={{ float: 'left', marginTop: -5 }}> 365 + <Formik 366 + initialValues={{ new_alias: '' }} 367 + onSubmit={this.onSubmitCreateAlias.bind(this, 'main')} 368 + validationSchema={enableReferences ? aliasValidation(t) : null} 369 + > 370 + {({ 371 + submitForm, 372 + isSubmitting, 373 + validateForm, 374 + setFieldValue, 375 + values, 376 + }) => ( 377 + <Form style={{ float: 'right' }}> 378 + <Field 379 + component={TextField} 380 + variant="standard" 381 + name="new_alias" 382 + autoFocus={true} 383 + placeholder={t('New alias')} 384 + className={classes.aliasesInput} 385 + onChange={this.handleChangeNewAlias.bind(this)} 386 + value={this.state.newAlias} 387 + onKeyDown={(e) => { 388 + if (e.keyCode === 13) { 389 + if ( 390 + enableReferences 391 + && !this.state.openCommitCreate 392 + ) { 393 + return this.handleOpenCommitCreate(); 394 + } 395 + return submitForm(); 396 + } 397 + return true; 398 + }} 399 + /> 400 + {enableReferences && ( 401 + <CommitMessage 402 + handleClose={this.openCommitCreate.bind(this)} 403 + open={this.state.openCommitCreate} 404 + submitForm={submitForm} 405 + disabled={isSubmitting} 406 + validateForm={validateForm} 407 + setFieldValue={setFieldValue} 408 + values={values} 409 + id={stixDomainObject.id} 410 + /> 411 + )} 412 + </Form> 413 + )} 414 + </Formik> 415 + </div> 416 + </Slide> 417 + )} 418 + {!noAliases && ( 419 + <Security needs={[KNOWLEDGE_KNUPDATE]}> 420 + {aliases.length > 5 ? ( 421 + <IconButton 422 + style={{ float: 'left', marginTop: -8 }} 423 + color="primary" 424 + aria-label="More" 425 + onClick={this.handleToggleOpenAliases.bind(this)} 426 + size="large" 427 + > 428 + <DotsHorizontalCircleOutline fontSize="small" /> 429 + </IconButton> 430 + ) : ( 431 + <IconButton 432 + style={{ float: 'left', marginTop: -8 }} 433 + color={this.state.openAlias ? 'primary' : 'secondary'} 434 + aria-label="Alias" 435 + onClick={this.handleToggleCreateAlias.bind(this)} 436 + size="large" 437 + > 438 + {this.state.openAlias ? ( 439 + <Close fontSize="small" color="primary" /> 440 + ) : ( 441 + <Add fontSize="small" /> 442 + )} 443 + </IconButton> 444 + )} 445 + </Security> 446 + )} 433 447 <div className={classes.actions}> 434 448 <ToggleButtonGroup size="small" color="secondary" exclusive={true}> 435 449 {disableSharing !== true && ( skipped 6 lines 442 456 </ToggleButtonGroup> 443 457 </div> 444 458 <div className="clearfix" /> 445 - <Dialog 446 - PaperProps={{ elevation: 1 }} 447 - open={this.state.openAliases} 448 - TransitionComponent={Transition} 449 - onClose={this.handleToggleOpenAliases.bind(this)} 450 - fullWidth={true} 451 - > 452 - <DialogTitle> 453 - {t('Entity aliases')} 454 - <Formik 455 - initialValues={{ new_alias: '' }} 456 - onSubmit={this.onSubmitCreateAlias.bind(this, 'dialog')} 457 - validationSchema={enableReferences ? aliasValidation(t) : null} 458 - > 459 - {({ 460 - submitForm, 461 - isSubmitting, 462 - validateForm, 463 - setFieldValue, 464 - values, 465 - }) => ( 466 - <Form style={{ float: 'right' }}> 467 - <Field 468 - component={TextField} 469 - variant="standard" 470 - name="new_alias" 471 - autoFocus={true} 472 - placeholder={t('New alias')} 473 - className={classes.aliasesInput} 474 - onChange={this.handleChangeNewAlias.bind(this)} 475 - value={this.state.newAlias} 476 - onKeyDown={(e) => { 477 - if (e.keyCode === 13) { 478 - if (enableReferences) { 479 - return this.handleOpenCommitCreate(); 480 - } 481 - return submitForm(); 482 - } 483 - return true; 484 - }} 485 - /> 486 - {enableReferences && ( 487 - <CommitMessage 488 - handleClose={this.handleCloseCommitCreate.bind(this)} 489 - open={this.state.openCommitCreate} 490 - submitForm={submitForm} 491 - disabled={isSubmitting} 492 - validateForm={validateForm} 493 - setFieldValue={setFieldValue} 494 - values={values} 495 - id={stixDomainObject.id} 496 - /> 497 - )} 498 - </Form> 499 - )} 500 - </Formik> 501 - </DialogTitle> 502 - <DialogContent dividers={true}> 503 - <List> 504 - {R.propOr( 505 - [], 506 - isOpenctiAlias ? 'x_opencti_aliases' : 'aliases', 507 - stixDomainObject, 508 - ).map( 509 - (label) => label.length > 0 && ( 510 - <ListItem key={label} disableGutters={true} dense={true}> 511 - <ListItemText primary={label} /> 512 - <ListItemSecondaryAction> 513 - <IconButton 514 - edge="end" 515 - aria-label="delete" 516 - onClick={ 517 - enableReferences 518 - ? this.handleOpenCommitDelete.bind(this, label) 519 - : this.deleteAlias.bind(this, label) 520 - } 521 - size="large" 522 - > 523 - <Delete /> 524 - </IconButton> 525 - </ListItemSecondaryAction> 526 - </ListItem> 527 - ), 528 - )} 529 - </List> 530 - <div 531 - style={{ 532 - display: this.state.openAliasesCreate ? 'block' : 'none', 533 - }} 534 - > 459 + {!noAliases && ( 460 + <Dialog 461 + PaperProps={{ elevation: 1 }} 462 + open={this.state.openAliases} 463 + TransitionComponent={Transition} 464 + onClose={this.handleToggleOpenAliases.bind(this)} 465 + fullWidth={true} 466 + > 467 + <DialogTitle> 468 + {t('Entity aliases')} 535 469 <Formik 536 470 initialValues={{ new_alias: '' }} 537 471 onSubmit={this.onSubmitCreateAlias.bind(this, 'dialog')} skipped 6 lines 544 478 setFieldValue, 545 479 values, 546 480 }) => ( 547 - <Form> 481 + <Form style={{ float: 'right' }}> 548 482 <Field 549 483 component={TextField} 550 484 variant="standard" 551 485 name="new_alias" 552 486 autoFocus={true} 553 - fullWidth={true} 554 - placeholder={t('New aliases')} 487 + placeholder={t('New alias')} 555 488 className={classes.aliasesInput} 556 489 onChange={this.handleChangeNewAlias.bind(this)} 557 490 value={this.state.newAlias} 558 491 onKeyDown={(e) => { 559 492 if (e.keyCode === 13) { 560 - if ( 561 - enableReferences 562 - && !this.state.openCommitCreate 563 - ) { 493 + if (enableReferences) { 564 494 return this.handleOpenCommitCreate(); 565 495 } 566 496 return submitForm(); skipped 16 lines 583 513 </Form> 584 514 )} 585 515 </Formik> 586 - </div> 587 - </ DialogContent> 588 - <DialogActions> 589 - <Button 590 - onClick={this.handleToggleOpenAliases.bind(this)} 591 - color="primary" 592 - > 593 - {t('Close')} 594 - </Button> 595 - </DialogActions> 596 - </Dialog> 516 + </DialogTitle> 517 + <DialogContent dividers = { true } > 518 + <List> 519 + {R.propOr( 520 + [], 521 + isOpenctiAlias ? 'x_opencti_aliases' : 'aliases', 522 + stixDomainObject, 523 + ).map( 524 + (label) => label.length > 0 && ( 525 + <ListItem key={label} disableGutters={true} dense={true}> 526 + <ListItemText primary={label} /> 527 + <ListItemSecondaryAction> 528 + <IconButton 529 + edge="end" 530 + aria-label="delete" 531 + onClick={ 532 + enableReferences 533 + ? this.handleOpenCommitDelete.bind(this, label) 534 + : this.deleteAlias.bind(this, label) 535 + } 536 + size="large" 537 + > 538 + <Delete /> 539 + </IconButton> 540 + </ListItemSecondaryAction> 541 + </ListItem> 542 + ), 543 + )} 544 + </List> 545 + <div 546 + style={{ 547 + display: this.state.openAliasesCreate ? 'block' : 'none', 548 + }} 549 + > 550 + <Formik 551 + initialValues={{ new_alias: '' }} 552 + onSubmit={this.onSubmitCreateAlias.bind(this, 'dialog')} 553 + validationSchema={ 554 + enableReferences ? aliasValidation(t) : null 555 + } 556 + > 557 + {({ 558 + submitForm, 559 + isSubmitting, 560 + validateForm, 561 + setFieldValue, 562 + values, 563 + }) => ( 564 + <Form> 565 + <Field 566 + component={TextField} 567 + variant="standard" 568 + name="new_alias" 569 + autoFocus={true} 570 + fullWidth={true} 571 + placeholder={t('New aliases')} 572 + className={classes.aliasesInput} 573 + onChange={this.handleChangeNewAlias.bind(this)} 574 + value={this.state.newAlias} 575 + onKeyDown={(e) => { 576 + if (e.keyCode === 13) { 577 + if ( 578 + enableReferences 579 + && !this.state.openCommitCreate 580 + ) { 581 + return this.handleOpenCommitCreate(); 582 + } 583 + return submitForm(); 584 + } 585 + return true; 586 + }} 587 + /> 588 + {enableReferences && ( 589 + <CommitMessage 590 + handleClose={this.handleCloseCommitCreate.bind(this)} 591 + open={this.state.openCommitCreate} 592 + submitForm={submitForm} 593 + disabled={isSubmitting} 594 + validateForm={validateForm} 595 + setFieldValue={setFieldValue} 596 + values={values} 597 + id={stixDomainObject.id} 598 + /> 599 + )} 600 + </Form> 601 + )} 602 + </Formik> 603 + </div> 604 + </DialogContent> 605 + <DialogActions> 606 + <Button 607 + onClick={this.handleToggleOpenAliases.bind(this)} 608 + color="primary" 609 + > 610 + {t('Close')} 611 + </Button> 612 + </DialogActions> 613 + </Dialog> 614 + )} 597 615 {enableReferences && ( 598 616 <Formik 599 617 initialValues={{}} skipped 38 lines 638 656 onViewAs: PropTypes.func, 639 657 disablePopover: PropTypes.bool, 640 658 isOpenctiAlias: PropTypes.bool, 659 + noAliases: PropTypes.bool, 641 660 enableReferences: PropTypes.bool, 642 661 }; 643 662 skipped 2 lines