Skip to content
Closed
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
1 change: 1 addition & 0 deletions packages/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * from "./event-tracker";
export * from "./spreadsheet";
export * from "./dashboard";
export * from "./page";
export * from "./swr-keys";
7 changes: 7 additions & 0 deletions packages/constants/src/swr-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum SWR_KEYS_CORE {}

export const SWR_KEYS = {
...SWR_KEYS_CORE,
} as const;

export type TSWRKey = SWR_KEYS_CORE;
15 changes: 14 additions & 1 deletion packages/utils/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";

import { TSWRKey } from "@plane/constants";
// Support email can be configured by the application
export const getSupportEmail = (defaultEmail: string = ""): string => defaultEmail;

Expand Down Expand Up @@ -39,3 +39,16 @@ export const partitionValidIds = (ids: string[], validIds: string[]): { valid: s

return { valid, invalid };
};

/**
* Generates a unique key for SWR cache
* @param workspaceSlug - The slug of the workspace
* @param label - The label for the cache key
* @param params - The parameters for the cache key
* @returns The unique key in array format
*/
export const getSwrKey = (workspaceSlug: string, label: TSWRKey, params: string[] = []) => [
label,
workspaceSlug,
...params,
];
Comment on lines +42 to +54
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

Well-documented utility function for consistent SWR key generation

The getSwrKey function is well-designed with comprehensive JSDoc comments that clearly explain its purpose and parameters. The function provides a structured approach to generating SWR cache keys, which will help maintain consistency throughout the application.

However, the function depends on the TSWRKey type which is currently based on an empty SWR_KEYS_CORE enum (as seen in the second file). This significantly limits the function's utility in its current state.

While the structure is good, you should populate the SWR_KEYS_CORE enum with actual values to make this function immediately useful. This would also prevent developers from using inconsistent string literals for cache keys.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FC } from "react";

export type TWorkItemAdditionalWidgets = {
workspaceSlug: string;
projectId: string;
workItemId: string;
disabled: boolean;
};

export const WorkItemAdditionalWidgets: FC<TWorkItemAdditionalWidgets> = (props) => <></>;
1 change: 1 addition & 0 deletions web/ce/components/issues/issue-detail-widgets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./additional-widgets";
4 changes: 4 additions & 0 deletions web/ce/store/issue/helpers/base-issue-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TIssue } from "@plane/types";
import { getIssueIds } from "@/store/issue/helpers/base-issues-utils";

export const workItemSortWithOrderByExtended = (array: TIssue[], key?: string) => getIssueIds(array);
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
// hooks
import { useIssueDetail } from "@/hooks/store";
// Plane-web
import { WorkItemAdditionalWidgets } from "@/plane-web/components/issues/issue-detail-widgets";
import { useTimeLineRelationOptions } from "@/plane-web/components/relations";

type Props = {
Expand Down Expand Up @@ -68,6 +69,13 @@ export const IssueDetailWidgetCollapsibles: FC<Props> = observer((props) => {
disabled={disabled}
/>
)}

<WorkItemAdditionalWidgets
workspaceSlug={workspaceSlug}
projectId={projectId}
workItemId={issueId}
disabled={disabled}
/>
</div>
);
});
1 change: 0 additions & 1 deletion web/core/components/issues/issue-detail/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ export const IssueDetailsSidebar: React.FC<Props> = observer((props) => {
projectId={projectId}
workspaceSlug={workspaceSlug}
isEditable={isEditable}
isPeekView
/>
</div>
</div>
Expand Down