fix: bug fix related to fetching dropdown options for the profile issue (#2246)

This commit is contained in:
Anmol Singh Bhatia 2023-09-25 12:18:35 +05:30 committed by GitHub
parent e8d303dd10
commit 68c8741f93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 21 deletions

View File

@ -157,6 +157,7 @@ export const SingleBoard: React.FC<Props> = (props) => {
type={type} type={type}
index={index} index={index}
issue={issue} issue={issue}
projectId={issue.project_detail.id}
groupTitle={groupTitle} groupTitle={groupTitle}
editIssue={() => handleIssueAction(issue, "edit")} editIssue={() => handleIssueAction(issue, "edit")}
makeIssueCopy={() => handleIssueAction(issue, "copy")} makeIssueCopy={() => handleIssueAction(issue, "copy")}

View File

@ -56,6 +56,7 @@ type Props = {
provided: DraggableProvided; provided: DraggableProvided;
snapshot: DraggableStateSnapshot; snapshot: DraggableStateSnapshot;
issue: IIssue; issue: IIssue;
projectId: string;
groupTitle?: string; groupTitle?: string;
index: number; index: number;
editIssue: () => void; editIssue: () => void;
@ -77,6 +78,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
provided, provided,
snapshot, snapshot,
issue, issue,
projectId,
index, index,
editIssue, editIssue,
makeIssueCopy, makeIssueCopy,
@ -104,7 +106,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
const { displayFilters, properties, mutateIssues } = viewProps; const { displayFilters, properties, mutateIssues } = viewProps;
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId, moduleId } = router.query; const { workspaceSlug, cycleId, moduleId } = router.query;
const isDraftIssue = router.pathname.includes("draft-issues"); const isDraftIssue = router.pathname.includes("draft-issues");
@ -452,6 +454,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
onChange={handleStateChange} onChange={handleStateChange}
projectId={projectId}
hideDropdownArrow hideDropdownArrow
disabled={isNotAllowed} disabled={isNotAllowed}
/> />
@ -479,6 +482,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
{properties.labels && issue.labels.length > 0 && ( {properties.labels && issue.labels.length > 0 && (
<LabelSelect <LabelSelect
value={issue.labels} value={issue.labels}
projectId={projectId}
onChange={handleLabelChange} onChange={handleLabelChange}
labelsDetails={issue.label_details} labelsDetails={issue.label_details}
hideDropdownArrow hideDropdownArrow
@ -489,6 +493,7 @@ export const SingleBoardIssue: React.FC<Props> = ({
{properties.assignee && ( {properties.assignee && (
<MembersSelect <MembersSelect
value={issue.assignees} value={issue.assignees}
projectId={projectId}
onChange={handleAssigneeChange} onChange={handleAssigneeChange}
membersDetails={issue.assignee_details} membersDetails={issue.assignee_details}
hideDropdownArrow hideDropdownArrow

View File

@ -71,6 +71,7 @@ export const SingleCalendarDate: React.FC<Props> = (props) => {
provided={provided} provided={provided}
snapshot={snapshot} snapshot={snapshot}
issue={issue} issue={issue}
projectId={issue.project_detail.id}
handleEditIssue={() => handleIssueAction(issue, "edit")} handleEditIssue={() => handleIssueAction(issue, "edit")}
handleDeleteIssue={() => handleIssueAction(issue, "delete")} handleDeleteIssue={() => handleIssueAction(issue, "delete")}
user={user} user={user}

View File

@ -41,6 +41,7 @@ type Props = {
provided: DraggableProvided; provided: DraggableProvided;
snapshot: DraggableStateSnapshot; snapshot: DraggableStateSnapshot;
issue: IIssue; issue: IIssue;
projectId: string;
user: ICurrentUserResponse | undefined; user: ICurrentUserResponse | undefined;
isNotAllowed: boolean; isNotAllowed: boolean;
}; };
@ -52,11 +53,12 @@ export const SingleCalendarIssue: React.FC<Props> = ({
provided, provided,
snapshot, snapshot,
issue, issue,
projectId,
user, user,
isNotAllowed, isNotAllowed,
}) => { }) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query; const { workspaceSlug, cycleId, moduleId, viewId } = router.query;
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -310,6 +312,7 @@ export const SingleCalendarIssue: React.FC<Props> = ({
{properties.state && ( {properties.state && (
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
projectId={projectId}
onChange={handleStateChange} onChange={handleStateChange}
hideDropdownArrow hideDropdownArrow
disabled={isNotAllowed} disabled={isNotAllowed}
@ -334,6 +337,7 @@ export const SingleCalendarIssue: React.FC<Props> = ({
{properties.labels && issue.labels.length > 0 && ( {properties.labels && issue.labels.length > 0 && (
<LabelSelect <LabelSelect
value={issue.labels} value={issue.labels}
projectId={projectId}
onChange={handleLabelChange} onChange={handleLabelChange}
labelsDetails={issue.label_details} labelsDetails={issue.label_details}
hideDropdownArrow hideDropdownArrow
@ -345,6 +349,7 @@ export const SingleCalendarIssue: React.FC<Props> = ({
{properties.assignee && ( {properties.assignee && (
<MembersSelect <MembersSelect
value={issue.assignees} value={issue.assignees}
projectId={projectId}
onChange={handleAssigneeChange} onChange={handleAssigneeChange}
membersDetails={issue.assignee_details} membersDetails={issue.assignee_details}
hideDropdownArrow hideDropdownArrow

View File

@ -51,6 +51,7 @@ import {
type Props = { type Props = {
type?: string; type?: string;
issue: IIssue; issue: IIssue;
projectId: string;
groupTitle?: string; groupTitle?: string;
editIssue: () => void; editIssue: () => void;
index: number; index: number;
@ -69,6 +70,7 @@ type Props = {
export const SingleListIssue: React.FC<Props> = ({ export const SingleListIssue: React.FC<Props> = ({
type, type,
issue, issue,
projectId,
editIssue, editIssue,
index, index,
makeIssueCopy, makeIssueCopy,
@ -88,7 +90,7 @@ export const SingleListIssue: React.FC<Props> = ({
const [contextMenuPosition, setContextMenuPosition] = useState<React.MouseEvent | null>(null); const [contextMenuPosition, setContextMenuPosition] = useState<React.MouseEvent | null>(null);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId, moduleId, userId } = router.query; const { workspaceSlug, cycleId, moduleId, userId } = router.query;
const isArchivedIssues = router.pathname.includes("archived-issues"); const isArchivedIssues = router.pathname.includes("archived-issues");
const isDraftIssues = router.pathname?.split("/")?.[4] === "draft-issues"; const isDraftIssues = router.pathname?.split("/")?.[4] === "draft-issues";
@ -376,6 +378,7 @@ export const SingleListIssue: React.FC<Props> = ({
{properties.state && ( {properties.state && (
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
projectId={projectId}
onChange={handleStateChange} onChange={handleStateChange}
hideDropdownArrow hideDropdownArrow
disabled={isNotAllowed} disabled={isNotAllowed}
@ -400,6 +403,7 @@ export const SingleListIssue: React.FC<Props> = ({
{properties.labels && ( {properties.labels && (
<LabelSelect <LabelSelect
value={issue.labels} value={issue.labels}
projectId={projectId}
onChange={handleLabelChange} onChange={handleLabelChange}
labelsDetails={issue.label_details} labelsDetails={issue.label_details}
hideDropdownArrow hideDropdownArrow
@ -411,6 +415,7 @@ export const SingleListIssue: React.FC<Props> = ({
{properties.assignee && ( {properties.assignee && (
<MembersSelect <MembersSelect
value={issue.assignees} value={issue.assignees}
projectId={projectId}
onChange={handleAssigneeChange} onChange={handleAssigneeChange}
membersDetails={issue.assignee_details} membersDetails={issue.assignee_details}
hideDropdownArrow hideDropdownArrow

View File

@ -258,6 +258,7 @@ export const SingleList: React.FC<Props> = (props) => {
key={issue.id} key={issue.id}
type={type} type={type}
issue={issue} issue={issue}
projectId={issue.project_detail.id}
groupTitle={groupTitle} groupTitle={groupTitle}
index={index} index={index}
editIssue={() => handleIssueAction(issue, "edit")} editIssue={() => handleIssueAction(issue, "edit")}

View File

@ -49,6 +49,7 @@ import { renderLongDetailDateFormat } from "helpers/date-time.helper";
type Props = { type Props = {
issue: IIssue; issue: IIssue;
projectId: string;
index: number; index: number;
expanded: boolean; expanded: boolean;
handleToggleExpand: (issueId: string) => void; handleToggleExpand: (issueId: string) => void;
@ -64,6 +65,7 @@ type Props = {
export const SingleSpreadsheetIssue: React.FC<Props> = ({ export const SingleSpreadsheetIssue: React.FC<Props> = ({
issue, issue,
projectId,
index, index,
expanded, expanded,
handleToggleExpand, handleToggleExpand,
@ -80,7 +82,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query; const { workspaceSlug, cycleId, moduleId, viewId } = router.query;
const { params } = useSpreadsheetIssuesView(); const { params } = useSpreadsheetIssuesView();
@ -96,7 +98,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params) ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params)
: viewId : viewId
? VIEW_ISSUES(viewId.toString(), params) ? VIEW_ISSUES(viewId.toString(), params)
: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId.toString(), params); : PROJECT_ISSUES_LIST_WITH_PARAMS(projectId, params);
if (issue.parent) if (issue.parent)
mutate<ISubIssueResponse>( mutate<ISubIssueResponse>(
@ -136,13 +138,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
); );
issuesService issuesService
.patchIssue( .patchIssue(workspaceSlug as string, projectId, issue.id as string, formData, user)
workspaceSlug as string,
projectId as string,
issue.id as string,
formData,
user
)
.then(() => { .then(() => {
if (issue.parent) { if (issue.parent) {
mutate(SUB_ISSUES(issue.parent as string)); mutate(SUB_ISSUES(issue.parent as string));
@ -368,6 +364,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
<div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200"> <div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200">
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
projectId={projectId}
onChange={handleStateChange} onChange={handleStateChange}
buttonClassName="!p-0 !rounded-none !shadow-none !border-0" buttonClassName="!p-0 !rounded-none !shadow-none !border-0"
hideDropdownArrow hideDropdownArrow
@ -390,6 +387,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
<div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200"> <div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200">
<MembersSelect <MembersSelect
value={issue.assignees} value={issue.assignees}
projectId={projectId}
onChange={handleAssigneeChange} onChange={handleAssigneeChange}
membersDetails={issue.assignee_details} membersDetails={issue.assignee_details}
buttonClassName="!p-0 !rounded-none !shadow-none !border-0" buttonClassName="!p-0 !rounded-none !shadow-none !border-0"
@ -402,6 +400,7 @@ export const SingleSpreadsheetIssue: React.FC<Props> = ({
<div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200"> <div className="flex items-center text-xs text-custom-text-200 text-center p-2 group-hover:bg-custom-background-80 border-custom-border-200">
<LabelSelect <LabelSelect
value={issue.labels} value={issue.labels}
projectId={projectId}
onChange={handleLabelChange} onChange={handleLabelChange}
labelsDetails={issue.label_details} labelsDetails={issue.label_details}
hideDropdownArrow hideDropdownArrow

View File

@ -55,6 +55,7 @@ export const SpreadsheetIssues: React.FC<Props> = ({
<div> <div>
<SingleSpreadsheetIssue <SingleSpreadsheetIssue
issue={issue} issue={issue}
projectId={issue.project_detail.id}
index={index} index={index}
expanded={isExpanded} expanded={isExpanded}
handleToggleExpand={handleToggleExpand} handleToggleExpand={handleToggleExpand}

View File

@ -24,6 +24,7 @@ import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
type Props = { type Props = {
value: string[]; value: string[];
projectId: string;
onChange: (data: any) => void; onChange: (data: any) => void;
labelsDetails: any[]; labelsDetails: any[];
className?: string; className?: string;
@ -37,6 +38,7 @@ type Props = {
export const LabelSelect: React.FC<Props> = ({ export const LabelSelect: React.FC<Props> = ({
value, value,
projectId,
onChange, onChange,
labelsDetails, labelsDetails,
className = "", className = "",
@ -54,15 +56,15 @@ export const LabelSelect: React.FC<Props> = ({
const [labelModal, setLabelModal] = useState(false); const [labelModal, setLabelModal] = useState(false);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug } = router.query;
const dropdownBtn = useRef<any>(null); const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null); const dropdownOptions = useRef<any>(null);
const { data: issueLabels } = useSWR<IIssueLabels[]>( const { data: issueLabels } = useSWR<IIssueLabels[]>(
projectId && fetchStates ? PROJECT_ISSUE_LABELS(projectId.toString()) : null, projectId && fetchStates ? PROJECT_ISSUE_LABELS(projectId) : null,
workspaceSlug && projectId && fetchStates workspaceSlug && projectId && fetchStates
? () => issuesService.getIssueLabels(workspaceSlug as string, projectId as string) ? () => issuesService.getIssueLabels(workspaceSlug as string, projectId)
: null : null
); );
@ -150,7 +152,7 @@ export const LabelSelect: React.FC<Props> = ({
<CreateLabelModal <CreateLabelModal
isOpen={labelModal} isOpen={labelModal}
handleClose={() => setLabelModal(false)} handleClose={() => setLabelModal(false)}
projectId={projectId.toString()} projectId={projectId}
user={user} user={user}
/> />
)} )}

View File

@ -18,6 +18,7 @@ import { IUser } from "types";
type Props = { type Props = {
value: string | string[]; value: string | string[];
projectId: string;
onChange: (data: any) => void; onChange: (data: any) => void;
membersDetails: IUser[]; membersDetails: IUser[];
renderWorkspaceMembers?: boolean; renderWorkspaceMembers?: boolean;
@ -30,6 +31,7 @@ type Props = {
export const MembersSelect: React.FC<Props> = ({ export const MembersSelect: React.FC<Props> = ({
value, value,
projectId,
onChange, onChange,
membersDetails, membersDetails,
renderWorkspaceMembers = false, renderWorkspaceMembers = false,
@ -44,14 +46,14 @@ export const MembersSelect: React.FC<Props> = ({
const [fetchStates, setFetchStates] = useState(false); const [fetchStates, setFetchStates] = useState(false);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug } = router.query;
const dropdownBtn = useRef<any>(null); const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null); const dropdownOptions = useRef<any>(null);
const { members } = useProjectMembers( const { members } = useProjectMembers(
workspaceSlug?.toString(), workspaceSlug?.toString(),
projectId?.toString(), projectId,
fetchStates && !renderWorkspaceMembers fetchStates && !renderWorkspaceMembers
); );

View File

@ -25,6 +25,7 @@ import { getStatesList } from "helpers/state.helper";
type Props = { type Props = {
value: IState; value: IState;
onChange: (data: any, states: IState[] | undefined) => void; onChange: (data: any, states: IState[] | undefined) => void;
projectId: string;
className?: string; className?: string;
buttonClassName?: string; buttonClassName?: string;
optionsClassName?: string; optionsClassName?: string;
@ -35,6 +36,7 @@ type Props = {
export const StateSelect: React.FC<Props> = ({ export const StateSelect: React.FC<Props> = ({
value, value,
onChange, onChange,
projectId,
className = "", className = "",
buttonClassName = "", buttonClassName = "",
optionsClassName = "", optionsClassName = "",
@ -50,12 +52,12 @@ export const StateSelect: React.FC<Props> = ({
const [fetchStates, setFetchStates] = useState<boolean>(false); const [fetchStates, setFetchStates] = useState<boolean>(false);
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug } = router.query;
const { data: stateGroups } = useSWR( const { data: stateGroups } = useSWR(
workspaceSlug && projectId && fetchStates ? STATES_LIST(projectId as string) : null, workspaceSlug && projectId && fetchStates ? STATES_LIST(projectId) : null,
workspaceSlug && projectId && fetchStates workspaceSlug && projectId && fetchStates
? () => stateService.getStates(workspaceSlug as string, projectId as string) ? () => stateService.getStates(workspaceSlug as string, projectId)
: null : null
); );