Skip to content

Commit 53aae45

Browse files
committed
fix: potential error points
1 parent c01b706 commit 53aae45

10 files changed

Lines changed: 57 additions & 27 deletions

File tree

apps/web/ce/components/command-palette/modals/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/web/ce/components/command-palette/modals/issue-level.tsx renamed to apps/web/ce/components/command-palette/modals/work-item-level.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import { useUser } from "@/hooks/store/user";
1515
import { useAppRouter } from "@/hooks/use-app-router";
1616
import { useIssuesActions } from "@/hooks/use-issues-actions";
1717

18-
export type TIssueLevelModalsProps = {
18+
export type TWorkItemLevelModalsProps = {
1919
workItemIdentifier: string | undefined;
2020
};
2121

22-
export const IssueLevelModals: FC<TIssueLevelModalsProps> = observer((props) => {
22+
export const WorkItemLevelModals: FC<TWorkItemLevelModalsProps> = observer((props) => {
2323
const { workItemIdentifier } = props;
2424
// router
2525
const { workspaceSlug, cycleId, moduleId } = useParams();

apps/web/core/components/power-k/config/help-commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const usePowerKHelpCommands = (): TPowerKCommandConfig[] => {
3535
i18n_title: "power_k.help_actions.open_plane_documentation",
3636
icon: FileText,
3737
action: () => {
38-
window.open("https://docs.plane.so/", "_blank");
38+
window.open("https://docs.plane.so/", "_blank", "noopener,noreferrer");
3939
},
4040
isEnabled: () => true,
4141
isVisible: () => true,
@@ -48,7 +48,7 @@ export const usePowerKHelpCommands = (): TPowerKCommandConfig[] => {
4848
i18n_title: "power_k.help_actions.join_discord",
4949
icon: DiscordIcon,
5050
action: () => {
51-
window.open("https://discord.com/invite/A92xrEGCge", "_blank");
51+
window.open("https://discord.com/invite/A92xrEGCge", "_blank", "noopener,noreferrer");
5252
},
5353
isEnabled: () => true,
5454
isVisible: () => true,
@@ -61,7 +61,7 @@ export const usePowerKHelpCommands = (): TPowerKCommandConfig[] => {
6161
i18n_title: "power_k.help_actions.report_bug",
6262
icon: GithubIcon,
6363
action: () => {
64-
window.open("https://github.com/makeplane/plane/issues/new/choose", "_blank");
64+
window.open("https://github.com/makeplane/plane/issues/new/choose", "_blank", "noopener,noreferrer");
6565
},
6666
isEnabled: () => true,
6767
isVisible: () => true,

apps/web/core/components/power-k/config/preferences-commands.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useCallback } from "react";
22
import { useTheme } from "next-themes";
33
import { Calendar, Earth, Languages, Palette } from "lucide-react";
44
// plane imports
5+
import { useTranslation } from "@plane/i18n";
56
import { setToast, TOAST_TYPE } from "@plane/propel/toast";
67
import type { EStartOfTheWeek, TUserProfile } from "@plane/types";
78
// components
@@ -17,17 +18,29 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
1718
const { setTheme } = useTheme();
1819
const { updateCurrentUser } = useUser();
1920
const { updateUserProfile, updateUserTheme } = useUserProfile();
21+
// translation
22+
const { t } = useTranslation();
2023

2124
const handleUpdateTheme = useCallback(
2225
async (newTheme: string) => {
2326
setTheme(newTheme);
24-
return updateUserTheme({ theme: newTheme }).catch(() => {
25-
setToast({
26-
type: TOAST_TYPE.ERROR,
27-
title: "Failed to save user theme settings!",
27+
return updateUserTheme({ theme: newTheme })
28+
.then(() => {
29+
setToast({
30+
type: TOAST_TYPE.SUCCESS,
31+
title: t("toast.success"),
32+
message: t("power_k.preferences_actions.toast.theme.success"),
33+
});
34+
})
35+
.catch(() => {
36+
setToast({
37+
type: TOAST_TYPE.ERROR,
38+
title: t("toast.error"),
39+
message: t("power_k.preferences_actions.toast.theme.error"),
40+
});
2841
});
29-
});
3042
},
43+
// eslint-disable-next-line react-hooks/exhaustive-deps
3144
[setTheme, updateUserTheme]
3245
);
3346

@@ -36,19 +49,20 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
3649
updateCurrentUser({ user_timezone: value })
3750
.then(() => {
3851
setToast({
39-
title: "Success!",
40-
message: "Timezone updated successfully",
4152
type: TOAST_TYPE.SUCCESS,
53+
title: t("toast.success"),
54+
message: t("power_k.preferences_actions.toast.timezone.success"),
4255
});
4356
})
4457
.catch(() => {
4558
setToast({
46-
title: "Error!",
47-
message: "Failed to update timezone",
4859
type: TOAST_TYPE.ERROR,
60+
title: t("toast.error"),
61+
message: t("power_k.preferences_actions.toast.timezone.error"),
4962
});
5063
});
5164
},
65+
// eslint-disable-next-line react-hooks/exhaustive-deps
5266
[updateCurrentUser]
5367
);
5468

@@ -57,19 +71,20 @@ export const usePowerKPreferencesCommands = (): TPowerKCommandConfig[] => {
5771
updateUserProfile(payload)
5872
.then(() => {
5973
setToast({
60-
title: "Success!",
61-
message: "Language updated successfully",
6274
type: TOAST_TYPE.SUCCESS,
75+
title: t("toast.success"),
76+
message: t("power_k.preferences_actions.toast.generic.success"),
6377
});
6478
})
6579
.catch(() => {
6680
setToast({
67-
title: "Error!",
68-
message: "Failed to update language",
6981
type: TOAST_TYPE.ERROR,
82+
title: t("toast.error"),
83+
message: t("power_k.preferences_actions.toast.generic.error"),
7084
});
7185
});
7286
},
87+
// eslint-disable-next-line react-hooks/exhaustive-deps
7388
[updateUserProfile]
7489
);
7590

apps/web/core/components/power-k/projects-app-provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { usePowerK } from "@/hooks/store/use-power-k";
99
import { useUser } from "@/hooks/store/user";
1010
import { useAppRouter } from "@/hooks/use-app-router";
1111
// plane web imports
12-
import { IssueLevelModals } from "@/plane-web/components/command-palette/modals/issue-level";
1312
import { ProjectLevelModals } from "@/plane-web/components/command-palette/modals/project-level";
13+
import { WorkItemLevelModals } from "@/plane-web/components/command-palette/modals/work-item-level";
1414
import { WorkspaceLevelModals } from "@/plane-web/components/command-palette/modals/workspace-level";
1515
// local imports
1616
import { useProjectsAppPowerKCommands } from "./config/commands";
@@ -79,7 +79,7 @@ export const ProjectsAppPowerKProvider = observer(() => {
7979
{workspaceSlug && projectId && (
8080
<ProjectLevelModals workspaceSlug={workspaceSlug.toString()} projectId={projectId.toString()} />
8181
)}
82-
<IssueLevelModals workItemIdentifier={workItemIdentifier?.toString()} />
82+
<WorkItemLevelModals workItemIdentifier={workItemIdentifier?.toString()} />
8383
<ProjectsAppPowerKModalWrapper
8484
commandsListComponent={ProjectsAppPowerKCommandsList}
8585
context={context}

apps/web/core/components/power-k/ui/modal/search-menu.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export const PowerKModalSearchMenu: React.FC<Props> = (props) => {
5757
);
5858
setResultsCount(count);
5959
})
60+
.catch(() => {
61+
setResults(WORKSPACE_DEFAULT_SEARCH_RESULT);
62+
setResultsCount(0);
63+
})
6064
.finally(() => setIsSearching(false));
6165
} else {
6266
setResults(WORKSPACE_DEFAULT_SEARCH_RESULT);

apps/web/core/components/power-k/ui/modal/wrapper.tsx.tsx renamed to apps/web/core/components/power-k/ui/modal/wrapper.tsx

File renamed without changes.

apps/web/core/components/power-k/ui/pages/context-based/work-item/commands.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const usePowerKWorkItemContextBasedCommands = (): TPowerKCommandConfig[]
6161
const entityDetails = entityId ? getIssueById(entityId) : null;
6262
const isEpic = !!entityDetails?.is_epic;
6363
const projectDetails = entityDetails?.project_id ? getProjectById(entityDetails?.project_id) : undefined;
64-
const isCurrentUserAssigned = entityDetails?.assignee_ids.includes(currentUser?.id ?? "");
64+
const isCurrentUserAssigned = !!entityDetails?.assignee_ids?.includes(currentUser?.id ?? "");
6565
const isEstimateEnabled = entityDetails?.project_id
6666
? areEstimateEnabledByProjectId(entityDetails?.project_id)
6767
: false;
@@ -99,7 +99,7 @@ export const usePowerKWorkItemContextBasedCommands = (): TPowerKCommandConfig[]
9999
(assigneeId: string) => {
100100
if (!entityDetails) return;
101101

102-
const updatedAssignees = entityDetails.assignee_ids ?? [];
102+
const updatedAssignees = [...(entityDetails.assignee_ids ?? [])];
103103
if (updatedAssignees.includes(assigneeId)) updatedAssignees.splice(updatedAssignees.indexOf(assigneeId), 1);
104104
else updatedAssignees.push(assigneeId);
105105

@@ -370,7 +370,7 @@ export const usePowerKWorkItemContextBasedCommands = (): TPowerKCommandConfig[]
370370
onSelect: (data) => {
371371
const labelId = (data as IIssueLabel)?.id;
372372
if (!workspaceSlug || !entityDetails || !entityDetails.project_id) return;
373-
const updatedLabels = entityDetails.label_ids ?? [];
373+
const updatedLabels = [...(entityDetails.label_ids ?? [])];
374374
if (updatedLabels.includes(labelId)) updatedLabels.splice(updatedLabels.indexOf(labelId), 1);
375375
else updatedLabels.push(labelId);
376376
handleUpdateEntity({

apps/web/core/components/power-k/ui/pages/issue-selection-page.tsx renamed to apps/web/core/components/power-k/ui/pages/work-item-selection-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Props = {
2929
isWorkspaceLevel?: boolean;
3030
};
3131

32-
export const IssueSelectionPage: React.FC<Props> = (props) => {
32+
export const WorkItemSelectionPage: React.FC<Props> = (props) => {
3333
const {
3434
workspaceSlug,
3535
projectId,

packages/i18n/src/locales/en/translations.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,20 @@ export default {
25912591
update_timezone: "Change timezone",
25922592
update_start_of_week: "Change first day of week",
25932593
update_language: "Change interface language",
2594+
toast: {
2595+
theme: {
2596+
success: "Theme updated successfully.",
2597+
error: "Failed to update theme. Please try again.",
2598+
},
2599+
timezone: {
2600+
success: "Timezone updated successfully.",
2601+
error: "Failed to update timezone. Please try again.",
2602+
},
2603+
generic: {
2604+
success: "Preferences updated successfully.",
2605+
error: "Failed to update preferences. Please try again.",
2606+
},
2607+
},
25942608
},
25952609
help_actions: {
25962610
open_keyboard_shortcuts: "Open keyboard shortcuts",

0 commit comments

Comments
 (0)