Skip to content

Commit

Permalink
[frontend] add current user first in assignee/participant field (#4333)
Browse files Browse the repository at this point in the history
  • Loading branch information
frapuks authored Nov 4, 2024
1 parent 3e0f5a7 commit 00ce6a6
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 10 deletions.
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "Aktuelle spezifische Zugriffe",
"Current stable score": "Aktuelle stabile Punktzahl",
"Current state": "Aktueller Zustand",
"Current User": "Aktueller Benutzer",
"Custom dashboard": "Benutzerdefiniertes Dashboard",
"Custom dashboards": "Benutzerdefinierte Dashboards",
"Customization": "Anpassungen",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "Current specific accesses",
"Current stable score": "Current stable score",
"Current state": "Current state",
"Current User": "Current User",
"Custom dashboard": "Custom dashboard",
"Custom dashboards": "Custom dashboards",
"Customization": "Customization",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "Accesos específicos actuales",
"Current stable score": "Puntuación estable actual",
"Current state": "Estado actual",
"Current User": "Usuario actual",
"Custom dashboard": "Cuadro de mando personalizado",
"Custom dashboards": "Cuadros de mando personalizados",
"Customization": "Personalización",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "Accès spécifiques actuels",
"Current stable score": "Score stable actuel",
"Current state": "Etat actuel",
"Current User": "Utilisateur actuel",
"Custom dashboard": "Tableau de bord personnalisé",
"Custom dashboards": "Tableaux de bord personnalisés",
"Customization": "Personnalisation",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "現在の特定のアクセス",
"Current stable score": "現在の安定スコア",
"Current state": "現在の状態",
"Current User": "現在のユーザー",
"Custom dashboard": "カスタムダッシュボード",
"Custom dashboards": "カスタムダッシュボード",
"Customization": "カスタマイズ",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "현재 특정 접근",
"Current stable score": "현재 안정 점수",
"Current state": "현재 상태",
"Current User": "현재 사용자",
"Custom dashboard": "맞춤 대시보드",
"Custom dashboards": "맞춤 대시보드",
"Customization": "맞춤 설정",
Expand Down
1 change: 1 addition & 0 deletions opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@
"Current specific accesses": "当前特定访问权限",
"Current stable score": "当前稳定分数",
"Current state": "当前状态",
"Current User": "当前用户",
"Custom dashboard": "自定义仪表盘",
"Custom dashboards": "自定义仪表盘",
"Customization": "定制化",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const useStyles = makeStyles<Theme>((theme) => ({

interface OptionAssignee extends Option {
type: string;
group: string;
}
interface ObjectAssigneeFieldProps {
name: string;
Expand Down Expand Up @@ -102,11 +103,19 @@ const ObjectAssigneeField: FunctionComponent<ObjectAssigneeFieldProps> = ({
.then((data) => {
const newAssignees = (
(data as ObjectAssigneeFieldMembersSearchQuery$data)?.members?.edges ?? []
).map((n) => ({
label: n.node.name,
value: n.node.id,
type: n.node.entity_type,
})).sort((a, b) => {
).map((n) => {
const group = n.node.id === me?.id ? t_i18n('Current User') : t_i18n('All');
return {
label: n.node.name,
value: n.node.id,
type: n.node.entity_type,
group,
};
});
// Add current user if is not in the only first results displayed
const isMeDisplayed = newAssignees.find((assignee) => assignee.value === me?.id);
if (me && !isMeDisplayed) newAssignees.unshift({ label: me.name, value: me.id, type: 'User', group: t_i18n('Current User') });
newAssignees.sort((a, b) => {
// Display first the current user
if (a.value === me?.id) return -1;
if (b.value === me?.id) return 1;
Expand All @@ -124,6 +133,7 @@ const ObjectAssigneeField: FunctionComponent<ObjectAssigneeFieldProps> = ({
disabled={disabled}
required={required}
multiple={true}
groupBy={(option: OptionAssignee) => option.group}
textfieldprops={{
variant: 'standard',
label: label ?? t_i18n('Assignee(s)'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const useStyles = makeStyles<Theme>((theme) => ({

interface OptionParticipant extends Option {
type: string;
group: string;
}
interface ObjectParticipantFieldProps {
name: string;
Expand Down Expand Up @@ -93,11 +94,19 @@ const ObjectParticipantField: FunctionComponent<ObjectParticipantFieldProps> = (
.then((data) => {
const newParticipants = (
(data as ObjectParticipantFieldMembersSearchQuery$data)?.members?.edges ?? []
).map((n) => ({
label: n.node.name,
value: n.node.id,
type: n.node.entity_type,
})).sort((a, b) => {
).map((n) => {
const group = n.node.id === me?.id ? t_i18n('Current User') : t_i18n('All');
return {
label: n.node.name,
value: n.node.id,
type: n.node.entity_type,
group,
};
});
// Add current user if is not in the only first results displayed
const isMeDisplayed = newParticipants.find((participant) => participant.value === me?.id);
if (me && !isMeDisplayed) newParticipants.unshift({ label: me.name, value: me.id, type: 'User', group: t_i18n('Current User') });
newParticipants.sort((a, b) => {
// Display first the current user
if (a.value === me?.id) return -1;
if (b.value === me?.id) return 1;
Expand All @@ -115,6 +124,7 @@ const ObjectParticipantField: FunctionComponent<ObjectParticipantFieldProps> = (
required={required}
disabled={disabled}
multiple={true}
groupBy={(option: OptionParticipant) => option.group}
textfieldprops={{
variant: 'standard',
label: label ?? t_i18n('Participant(s)'),
Expand Down

0 comments on commit 00ce6a6

Please sign in to comment.