Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEB-3043]chore: removed guest assignees from issue filters #6402

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export const ProjectViewIssuesHeader: React.FC = observer(() => {
layoutDisplayFiltersOptions={
activeLayout ? ISSUE_DISPLAY_FILTERS_BY_LAYOUT.issues[activeLayout] : undefined
}
projectId={projectId.toString()}
labels={projectLabels}
memberIds={projectMemberIds ?? undefined}
states={projectStates}
Expand Down
1 change: 1 addition & 0 deletions web/core/components/issues/filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const HeaderFilters = observer((props: Props) => {
layoutDisplayFiltersOptions={layoutDisplayFiltersOptions}
labels={projectLabels}
memberIds={projectMemberIds ?? undefined}
projectId={projectId}
states={projectStates}
cycleViewDisabled={!currentProjectDetails?.cycle_view}
moduleViewDisabled={!currentProjectDetails?.module_view}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ import {
FilterIssueGrouping,
} from "@/components/issues";
// hooks
import { useMember } from "@/hooks/store";
import { usePlatformOS } from "@/hooks/use-platform-os";
// plane web components
import { FilterIssueTypes, FilterTeamProjects } from "@/plane-web/components/issues";
import { EUserPermissions } from "@/plane-web/constants";

type Props = {
filters: IIssueFilterOptions;
displayFilters?: IIssueDisplayFilterOptions | undefined;
handleDisplayFiltersUpdate?: (updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => void;
handleFiltersUpdate: (key: keyof IIssueFilterOptions, value: string | string[]) => void;
layoutDisplayFiltersOptions: ILayoutDisplayFiltersOptions | undefined;
projectId?: string;
labels?: IIssueLabel[] | undefined;
memberIds?: string[] | undefined;
states?: IState[] | undefined;
Expand All @@ -52,6 +55,7 @@ export const FilterSelection: React.FC<Props> = observer((props) => {
handleDisplayFiltersUpdate,
handleFiltersUpdate,
layoutDisplayFiltersOptions,
projectId,
labels,
memberIds,
states,
Expand All @@ -62,9 +66,22 @@ export const FilterSelection: React.FC<Props> = observer((props) => {
// hooks
const { isMobile } = usePlatformOS();
const { moduleId, cycleId } = useParams();
const {
project: { getProjectMemberDetails },
} = useMember();
// states
const [filtersSearchQuery, setFiltersSearchQuery] = useState("");

// filter guests from assignees
const assigneeIds = memberIds?.filter((id) => {
if (projectId) {
const memeberDetails = getProjectMemberDetails(id, projectId);
const isGuest = (memeberDetails?.role || EUserPermissions.GUEST) === EUserPermissions.GUEST;
if (isGuest && memeberDetails) return false;
}
return true;
});
Comment on lines +75 to +83
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix typos and optimize the guest filtering logic.

The guest filtering implementation has a few issues:

  1. Typo in variable name memeberDetails -> memberDetails
  2. Redundant null check after using the variable
  3. The role access can be simplified
 const assigneeIds = memberIds?.filter((id) => {
   if (projectId) {
-    const memeberDetails = getProjectMemberDetails(id, projectId);
-    const isGuest = (memeberDetails?.role || EUserPermissions.GUEST) === EUserPermissions.GUEST;
-    if (isGuest && memeberDetails) return false;
+    const memberDetails = getProjectMemberDetails(id, projectId);
+    return memberDetails?.role !== EUserPermissions.GUEST;
   }
   return true;
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// filter guests from assignees
const assigneeIds = memberIds?.filter((id) => {
if (projectId) {
const memeberDetails = getProjectMemberDetails(id, projectId);
const isGuest = (memeberDetails?.role || EUserPermissions.GUEST) === EUserPermissions.GUEST;
if (isGuest && memeberDetails) return false;
}
return true;
});
// filter guests from assignees
const assigneeIds = memberIds?.filter((id) => {
if (projectId) {
const memberDetails = getProjectMemberDetails(id, projectId);
return memberDetails?.role !== EUserPermissions.GUEST;
}
return true;
});


const isFilterEnabled = (filter: keyof IIssueFilterOptions) => layoutDisplayFiltersOptions?.filters.includes(filter);

const isDisplayFilterEnabled = (displayFilter: keyof IIssueDisplayFilterOptions) =>
Expand Down Expand Up @@ -140,7 +157,7 @@ export const FilterSelection: React.FC<Props> = observer((props) => {
<FilterAssignees
appliedFilters={filters.assignees ?? null}
handleUpdate={(val) => handleFiltersUpdate("assignees", val)}
memberIds={memberIds}
memberIds={assigneeIds}
searchQuery={filtersSearchQuery}
/>
</div>
Expand Down
Loading