mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: project members fetch fix (#3145)
* chore: all issues assignee fetch fix * chore: assignee fetch logic updated
This commit is contained in:
parent
8a1a6c6f62
commit
31fdaf2659
@ -42,7 +42,7 @@ export const IssuePropertyAssignee: React.FC<IIssuePropertyAssignee> = observer(
|
|||||||
// store
|
// store
|
||||||
const {
|
const {
|
||||||
workspace: workspaceStore,
|
workspace: workspaceStore,
|
||||||
projectMember: { projectMembers: _projectMembers, fetchProjectMembers },
|
projectMember: { members: _members, fetchProjectMembers },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
const workspaceSlug = workspaceStore?.workspaceSlug;
|
const workspaceSlug = workspaceStore?.workspaceSlug;
|
||||||
// states
|
// states
|
||||||
@ -51,14 +51,14 @@ export const IssuePropertyAssignee: React.FC<IIssuePropertyAssignee> = observer(
|
|||||||
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
|
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState<Boolean>(false);
|
const [isLoading, setIsLoading] = useState<Boolean>(false);
|
||||||
|
|
||||||
const getWorkspaceMembers = () => {
|
const getProjectMembers = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
if (workspaceSlug && projectId) fetchProjectMembers(workspaceSlug, projectId).then(() => setIsLoading(false));
|
if (workspaceSlug && projectId) fetchProjectMembers(workspaceSlug, projectId).then(() => setIsLoading(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updatedDefaultOptions: IProjectMember[] =
|
const updatedDefaultOptions: IProjectMember[] =
|
||||||
defaultOptions.map((member: any) => ({ member: { ...member } })) ?? [];
|
defaultOptions.map((member: any) => ({ member: { ...member } })) ?? [];
|
||||||
const projectMembers = _projectMembers ?? updatedDefaultOptions;
|
const projectMembers = projectId && _members[projectId] ? _members[projectId] : updatedDefaultOptions;
|
||||||
|
|
||||||
const options = projectMembers?.map((member) => ({
|
const options = projectMembers?.map((member) => ({
|
||||||
value: member.member.id,
|
value: member.member.id,
|
||||||
@ -142,7 +142,7 @@ export const IssuePropertyAssignee: React.FC<IIssuePropertyAssignee> = observer(
|
|||||||
className={`flex w-full items-center justify-between gap-1 text-xs ${
|
className={`flex w-full items-center justify-between gap-1 text-xs ${
|
||||||
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer"
|
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer"
|
||||||
} ${buttonClassName}`}
|
} ${buttonClassName}`}
|
||||||
onClick={() => !projectMembers && getWorkspaceMembers()}
|
onClick={() => (!projectId || !_members[projectId]) && getProjectMembers()}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
{!hideDropdownArrow && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
{!hideDropdownArrow && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
||||||
@ -168,7 +168,7 @@ export const IssuePropertyAssignee: React.FC<IIssuePropertyAssignee> = observer(
|
|||||||
<div className={`mt-2 max-h-48 space-y-1 overflow-y-scroll`}>
|
<div className={`mt-2 max-h-48 space-y-1 overflow-y-scroll`}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<p className="text-center text-custom-text-200">Loading...</p>
|
<p className="text-center text-custom-text-200">Loading...</p>
|
||||||
) : filteredOptions.length > 0 ? (
|
) : filteredOptions && filteredOptions.length > 0 ? (
|
||||||
filteredOptions.map((option) => (
|
filteredOptions.map((option) => (
|
||||||
<Combobox.Option
|
<Combobox.Option
|
||||||
key={option.value}
|
key={option.value}
|
||||||
|
Loading…
Reference in New Issue
Block a user