Skip to content

Commit

Permalink
added editor for reviewers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish8689 committed Sep 27, 2024
1 parent dde2c0b commit 7a4500b
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import { Form } from 'antd';
import { DefaultOptionType } from 'antd/lib/select';
import { t } from 'i18next';
import { toString } from 'lodash';
import React, { ReactNode } from 'react';
import TreeAsyncSelectList from '../../components/common/AsyncSelectList/TreeAsyncSelectList';
Expand Down Expand Up @@ -230,6 +231,54 @@ class CSVUtilsClassBase {
</DomainSelectableList>
);
};
case 'reviewers':
return ({ value, ...props }: EditorProps) => {
const reviewers = value?.split(';') ?? [];
const reviewersEntityRef = reviewers.map((reviewer) => {
const [type, user] = reviewer.split(':');

return {
type,
name: user,
id: user,
} as EntityReference;
});

const handleChange = (reviewers?: EntityReference[]) => {
if (!reviewers || reviewers.length === 0) {
props.onChange();

setTimeout(() => {
props.onComplete();
}, 1);

return;
}
const reviewerText = reviewers
.map((reviewer) => `${reviewer.type}:${reviewer.name}`)
.join(';');
props.onChange(reviewerText);

setTimeout(() => {
props.onComplete(reviewerText);
}, 1);
};

return (
<UserTeamSelectableList
hasPermission
previewSelected
label={t('label.reviewer-plural')}
listHeight={200}
multiple={{ user: true, team: false }}
owner={reviewersEntityRef}
popoverProps={{
open: true,
}}
onUpdate={handleChange}
/>
);
};
case 'extension':
return ({ value, ...props }: EditorProps) => {
const handleSave = async (extension: string) => {
Expand Down

0 comments on commit 7a4500b

Please sign in to comment.