-
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
chore: move constants to packages and refactor empty state #6137
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export enum AI_EDITOR_TASKS { | ||
ASK_ANYTHING = "ASK_ANYTHING", | ||
} | ||
|
||
export const LOADING_TEXTS: { | ||
[key in AI_EDITOR_TASKS]: string; | ||
} = { | ||
[AI_EDITOR_TASKS.ASK_ANYTHING]: "Pi is generating response", | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum EAuthModes { | ||
SIGN_IN = "SIGN_IN", | ||
SIGN_UP = "SIGN_UP", | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { mergeEnums } from "../helper"; | ||
import { | ||
EmptyStateDetails, | ||
ECoreEmptyState, | ||
coreEmptyStateDetails, | ||
} from "../core/empty-state"; | ||
|
||
enum EEmptyState {} | ||
|
||
// Create a combined enum | ||
export const EmptyStateType = mergeEnums(ECoreEmptyState, EEmptyState); | ||
|
||
const emptyStateDetails: Record< | ||
EEmptyState, | ||
EmptyStateDetails<EEmptyState> | ||
> = {} as const; | ||
|
||
export type TEmptyStateType = ECoreEmptyState | EEmptyState; | ||
|
||
export const EMPTY_STATE_DETAILS: Record< | ||
TEmptyStateType, | ||
EmptyStateDetails<TEmptyStateType> | ||
> = { | ||
...coreEmptyStateDetails, | ||
...emptyStateDetails, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// types | ||
import { TEstimateSystems } from "@plane/types"; | ||
|
||
export const MAX_ESTIMATE_POINT_INPUT_LENGTH = 20; | ||
|
||
export enum EEstimateSystem { | ||
POINTS = "points", | ||
CATEGORIES = "categories", | ||
TIME = "time", | ||
} | ||
|
||
export enum EEstimateUpdateStages { | ||
CREATE = "create", | ||
EDIT = "edit", | ||
SWITCH = "switch", | ||
} | ||
|
||
export const estimateCount = { | ||
min: 2, | ||
max: 6, | ||
}; | ||
|
||
export const ESTIMATE_SYSTEMS: TEstimateSystems = { | ||
points: { | ||
name: "Points", | ||
templates: { | ||
fibonacci: { | ||
title: "Fibonacci", | ||
values: [ | ||
{ id: undefined, key: 1, value: "1" }, | ||
{ id: undefined, key: 2, value: "2" }, | ||
{ id: undefined, key: 3, value: "3" }, | ||
{ id: undefined, key: 4, value: "5" }, | ||
{ id: undefined, key: 5, value: "8" }, | ||
{ id: undefined, key: 6, value: "13" }, | ||
], | ||
}, | ||
linear: { | ||
title: "Linear", | ||
values: [ | ||
{ id: undefined, key: 1, value: "1" }, | ||
{ id: undefined, key: 2, value: "2" }, | ||
{ id: undefined, key: 3, value: "3" }, | ||
{ id: undefined, key: 4, value: "4" }, | ||
{ id: undefined, key: 5, value: "5" }, | ||
{ id: undefined, key: 6, value: "6" }, | ||
], | ||
}, | ||
squares: { | ||
title: "Squares", | ||
values: [ | ||
{ id: undefined, key: 1, value: "1" }, | ||
{ id: undefined, key: 2, value: "4" }, | ||
{ id: undefined, key: 3, value: "9" }, | ||
{ id: undefined, key: 4, value: "16" }, | ||
{ id: undefined, key: 5, value: "25" }, | ||
{ id: undefined, key: 6, value: "36" }, | ||
], | ||
}, | ||
custom: { | ||
title: "Custom", | ||
values: [ | ||
{ id: undefined, key: 1, value: "1" }, | ||
{ id: undefined, key: 2, value: "2" }, | ||
], | ||
hide: true, | ||
}, | ||
}, | ||
is_available: true, | ||
is_ee: false, | ||
}, | ||
categories: { | ||
name: "Categories", | ||
templates: { | ||
t_shirt_sizes: { | ||
title: "T-Shirt Sizes", | ||
values: [ | ||
{ id: undefined, key: 1, value: "XS" }, | ||
{ id: undefined, key: 2, value: "S" }, | ||
{ id: undefined, key: 3, value: "M" }, | ||
{ id: undefined, key: 4, value: "L" }, | ||
{ id: undefined, key: 5, value: "XL" }, | ||
{ id: undefined, key: 6, value: "XXL" }, | ||
], | ||
}, | ||
easy_to_hard: { | ||
title: "Easy to hard", | ||
values: [ | ||
{ id: undefined, key: 1, value: "Easy" }, | ||
{ id: undefined, key: 2, value: "Medium" }, | ||
{ id: undefined, key: 3, value: "Hard" }, | ||
{ id: undefined, key: 4, value: "Very Hard" }, | ||
], | ||
}, | ||
custom: { | ||
title: "Custom", | ||
values: [ | ||
{ id: undefined, key: 1, value: "Easy" }, | ||
{ id: undefined, key: 2, value: "Hard" }, | ||
], | ||
hide: true, | ||
}, | ||
}, | ||
is_available: true, | ||
is_ee: false, | ||
}, | ||
time: { | ||
name: "Time", | ||
templates: { | ||
hours: { | ||
title: "Hours", | ||
values: [ | ||
{ id: undefined, key: 1, value: "1" }, | ||
{ id: undefined, key: 2, value: "2" }, | ||
{ id: undefined, key: 3, value: "3" }, | ||
{ id: undefined, key: 4, value: "4" }, | ||
{ id: undefined, key: 5, value: "5" }, | ||
{ id: undefined, key: 6, value: "6" }, | ||
], | ||
}, | ||
}, | ||
is_available: false, | ||
is_ee: true, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from "./ai"; | ||
export * from "./estimates"; | ||
export * from "./empty-state"; | ||
export * from "./issues"; | ||
export * from "./user-permissions"; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||
import { TIssueActivityComment } from "@plane/types"; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export enum EActivityFilterType { | ||||||||||||||||||||||||||||||||
ACTIVITY = "ACTIVITY", | ||||||||||||||||||||||||||||||||
COMMENT = "COMMENT", | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export type TActivityFilters = EActivityFilterType; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const ACTIVITY_FILTER_TYPE_OPTIONS: Record<EActivityFilterType, { label: string }> = { | ||||||||||||||||||||||||||||||||
[EActivityFilterType.ACTIVITY]: { | ||||||||||||||||||||||||||||||||
label: "Updates", | ||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
[EActivityFilterType.COMMENT]: { | ||||||||||||||||||||||||||||||||
label: "Comments", | ||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const defaultActivityFilters: TActivityFilters[] = [EActivityFilterType.ACTIVITY, EActivityFilterType.COMMENT]; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export type TActivityFilterOption = { | ||||||||||||||||||||||||||||||||
key: EActivityFilterType; | ||||||||||||||||||||||||||||||||
label: string; | ||||||||||||||||||||||||||||||||
isSelected: boolean; | ||||||||||||||||||||||||||||||||
onClick: () => void; | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const filterActivityOnSelectedFilters = ( | ||||||||||||||||||||||||||||||||
activity: TIssueActivityComment[], | ||||||||||||||||||||||||||||||||
filter: TActivityFilters[] | ||||||||||||||||||||||||||||||||
): TIssueActivityComment[] => | ||||||||||||||||||||||||||||||||
activity.filter((activity) => filter.includes(activity.activity_type as TActivityFilters)); | ||||||||||||||||||||||||||||||||
Comment on lines
+28
to
+32
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. 🛠️ Refactor suggestion Add input validation and error handling The export const filterActivityOnSelectedFilters = (
activity: TIssueActivityComment[],
filter: TActivityFilters[]
): TIssueActivityComment[] => {
+ if (!Array.isArray(activity) || !Array.isArray(filter)) {
+ throw new TypeError('Both arguments must be arrays');
+ }
+ if (filter.length === 0) return activity;
return activity.filter((activity) => filter.includes(activity.activity_type as TActivityFilters));
+} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const ENABLE_ISSUE_DEPENDENCIES = false; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export enum EUserPermissionsLevel { | ||
WORKSPACE = "WORKSPACE", | ||
PROJECT = "PROJECT", | ||
} | ||
export type TUserPermissionsLevel = EUserPermissionsLevel; | ||
|
||
export enum EUserPermissions { | ||
ADMIN = 20, | ||
MEMBER = 15, | ||
GUEST = 5, | ||
} | ||
export type TUserPermissions = EUserPermissions; | ||
|
||
export type TUserAllowedPermissionsObject = { | ||
create: TUserPermissions[]; | ||
update: TUserPermissions[]; | ||
delete: TUserPermissions[]; | ||
read: TUserPermissions[]; | ||
}; | ||
export type TUserAllowedPermissions = { | ||
workspace: { | ||
[key: string]: Partial<TUserAllowedPermissionsObject>; | ||
}; | ||
project: { | ||
[key: string]: Partial<TUserAllowedPermissionsObject>; | ||
}; | ||
}; | ||
|
||
export const USER_ALLOWED_PERMISSIONS: TUserAllowedPermissions = { | ||
workspace: { | ||
dashboard: { | ||
read: [EUserPermissions.ADMIN, EUserPermissions.MEMBER, EUserPermissions.GUEST], | ||
}, | ||
}, | ||
project: {}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// types | ||
import { TXAxisValues, TYAxisValues } from "@plane/types"; | ||
|
||
export const ANALYTICS_TABS = [ | ||
{ key: "scope_and_demand", title: "Scope and Demand" }, | ||
{ key: "custom", title: "Custom Analytics" }, | ||
]; | ||
|
||
export const ANALYTICS_X_AXIS_VALUES: { value: TXAxisValues; label: string }[] = [ | ||
{ | ||
value: "state_id", | ||
label: "State name", | ||
}, | ||
{ | ||
value: "state__group", | ||
label: "State group", | ||
}, | ||
{ | ||
value: "priority", | ||
label: "Priority", | ||
}, | ||
{ | ||
value: "labels__id", | ||
label: "Label", | ||
}, | ||
{ | ||
value: "assignees__id", | ||
label: "Assignee", | ||
}, | ||
{ | ||
value: "estimate_point__value", | ||
label: "Estimate point", | ||
}, | ||
{ | ||
value: "issue_cycle__cycle_id", | ||
label: "Cycle", | ||
}, | ||
{ | ||
value: "issue_module__module_id", | ||
label: "Module", | ||
}, | ||
{ | ||
value: "completed_at", | ||
label: "Completed date", | ||
}, | ||
{ | ||
value: "target_date", | ||
label: "Due date", | ||
}, | ||
{ | ||
value: "start_date", | ||
label: "Start date", | ||
}, | ||
{ | ||
value: "created_at", | ||
label: "Created date", | ||
}, | ||
]; | ||
|
||
export const ANALYTICS_Y_AXIS_VALUES: { value: TYAxisValues; label: string }[] = [ | ||
{ | ||
value: "issue_count", | ||
label: "Issue Count", | ||
}, | ||
{ | ||
value: "estimate", | ||
label: "Estimate", | ||
}, | ||
]; | ||
|
||
export const DATE_KEYS = ["completed_at", "target_date", "start_date", "created_at"]; |
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.
🛠️ Refactor suggestion
Improve type safety of emptyStateDetails constant.
The current implementation uses type assertion (
as const
). Consider using a proper type guard or initialization with an empty object that matches the type.