■ ■ ■ ■ ■ ■
opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectHeader.js
| skipped 267 lines |
268 | 268 | | const { |
269 | 269 | | t, |
270 | 270 | | classes, |
271 | | - | variant, |
272 | 271 | | stixDomainObject, |
273 | 272 | | isOpenctiAlias, |
274 | 273 | | PopoverComponent, |
| skipped 47 lines |
322 | 321 | | </FormControl> |
323 | 322 | | </div> |
324 | 323 | | )} |
325 | | - | {variant !== 'noaliases' && ( |
326 | | - | <div |
327 | | - | className={classes.aliases} |
328 | | - | style={{ marginLeft: typeof onViewAs === 'function' ? 10 : 0 }} |
329 | | - | > |
330 | | - | {R.take(5, aliases).map( |
331 | | - | (label) => label.length > 0 && ( |
332 | | - | <Security |
333 | | - | needs={[KNOWLEDGE_KNUPDATE]} |
334 | | - | key={label} |
335 | | - | placeholder={ |
336 | | - | <Chip classes={{ root: classes.alias }} label={label} /> |
| 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) |
337 | 344 | | } |
338 | | - | > |
339 | | - | <Chip |
340 | | - | classes={{ root: classes.alias }} |
341 | | - | label={label} |
342 | | - | onDelete={ |
343 | | - | enableReferences |
344 | | - | ? this.handleOpenCommitDelete.bind(this, label) |
345 | | - | : this.deleteAlias.bind(this, label) |
| 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(); |
346 | 385 | | } |
| 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} |
347 | 399 | | /> |
348 | | - | </Security> |
349 | | - | ), |
350 | | - | )} |
| 400 | + | )} |
| 401 | + | </Form> |
| 402 | + | )} |
| 403 | + | </Formik> |
351 | 404 | | </div> |
352 | | - | )} |
353 | | - | {variant !== 'noaliases' && ( |
354 | | - | <Slide |
355 | | - | direction="right" |
356 | | - | in={this.state.openAlias} |
357 | | - | mountOnEnter={true} |
358 | | - | unmountOnExit={true} |
359 | | - | > |
360 | | - | <div style={{ float: 'left', marginTop: -5 }}> |
361 | | - | <Formik |
362 | | - | initialValues={{ new_alias: '' }} |
363 | | - | onSubmit={this.onSubmitCreateAlias.bind(this, 'main')} |
364 | | - | validationSchema={enableReferences ? aliasValidation(t) : null} |
365 | | - | > |
366 | | - | {({ |
367 | | - | submitForm, |
368 | | - | isSubmitting, |
369 | | - | validateForm, |
370 | | - | setFieldValue, |
371 | | - | values, |
372 | | - | }) => ( |
373 | | - | <Form style={{ float: 'right' }}> |
374 | | - | <Field |
375 | | - | component={TextField} |
376 | | - | variant="standard" |
377 | | - | name="new_alias" |
378 | | - | autoFocus={true} |
379 | | - | placeholder={t('New alias')} |
380 | | - | className={classes.aliasesInput} |
381 | | - | onChange={this.handleChangeNewAlias.bind(this)} |
382 | | - | value={this.state.newAlias} |
383 | | - | onKeyDown={(e) => { |
384 | | - | if (e.keyCode === 13) { |
385 | | - | if ( |
386 | | - | enableReferences |
387 | | - | && !this.state.openCommitCreate |
388 | | - | ) { |
389 | | - | return this.handleOpenCommitCreate(); |
390 | | - | } |
391 | | - | return submitForm(); |
392 | | - | } |
393 | | - | return true; |
394 | | - | }} |
395 | | - | /> |
396 | | - | {enableReferences && ( |
397 | | - | <CommitMessage |
398 | | - | handleClose={this.openCommitCreate.bind(this)} |
399 | | - | open={this.state.openCommitCreate} |
400 | | - | submitForm={submitForm} |
401 | | - | disabled={isSubmitting} |
402 | | - | validateForm={validateForm} |
403 | | - | setFieldValue={setFieldValue} |
404 | | - | values={values} |
405 | | - | id={stixDomainObject.id} |
406 | | - | /> |
407 | | - | )} |
408 | | - | </Form> |
409 | | - | )} |
410 | | - | </Formik> |
411 | | - | </div> |
412 | | - | </Slide> |
413 | | - | )} |
414 | | - | {variant !== 'noaliases' && ( |
415 | | - | <Security needs={[KNOWLEDGE_KNUPDATE]}> |
416 | | - | {aliases.length > 5 ? ( |
417 | | - | <IconButton |
418 | | - | style={{ float: 'left', marginTop: -8 }} |
419 | | - | color="primary" |
420 | | - | aria-label="More" |
421 | | - | onClick={this.handleToggleOpenAliases.bind(this)} |
422 | | - | size="large" |
423 | | - | > |
424 | | - | <DotsHorizontalCircleOutline fontSize="small" /> |
425 | | - | </IconButton> |
426 | | - | ) : ( |
427 | | - | <IconButton |
428 | | - | style={{ float: 'left', marginTop: -8 }} |
429 | | - | color={this.state.openAlias ? 'primary' : 'secondary'} |
430 | | - | aria-label="Alias" |
431 | | - | onClick={this.handleToggleCreateAlias.bind(this)} |
432 | | - | size="large" |
433 | | - | > |
434 | | - | {this.state.openAlias ? ( |
435 | | - | <Close fontSize="small" color="primary" /> |
436 | | - | ) : ( |
437 | | - | <Add fontSize="small" /> |
438 | | - | )} |
439 | | - | </IconButton> |
440 | | - | )} |
441 | | - | </Security> |
442 | | - | )} |
| 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> |
443 | 433 | | <div className={classes.actions}> |
444 | 434 | | <ToggleButtonGroup size="small" color="secondary" exclusive={true}> |
445 | 435 | | {disableSharing !== true && ( |
| skipped 210 lines |