chore: add select all/deselect all functionality when adding existing work item (#7045)
* chore: add select all/deselect all functionality * chore: update button display logic by CR
This commit is contained in:
parent
7c336a65c4
commit
64da29b0d9
20 changed files with 83 additions and 25 deletions
|
|
@ -110,6 +110,10 @@ export const ExistingIssuesListModal: React.FC<Props> = (props) => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleSelectIssues = () => {
|
||||
setSelectedIssues((prevData) => (prevData.length === filteredIssues.length ? [] : [...filteredIssues]));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedWorkItems) {
|
||||
setSelectedIssues(selectedWorkItems);
|
||||
|
|
@ -317,15 +321,31 @@ export const ExistingIssuesListModal: React.FC<Props> = (props) => {
|
|||
)}
|
||||
</Combobox.Options>
|
||||
</Combobox>
|
||||
<div className="flex items-center justify-end gap-2 p-3">
|
||||
<Button variant="neutral-primary" size="sm" onClick={handleClose}>
|
||||
{t("common.cancel")}
|
||||
<div className="flex justify-between items-center">
|
||||
<Button
|
||||
variant="link-primary"
|
||||
size="sm"
|
||||
onClick={handleSelectIssues}
|
||||
disabled={filteredIssues.length === 0}
|
||||
>
|
||||
{selectedIssues.length === issues.length
|
||||
? t("issue.select.deselect_all")
|
||||
: t("issue.select.select_all")}
|
||||
</Button>
|
||||
{selectedIssues.length > 0 && (
|
||||
<Button variant="primary" size="sm" onClick={onSubmit} loading={isSubmitting}>
|
||||
<div className="flex items-center justify-end gap-2 p-3">
|
||||
<Button variant="neutral-primary" size="sm" onClick={handleClose}>
|
||||
{t("common.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
size="sm"
|
||||
onClick={onSubmit}
|
||||
loading={isSubmitting}
|
||||
disabled={isSubmitting || selectedIssues.length === 0}
|
||||
>
|
||||
{isSubmitting ? t("common.adding") : t("issue.select.add_selected")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Panel>
|
||||
</Transition.Child>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue