Skip to content

Commit

Permalink
[frontend/backend] Add quick actions on Assignee/Participant (#4333)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrien Servel <adrien.servel@filigran.io>
Co-authored-by: Angelique <angelique.jard@filigran.io>
  • Loading branch information
3 people authored and labo-flg committed Oct 15, 2024
1 parent e64f317 commit af2574f
Show file tree
Hide file tree
Showing 36 changed files with 923 additions and 534 deletions.
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "Indikatoren hinzufügen",
"Add individual": "Einzelperson hinzufügen",
"Add locations": "Standorte hinzufügen",
"Add new assignees": "Neue Referenten hinzufügen",
"Add new labels": "Neue Labels hinzufügen",
"Add new participants": "Neue Teilnehmer hinzufügen",
"Add new specific access": "Neuen spezifischen Zugang hinzufügen",
"Add notes": "Notizen hinzufügen",
"Add observable": "Observable hinzufügen",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "Die Regel wurde deaktiviert, Bereinigung eingeleitet...",
"The rule has been enabled, rescan of platform data launched...": "Die Regel wurde aktiviert, erneuter Scan der Plattformdaten gestartet...",
"The scenario has been correctly generated in your OpenBAS platform": "Das Szenario wurde korrekt in Ihrer OpenBAS-Plattform generiert",
"The STIX ID has been removed": "Die STIX-ID wurde entfernt",
"The tag has been added": "Das Tag wurde hinzugefügt",
"The tag has been removed": "Das Tag wurde entfernt",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "Das Token fehlt in der Konfiguration Ihrer Plattform. Bitten Sie Ihren Filigran-Vertreter, es Ihnen zur Verfügung zu stellen oder eine Anleitung für den Einsatz vor Ort zu geben. Sie können dazu ein Support-Ticket eröffnen.",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "Add indicators",
"Add individual": "Add individual",
"Add locations": "Add locations",
"Add new assignees": "Add new assignees",
"Add new labels": "Add new labels",
"Add new participants": "Add new participants",
"Add new specific access": "Add new specific access",
"Add notes": "Add notes",
"Add observable": "Add observable",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "The rule has been disabled, clean-up launched...",
"The rule has been enabled, rescan of platform data launched...": "The rule has been enabled, rescan of platform data launched...",
"The scenario has been correctly generated in your OpenBAS platform": "The scenario has been correctly generated in your OpenBAS platform",
"The STIX ID has been removed": "The STIX ID has been removed",
"The tag has been added": "The tag has been added",
"The tag has been removed": "The tag has been removed",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "Añadir indicadores",
"Add individual": "Agregar individuo",
"Add locations": "Añadir una localización",
"Add new assignees": "Agregar nuevos referentes",
"Add new labels": "Añadir nuevas etiquetas",
"Add new participants": "Agregar nuevos participantes",
"Add new specific access": "Agregar nuevo acceso específico",
"Add notes": "Añadir notas",
"Add observable": "Añadir un observable",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "La regla ha sido desactivada, limpieza lanzada...",
"The rule has been enabled, rescan of platform data launched...": "La regla ha sido activada, reescaneo de los datos de la plataforma lanzado...",
"The scenario has been correctly generated in your OpenBAS platform": "El escenario se ha generado correctamente en su plataforma OpenBAS",
"The STIX ID has been removed": "El ID de STIX ha sido eliminado",
"The tag has been added": "Se ha añadido la etiqueta",
"The tag has been removed": "Se ha eliminado la etiqueta",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "Falta el token en la configuración de su plataforma, por favor solicite a su representante de Filigran que se lo proporcione o las instrucciones de despliegue on-premise. Puede abrir un ticket de soporte para ello.",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "Ajouter des indicateurs",
"Add individual": "Ajouter un individu",
"Add locations": "Ajouter une localisation",
"Add new assignees": "Ajouter de nouveaux référents",
"Add new labels": "Ajouter des labels",
"Add new participants": "Ajouter de nouveaux participants",
"Add new specific access": "Ajouter un nouvel accès spécifique",
"Add notes": "Ajouter des notes",
"Add observable": "Ajouter un observable",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "La règle a été déséactivée, purge lancée...",
"The rule has been enabled, rescan of platform data launched...": "La règle a été activée, re-scan des données de la plateforme lancé...",
"The scenario has been correctly generated in your OpenBAS platform": "Le scénario a été correctement généré dans votre plateforme OpenBAS",
"The STIX ID has been removed": "L'ID STIX a été supprimé",
"The tag has been added": "La balise a été ajoutée",
"The tag has been removed": "La balise a été supprimée",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "Le token est manquant dans la configuration de votre plateforme, veuillez demander à votre représentant Filigran de vous le fournir ou de vous donner des instructions pour le déploiement sur site. Vous pouvez ouvrir un ticket de support pour ce faire.",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "インジケータの追加",
"Add individual": "個人を追加",
"Add locations": "ロケーションの追加",
"Add new assignees": "新しい担当者を追加",
"Add new labels": "新しいラベルを作成",
"Add new participants": "新しい参加者を追加",
"Add new specific access": "新しい特定のアクセス権を追加する",
"Add notes": "ノートを追加",
"Add observable": "観測結果の追加",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "ルールは無効化され、クリーンアップが開始されました...",
"The rule has been enabled, rescan of platform data launched...": "ルールが有効化され、プラットフォームデータの再スキャンが開始されました...",
"The scenario has been correctly generated in your OpenBAS platform": "シナリオはOpenBASプラットフォームで正しく生成されました。",
"The STIX ID has been removed": "STIX ID が削除されました",
"The tag has been added": "タグが追加されました",
"The tag has been removed": "タグは削除されました",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "お客様のプラットフォーム構成にトークンがありません。フィリグランの担当者にトークンの提供、またはオンプレミスでの展開方法をお問い合わせください。サポートチケットでお問い合わせください。",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "지표 추가",
"Add individual": "개인 추가",
"Add locations": "위치 추가",
"Add new assignees": "새로운 담당자를 추가",
"Add new labels": "새 라벨 추가",
"Add new participants": "새로운 참가자를 추가",
"Add new specific access": "새 특정 접근 추가",
"Add notes": "노트 추가",
"Add observable": "관찰 가능 항목 추가",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "규칙이 비활성화되었습니다, 정리 시작...",
"The rule has been enabled, rescan of platform data launched...": "규칙이 활성화되었습니다, 플랫폼 데이터 다시 스캔 시작...",
"The scenario has been correctly generated in your OpenBAS platform": "시나리오가 OpenBAS 플랫폼에서 올바르게 생성되었습니다",
"The STIX ID has been removed": "STIX ID가 제거되었습니다",
"The tag has been added": "태그가 추가되었습니다",
"The tag has been removed": "태그가 제거되었습니다",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "플랫폼 구성에 토큰이 누락되었습니다. Filigran 담당자에게 이를 제공하거나 온프레미스 배포 지침을 요청하십시오. 지원 티켓을 열 수 있습니다.",
Expand Down
3 changes: 3 additions & 0 deletions opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"Add indicators": "添加指标",
"Add individual": "添加个人",
"Add locations": "添加位置",
"Add new assignees": "添加新的负责人",
"Add new labels": "添加新的标签",
"Add new participants": "添加新的参与者",
"Add new specific access": "添加新的特定访问权限",
"Add notes": "添加注释",
"Add observable": "添加可观测数据",
Expand Down Expand Up @@ -2599,6 +2601,7 @@
"The rule has been disabled, clean-up launched...": "该规则已禁用,清理已启动",
"The rule has been enabled, rescan of platform data launched...": "该规则已启用,平台数据的重新扫描已启动",
"The scenario has been correctly generated in your OpenBAS platform": "场景已在 OpenBAS 平台正确生成",
"The STIX ID has been removed": "STIX ID 已被删除",
"The tag has been added": "标签已添加",
"The tag has been removed": "标签已删除",
"The token is missing in your platform configuration, please ask your Filigran representative to provide you with it or with on-premise deployment instructions. Your can open a support ticket to do so.": "平台配置中缺少令牌,请要求 Filigran 代表提供令牌或内部部署说明。您可以打开支持票单进行申请。",
Expand Down
66 changes: 51 additions & 15 deletions opencti-platform/opencti-front/src/components/ItemAssignees.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import React, { FunctionComponent } from 'react';
import Button from '@mui/material/Button';
import Chip from '@mui/material/Chip';
import { CancelOutlined, PersonOutline } from '@mui/icons-material';
import { useTheme } from '@mui/styles';
import { stixDomainObjectMutation } from '@components/common/stix_domain_objects/StixDomainObjectHeader';
import Tooltip from '@mui/material/Tooltip';
import { truncate } from '../utils/String';
import useGranted, { KNOWLEDGE_KNUPDATE } from '../utils/hooks/useGranted';
import type { Theme } from './Theme';
import FieldOrEmpty from './FieldOrEmpty';
import { commitMutation, defaultCommitMutation } from '../relay/environment';

type Node = {
readonly entity_type: string;
Expand All @@ -9,25 +18,52 @@ type Node = {

type Props = {
assignees: ReadonlyArray<Node>;
stixDomainObjectId: string;
};

const ItemAssignees: FunctionComponent<Props> = ({ assignees }) => {
const ItemAssignees: FunctionComponent<Props> = ({ assignees, stixDomainObjectId }) => {
const theme = useTheme<Theme>();
const canUpdateKnowledge = useGranted([KNOWLEDGE_KNUPDATE]);
const handleRemoveAssignee = (removedId: string) => {
const values = assignees.filter((assignee) => assignee.id !== removedId);
const valuesIds = values.map((value) => value.id);
commitMutation({
mutation: stixDomainObjectMutation,
variables: {
id: stixDomainObjectId,
input: {
key: 'objectAssignee',
value: valuesIds,
},
},
...defaultCommitMutation,
});
};
return (
<div>
{assignees.length > 0
? assignees.map((assignee) => (
<Button
<FieldOrEmpty source={assignees}>
{assignees.map((assignee) => (
<Tooltip key={assignee.id} title={assignee.name}>
<Chip
key={assignee.id}
variant="outlined"
color="primary"
size="small"
style={{ margin: '0 7px 7px 0', cursor: 'default' }}
>
{assignee.name}
</Button>
))
: '-'}
</div>
icon={<PersonOutline color={'primary'} />}
label={truncate(assignee.name, 25).toUpperCase()}
style={{
color: theme.palette.primary.main,
borderColor: theme.palette.primary.main,
margin: '0 7px 7px 0',
borderRadius: theme.borderRadius,
}}
onDelete={canUpdateKnowledge ? () => (handleRemoveAssignee(assignee.id)) : undefined}
deleteIcon={
<CancelOutlined
style={{ color: theme.palette.primary.main }}
/>
}
/>
</Tooltip>
))}
</FieldOrEmpty>
);
};

Expand Down
59 changes: 48 additions & 11 deletions opencti-platform/opencti-front/src/components/ItemParticipants.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,65 @@
import React, { FunctionComponent } from 'react';
import Button from '@mui/material/Button';
import { useTheme } from '@mui/styles';
import { CancelOutlined, PersonOutline } from '@mui/icons-material';
import Chip from '@mui/material/Chip';
import { stixDomainObjectMutation } from '@components/common/stix_domain_objects/StixDomainObjectHeader';
import Tooltip from '@mui/material/Tooltip';
import FieldOrEmpty from './FieldOrEmpty';
import type { Theme } from './Theme';
import useGranted, { KNOWLEDGE_KNUPDATE } from '../utils/hooks/useGranted';
import { truncate } from '../utils/String';
import { commitMutation, defaultCommitMutation } from '../relay/environment';

interface ItemParticipantsProps {
participants: {
readonly entity_type: string
readonly id: string
readonly name: string
}[];
stixDomainObjectId: string;
}

const ItemParticipants: FunctionComponent<ItemParticipantsProps> = ({ participants }) => {
const ItemParticipants: FunctionComponent<ItemParticipantsProps> = ({ participants, stixDomainObjectId }) => {
const theme = useTheme<Theme>();
const canUpdateKnowledge = useGranted([KNOWLEDGE_KNUPDATE]);
const handleRemoveParticipant = (removedId: string) => {
const values = participants.filter((participant) => participant.id !== removedId);
const valuesIds = values.map((value) => value.id);
commitMutation({
mutation: stixDomainObjectMutation,
variables: {
id: stixDomainObjectId,
input: {
key: 'objectParticipant',
value: valuesIds,
},
},
...defaultCommitMutation,
});
};
return (
<FieldOrEmpty source={participants}>
{participants.map((participant) => (
<Button
key={participant.id}
variant="outlined"
color="primary"
size="small"
style={{ margin: '0 7px 7px 0', cursor: 'default' }}
>
{participant.name}
</Button>
<Tooltip key={participant.id} title={participant.name}>
<Chip
key={participant.id}
variant="outlined"
icon={<PersonOutline color={'primary'} />}
label={truncate(participant.name, 25).toUpperCase()}
style={{
color: theme.palette.primary.main,
borderColor: theme.palette.primary.main,
margin: '0 7px 7px 0',
borderRadius: theme.borderRadius,
}}
onDelete={canUpdateKnowledge ? () => (handleRemoveParticipant(participant.id)) : undefined}
deleteIcon={
<CancelOutlined
style={{ color: theme.palette.primary.main }}
/>
}
/>
</Tooltip>
))}
</FieldOrEmpty>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const CaseTaskOverview: FunctionComponent<CaseTaskOverviewProps> = ({
>
{t_i18n('Assignees')}
</Typography>
<ItemAssignees assignees={data.objectAssignee ?? []} />
<ItemAssignees assignees={data.objectAssignee ?? []} stixDomainObjectId={data.id}/>
<Typography
variant="h3"
gutterBottom={true}
Expand Down
Loading

0 comments on commit af2574f

Please sign in to comment.