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

chore: dynamic position dropdown #2138

Merged
merged 20 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f2d5761
chore: dynamic position state dropdown for issue view
anmolsinghbhatia Sep 11, 2023
fd7ddee
style: state select dropdown styling
anmolsinghbhatia Sep 11, 2023
7d4f7a1
Merge branch 'develop' of https://github.com/makeplane/plane into cho…
aaryan610 Sep 11, 2023
3474edb
fix: state icon attribute names
aaryan610 Sep 11, 2023
bdb5255
Merge branch 'develop' of github.com:makeplane/plane into chore/state…
anmolsinghbhatia Sep 13, 2023
9cade4a
fix: merge conflict
anmolsinghbhatia Sep 15, 2023
a5817cd
Merge branch 'develop' of github.com:makeplane/plane into chore/state…
anmolsinghbhatia Sep 15, 2023
8ec2245
Merge branch 'chore/state_dropdown' of github.com:makeplane/plane int…
anmolsinghbhatia Sep 15, 2023
2788d38
Merge branch 'develop' of github.com:makeplane/plane into chore/state…
anmolsinghbhatia Sep 15, 2023
863cf6e
Merge branch 'develop' of github.com:makeplane/plane into chore/state…
anmolsinghbhatia Sep 15, 2023
3052269
chore: state select dynamic dropdown
anmolsinghbhatia Sep 19, 2023
0bffe3a
Merge branch 'develop' of github.com:makeplane/plane into chore/state…
anmolsinghbhatia Sep 19, 2023
74bc8e5
chore: member select dynamic dropdown
anmolsinghbhatia Sep 19, 2023
d6c96d4
chore: label select dynamic dropdown
anmolsinghbhatia Sep 19, 2023
3f9076b
chore: priority select dynamic dropdown
anmolsinghbhatia Sep 19, 2023
3cbf8cf
chore: label select dropdown improvement
anmolsinghbhatia Sep 19, 2023
9c9d6f4
Merge branch 'develop' of https://github.com/makeplane/plane into cho…
aaryan610 Sep 19, 2023
5cbe41c
refactor: state dropdown location
aaryan610 Sep 19, 2023
0c63c69
chore: dropdown improvement and code refactor
Sep 19, 2023
23135ad
chore: dynamic dropdown hook type added
Sep 20, 2023
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
2 changes: 0 additions & 2 deletions web/components/core/views/board-view/board-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export const BoardHeader: React.FC<Props> = ({

const { displayFilters, groupedIssues } = viewProps;

console.log("dF", displayFilters);

const { data: issueLabels } = useSWR(
workspaceSlug && projectId && displayFilters?.group_by === "labels"
? PROJECT_ISSUE_LABELS(projectId.toString())
Expand Down
150 changes: 118 additions & 32 deletions web/components/core/views/board-view/single-issue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ import {
} from "react-beautiful-dnd";
// services
import issuesService from "services/issues.service";
import trackEventServices from "services/track-event.service";
// hooks
import useToast from "hooks/use-toast";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// components
import {
ViewAssigneeSelect,
ViewDueDateSelect,
ViewEstimateSelect,
ViewIssueLabel,
ViewPrioritySelect,
ViewStartDateSelect,
ViewStateSelect,
} from "components/issues";
import { ViewDueDateSelect, ViewEstimateSelect, ViewStartDateSelect } from "components/issues";
import { MembersSelect, LabelSelect, PrioritySelect } from "components/project";
import { StateSelect } from "components/states";
// ui
import { ContextMenu, CustomMenu, Tooltip } from "components/ui";
// icons
Expand All @@ -44,7 +39,15 @@ import { LayerDiagonalIcon } from "components/icons";
import { handleIssuesMutation } from "constants/issue";
import { copyTextToClipboard } from "helpers/string.helper";
// types
import { ICurrentUserResponse, IIssue, IIssueViewProps, ISubIssueResponse, UserAuth } from "types";
import {
ICurrentUserResponse,
IIssue,
IIssueViewProps,
IState,
ISubIssueResponse,
TIssuePriorities,
UserAuth,
} from "types";
// fetch-keys
import { CYCLE_DETAILS, MODULE_DETAILS, SUB_ISSUES } from "constants/fetch-keys";

Expand Down Expand Up @@ -188,6 +191,86 @@ export const SingleBoardIssue: React.FC<Props> = ({
});
};

const handleStateChange = (data: string, states: IState[] | undefined) => {
const oldState = states?.find((s) => s.id === issue.state);
const newState = states?.find((s) => s.id === data);

partialUpdateIssue(
{
state: data,
state_detail: newState,
},
issue
);
trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug,
workspaceId: issue.workspace,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_STATE",
user
);
if (oldState?.group !== "completed" && newState?.group !== "completed") {
trackEventServices.trackIssueMarkedAsDoneEvent(
{
workspaceSlug: issue.workspace_detail.slug,
workspaceId: issue.workspace_detail.id,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
user
);
}
};

const handleAssigneeChange = (data: any) => {
const newData = issue.assignees ?? [];

if (newData.includes(data)) newData.splice(newData.indexOf(data), 1);
else newData.push(data);

partialUpdateIssue({ assignees_list: data }, issue);

trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug,
workspaceId: issue.workspace,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_ASSIGNEE",
user
);
};

const handleLabelChange = (data: any) => {
partialUpdateIssue({ labels_list: data }, issue);
};

const handlePriorityChange = (data: TIssuePriorities) => {
partialUpdateIssue({ priority: data }, issue);
trackEventServices.trackIssuePartialPropertyUpdateEvent(
{
workspaceSlug,
workspaceId: issue.workspace,
projectId: issue.project_detail.id,
projectIdentifier: issue.project_detail.identifier,
projectName: issue.project_detail.name,
issueId: issue.id,
},
"ISSUE_PROPERTY_UPDATE_PRIORITY",
user
);
};

useEffect(() => {
if (snapshot.isDragging) handleTrashBox(snapshot.isDragging);
}, [snapshot, handleTrashBox]);
Expand Down Expand Up @@ -343,13 +426,12 @@ export const SingleBoardIssue: React.FC<Props> = ({
)}
<button
type="button"
className="text-sm text-left break-words line-clamp-2"
onClick={() => {
if (isDraftIssue && handleDraftIssueEdit) handleDraftIssueEdit();
else openPeekOverview();
}}
>
{issue.name}
<span className="text-sm text-left break-words line-clamp-2">{issue.name}</span>
</button>
</div>

Expand All @@ -359,21 +441,19 @@ export const SingleBoardIssue: React.FC<Props> = ({
}`}
>
{properties.priority && (
<ViewPrioritySelect
issue={issue}
partialUpdateIssue={partialUpdateIssue}
isNotAllowed={isNotAllowed}
user={user}
selfPositioned
<PrioritySelect
value={issue.priority}
onChange={handlePriorityChange}
hideDropdownArrow
disabled={isNotAllowed}
/>
)}
{properties.state && (
<ViewStateSelect
issue={issue}
partialUpdateIssue={partialUpdateIssue}
isNotAllowed={isNotAllowed}
user={user}
selfPositioned
<StateSelect
value={issue.state_detail}
onChange={handleStateChange}
hideDropdownArrow
disabled={isNotAllowed}
/>
)}
{properties.start_date && issue.start_date && (
Expand All @@ -397,16 +477,22 @@ export const SingleBoardIssue: React.FC<Props> = ({
/>
)}
{properties.labels && issue.labels.length > 0 && (
<ViewIssueLabel labelDetails={issue.label_details} maxRender={2} />
<LabelSelect
value={issue.labels}
onChange={handleLabelChange}
labelsDetails={issue.label_details}
hideDropdownArrow
user={user}
disabled={isNotAllowed}
/>
)}
{properties.assignee && (
<ViewAssigneeSelect
issue={issue}
partialUpdateIssue={partialUpdateIssue}
isNotAllowed={isNotAllowed}
customButton
user={user}
selfPositioned
<MembersSelect
value={issue.assignees}
onChange={handleAssigneeChange}
membersDetails={issue.assignee_details}
hideDropdownArrow
disabled={isNotAllowed}
/>
)}
{properties.estimate && issue.estimate_point !== null && (
Expand Down
Loading
Loading