From fce6907465d196bdac3a3ecdc79dbb52f2c7a044 Mon Sep 17 00:00:00 2001 From: gurusainath Date: Thu, 14 Sep 2023 22:34:44 +0530 Subject: [PATCH] chore: filter empty state handling in issue filter selection --- web/components/issue-layouts/filters/assignees.tsx | 3 ++- web/components/issue-layouts/filters/created-by.tsx | 3 ++- web/components/issue-layouts/filters/labels.tsx | 3 ++- web/components/issue-layouts/filters/priority.tsx | 3 ++- web/components/issue-layouts/filters/state-group.tsx | 3 ++- web/components/issue-layouts/filters/state.tsx | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/web/components/issue-layouts/filters/assignees.tsx b/web/components/issue-layouts/filters/assignees.tsx index e591ea44f..422318ec1 100644 --- a/web/components/issue-layouts/filters/assignees.tsx +++ b/web/components/issue-layouts/filters/assignees.tsx @@ -33,12 +33,13 @@ export const FilterAssignees = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); }; diff --git a/web/components/issue-layouts/filters/created-by.tsx b/web/components/issue-layouts/filters/created-by.tsx index e9b34342f..e2353d32c 100644 --- a/web/components/issue-layouts/filters/created-by.tsx +++ b/web/components/issue-layouts/filters/created-by.tsx @@ -16,12 +16,13 @@ export const FilterCreatedBy = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); }; diff --git a/web/components/issue-layouts/filters/labels.tsx b/web/components/issue-layouts/filters/labels.tsx index 79a82ddd2..4c42e8af9 100644 --- a/web/components/issue-layouts/filters/labels.tsx +++ b/web/components/issue-layouts/filters/labels.tsx @@ -21,12 +21,13 @@ export const FilterLabels = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); }; diff --git a/web/components/issue-layouts/filters/priority.tsx b/web/components/issue-layouts/filters/priority.tsx index 048e22469..2bbcce8f7 100644 --- a/web/components/issue-layouts/filters/priority.tsx +++ b/web/components/issue-layouts/filters/priority.tsx @@ -57,12 +57,13 @@ export const FilterPriority = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); }; diff --git a/web/components/issue-layouts/filters/state-group.tsx b/web/components/issue-layouts/filters/state-group.tsx index 1598734a7..e9ea5c6fa 100644 --- a/web/components/issue-layouts/filters/state-group.tsx +++ b/web/components/issue-layouts/filters/state-group.tsx @@ -88,12 +88,13 @@ export const FilterStateGroup = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); }; diff --git a/web/components/issue-layouts/filters/state.tsx b/web/components/issue-layouts/filters/state.tsx index 917fe2af7..bb56c2f72 100644 --- a/web/components/issue-layouts/filters/state.tsx +++ b/web/components/issue-layouts/filters/state.tsx @@ -18,12 +18,13 @@ export const FilterState = observer(() => { const [previewEnabled, setPreviewEnabled] = React.useState(true); const handleFilter = (key: string, value: string) => { - const _value = + let _value = issueFilterStore?.userFilters?.filters?.[key] != null ? issueFilterStore?.userFilters?.filters?.[key].includes(value) ? issueFilterStore?.userFilters?.filters?.[key].filter((p: string) => p != value) : [...issueFilterStore?.userFilters?.filters?.[key], value] : [value]; + _value = _value && _value.length > 0 ? _value : null; issueFilterStore.handleUserFilter("filters", key, _value); };