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:
Quang Hung Pham 2025-06-02 08:00:31 +00:00 committed by GitHub
parent 7c336a65c4
commit 64da29b0d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 83 additions and 25 deletions

View file

@ -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>