-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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-2388] dev: workspace draft issues #5772
Changes from all commits
9f61c30
76b2308
d1fceda
2359b5c
3bba839
2fba20c
bdbc763
0cd0f6d
623ada4
4520959
ff4b2c1
90a0fca
d404671
abaf8cd
131519a
83ed3fb
11d1c5f
ba8b20b
8fab9ed
d7d8f99
6f90514
54c22b3
88a9fb0
684d5fc
0dd4cbe
a9f4294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,7 @@ def get_result(self, limit=1000, cursor=None): | |
raise BadPaginationError("Pagination offset cannot be negative") | ||
|
||
results = queryset[offset:stop] | ||
|
||
print(limit, "limit") | ||
if cursor.value != limit: | ||
results = results[-(limit + 1) :] | ||
Comment on lines
+153
to
155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove debug print and review slicing logic
Consider removing the print statement and reverting the slicing logic to its previous implementation unless there's a specific reason for this change that's not apparent from the context provided. |
||
|
||
|
@@ -761,7 +761,7 @@ def paginate( | |
): | ||
"""Paginate the request""" | ||
per_page = self.get_per_page(request, default_per_page, max_per_page) | ||
|
||
print(per_page, "per_page") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace debug prints with proper logging There are two print statements added for debugging purposes:
These should be removed or replaced with proper logging before merging to production. Replace the print statements with appropriate logging: import logging
logger = logging.getLogger(__name__)
# ... (in the paginate method)
logger.debug(f"Initial per_page value: {per_page}")
# ... (before calling paginator.get_result)
logger.debug(f"per_page value before get_result: {per_page}") This approach allows for better control over log levels and output in different environments. Also applies to: 791-791 |
||
# Convert the cursor value to integer and float from string | ||
input_cursor = None | ||
try: | ||
|
@@ -788,6 +788,7 @@ def paginate( | |
paginator = paginator_cls(**paginator_kwargs) | ||
|
||
try: | ||
print(per_page, "per_page 2") | ||
cursor_result = paginator.get_result( | ||
limit=per_page, cursor=input_cursor | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { TIssuePriorities } from "../issues"; | ||
|
||
export type TWorkspaceDraftIssue = { | ||
id: string; | ||
name: string; | ||
sort_order: number; | ||
|
||
state_id: string | undefined; | ||
priority: TIssuePriorities | undefined; | ||
label_ids: string[]; | ||
assignee_ids: string[]; | ||
estimate_point: string | undefined; | ||
|
||
project_id: string | undefined; | ||
parent_id: string | undefined; | ||
cycle_id: string | undefined; | ||
module_ids: string[] | undefined; | ||
|
||
start_date: string | undefined; | ||
target_date: string | undefined; | ||
completed_at: string | undefined; | ||
|
||
created_at: string; | ||
updated_at: string; | ||
created_by: string; | ||
updated_by: string; | ||
|
||
is_draft: boolean; | ||
}; | ||
|
||
export type TWorkspaceDraftPaginationInfo<T> = { | ||
next_cursor: string | undefined; | ||
prev_cursor: string | undefined; | ||
next_page_results: boolean | undefined; | ||
prev_page_results: boolean | undefined; | ||
total_pages: number | undefined; | ||
count: number | undefined; // current paginated results count | ||
total_count: number | undefined; // total available results count | ||
total_results: number | undefined; | ||
results: T[] | undefined; | ||
extra_stats: string | undefined; | ||
grouped_by: string | undefined; | ||
sub_grouped_by: string | undefined; | ||
}; | ||
|
||
export type TWorkspaceDraftQueryParams = { | ||
per_page: number; | ||
cursor: string; | ||
}; | ||
|
||
export type TWorkspaceDraftIssueLoader = | ||
| "init-loader" | ||
| "empty-state" | ||
| "mutation" | ||
| "pagination" | ||
| "loaded" | ||
| "create" | ||
| "update" | ||
| "delete" | ||
| "move" | ||
| undefined; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"use client"; | ||
|
||
import { FC, useState } from "react"; | ||
import { observer } from "mobx-react"; | ||
import { PenSquare } from "lucide-react"; | ||
// ui | ||
import { Breadcrumbs, Button, Header } from "@plane/ui"; | ||
// components | ||
import { BreadcrumbLink } from "@/components/common"; | ||
import { CreateUpdateIssueModal } from "@/components/issues"; | ||
// constants | ||
import { EIssuesStoreType } from "@/constants/issue"; | ||
// hooks | ||
import { useUserPermissions } from "@/hooks/store"; | ||
// plane-web | ||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions"; | ||
|
||
export const WorkspaceDraftHeader: FC = observer(() => { | ||
// state | ||
const [isDraftIssueModalOpen, setIsDraftIssueModalOpen] = useState(false); | ||
// store hooks | ||
const { allowPermissions } = useUserPermissions(); | ||
|
||
// check if user is authorized to create draft issue | ||
const isAuthorizedUser = allowPermissions( | ||
[EUserPermissions.ADMIN, EUserPermissions.MEMBER], | ||
EUserPermissionsLevel.WORKSPACE | ||
); | ||
|
||
return ( | ||
<> | ||
<CreateUpdateIssueModal | ||
isOpen={isDraftIssueModalOpen} | ||
storeType={EIssuesStoreType.WORKSPACE_DRAFT} | ||
onClose={() => setIsDraftIssueModalOpen(false)} | ||
isDraft | ||
/> | ||
<Header> | ||
<Header.LeftItem> | ||
<Breadcrumbs> | ||
<Breadcrumbs.BreadcrumbItem | ||
type="text" | ||
link={<BreadcrumbLink label={`Draft`} icon={<PenSquare className="h-4 w-4 text-custom-text-300" />} />} | ||
/> | ||
</Breadcrumbs> | ||
</Header.LeftItem> | ||
|
||
<Header.RightItem> | ||
<Button | ||
variant="primary" | ||
size="sm" | ||
className="items-center gap-1" | ||
onClick={() => setIsDraftIssueModalOpen(true)} | ||
disabled={!isAuthorizedUser} | ||
> | ||
Draft <span className="hidden sm:inline-block">issue</span> | ||
</Button> | ||
</Header.RightItem> | ||
</Header> | ||
</> | ||
); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use client"; | ||
|
||
import { AppHeader, ContentWrapper } from "@/components/core"; | ||
import { WorkspaceDraftHeader } from "./header"; | ||
|
||
export default function WorkspaceDraftLayout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<> | ||
<AppHeader header={<WorkspaceDraftHeader />} /> | ||
<ContentWrapper>{children}</ContentWrapper> | ||
</> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
created_by
filter increate_draft_to_issue
for security.In the
create_draft_to_issue
method, thedraft_issue
is retrieved without filtering bycreated_by=request.user
. This could allow users to act on draft issues they did not create. To prevent unauthorized access, include thecreated_by
filter.Apply this diff to secure the query:
📝 Committable suggestion