Skip to content

Commit bac57f8

Browse files
authored
fix: open session from deployments page on manual run (#1399)
## Description When executing a manual run from the deployments page, the "Show More" button in the success toast was attempting to navigate to a session URL that included a deployment ID, but this navigation was failing when the session wasn't associated with a specific deployment. ## What type of PR is this? (check all applicable) - [ ] 💡 (feat) - A new feature (non-breaking change which adds functionality) - [ ] 🔄 (refactor) - Code Refactoring - A code change that neither fixes a bug nor adds a feature - [x] 🐞 (fix) - Bug Fix (non-breaking change which fixes an issue) - [ ] 🏎 (perf) - Optimization - [ ] 📄 (docs) - Documentation - Documentation only changes - [ ] 📄 (test) - Tests - Adding missing tests or correcting existing tests - [ ] ⚙️ (ci) - Continuous Integrations - Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) - [ ] ☑️ (chore) - Chores - Other changes that don't modify src or test files - [ ] ↩️ (revert) - Reverts - Reverts a previous commit(s). <!-- For a timely review/response, please avoid force-pushing additional commits if your PR already received reviews or comments. Before submitting a Pull Request, please ensure you've done the following: - 👷‍♀️ Create small PRs. In most cases this will be possible. - ✅ Provide tests for your changes. - 📝 Use descriptive commit messages (as described below). - 📗 Update any related documentation and include any relevant screenshots. Commit Message Structure (all lower-case): <type>(optional ticket number): <description> [optional body] -->
1 parent 5622489 commit bac57f8

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

src/components/organisms/topbar/project/manualRun/manualRunButtons.tsx

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { GearIcon, RunIcon } from "@assets/image/icons";
1818

1919
export const ManualRunButtons = () => {
2020
const { t } = useTranslation("deployments", { keyPrefix: "history" });
21+
const { t: tGenericError } = useTranslation("global");
2122
const { projectId } = useParams();
2223
const addToast = useToastStore((state) => state.addToast);
2324
const { openDrawer } = useDrawerStore();
@@ -27,13 +28,13 @@ export const ManualRunButtons = () => {
2728
activeDeploymentStore,
2829
entrypointFunction,
2930
isManualRunEnabled,
30-
saveProjectManualRun,
31+
saveAndExecuteManualRun,
3132
fetchManualRunConfiguration,
3233
} = useManualRunStore((state) => ({
3334
activeDeploymentStore: state.projectManualRun[projectId!]?.activeDeployment,
3435
entrypointFunction: state.projectManualRun[projectId!]?.entrypointFunction,
3536
isManualRunEnabled: state.projectManualRun[projectId!]?.isManualRunEnabled,
36-
saveProjectManualRun: state.saveAndExecuteManualRun,
37+
saveAndExecuteManualRun: state.saveAndExecuteManualRun,
3738
fetchManualRunConfiguration: state.fetchManualRunConfiguration,
3839
}));
3940

@@ -52,7 +53,7 @@ export const ManualRunButtons = () => {
5253
if (!projectId) return;
5354
try {
5455
setActionInProcess(ProjectActions.manualRun, true);
55-
const { data: sessionId, error } = await saveProjectManualRun(projectId);
56+
const { data: sessionId, error } = await saveAndExecuteManualRun(projectId);
5657
if (error) {
5758
addToast({
5859
message: t("manualRun.executionFailed"),
@@ -65,6 +66,27 @@ export const ManualRunButtons = () => {
6566

6667
return;
6768
}
69+
70+
if (sessionId) {
71+
UserTrackingUtils.trackEvent("manual_run_executed", {
72+
sessionId,
73+
projectId,
74+
deploymentId: activeDeploymentStore?.deploymentId,
75+
entrypoint: entrypointFunction?.value,
76+
});
77+
} else {
78+
addToast({
79+
message: t("manualRun.executionFailed"),
80+
type: "error",
81+
});
82+
LoggerService.error(
83+
namespaces.ui.manualRun,
84+
t("manualRun.executionFailedExtended", { projectId, error: tGenericError("genericError") })
85+
);
86+
87+
return;
88+
}
89+
6890
addToast({
6991
message: (
7092
<ManualRunSuccessToastMessage
@@ -76,15 +98,6 @@ export const ManualRunButtons = () => {
7698
type: "success",
7799
});
78100

79-
if (sessionId) {
80-
UserTrackingUtils.trackEvent("manual_run_executed", {
81-
sessionId,
82-
projectId,
83-
deploymentId: activeDeploymentStore?.deploymentId,
84-
entrypoint: entrypointFunction?.value,
85-
});
86-
}
87-
88101
setTimeout(() => {
89102
fetchDeployments(projectId, true);
90103
}, 100);

src/components/organisms/topbar/project/manualRun/manualRunSettingsDrawer.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { namespaces } from "@src/constants";
99
import { DrawerName } from "@src/enums/components";
1010
import { SelectOption } from "@src/interfaces/components";
1111
import { useCacheStore, useDrawerStore, useManualRunStore, useToastStore } from "@src/store";
12+
import { UserTrackingUtils } from "@src/utilities";
1213
import { validateManualRun } from "@validations";
1314

1415
import { Button, IconSvg, Spinner, Typography } from "@components/atoms";
@@ -29,6 +30,7 @@ export const ManualRunSettingsDrawer = () => {
2930
const { projectId } = useParams();
3031
const [sendingManualRun, setSendingManualRun] = useState(false);
3132
const [isValid, setIsValid] = useState(false);
33+
const { t: tGenericError } = useTranslation("global");
3234

3335
const { projectManualRun, saveAndExecuteManualRun, updateManualRunConfiguration } = useManualRunStore((state) => ({
3436
projectManualRun: state.projectManualRun[projectId!],
@@ -71,6 +73,26 @@ export const ManualRunSettingsDrawer = () => {
7173
return;
7274
}
7375

76+
if (sessionId) {
77+
UserTrackingUtils.trackEvent("manual_run_executed", {
78+
sessionId,
79+
projectId,
80+
deploymentId: activeDeployment?.deploymentId,
81+
entrypoint: entrypointFunction?.value,
82+
});
83+
} else {
84+
addToast({
85+
message: t("executionFailed"),
86+
type: "error",
87+
});
88+
LoggerService.error(
89+
namespaces.ui.manualRun,
90+
t("executionFailedExtended", { projectId, error: tGenericError("genericError") })
91+
);
92+
93+
return;
94+
}
95+
7496
addToast({
7597
message: (
7698
<ManualRunSuccessToastMessage

src/components/organisms/topbar/project/manualRun/manualRunSuccessToastMessage.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ export const ManualRunSuccessToastMessage = ({
1616
projectId?: string;
1717
sessionId?: string;
1818
}) => {
19-
const { t } = useTranslation("deployments", { keyPrefix: "history.manualRun" });
19+
const { t } = useTranslation("deployments", {
20+
keyPrefix: "history.manualRun",
21+
});
2022
const navigate = useNavigate();
23+
const goToSession = () =>
24+
deploymentId
25+
? navigate(`/projects/${projectId}/deployments/${deploymentId}/sessions/${sessionId}`)
26+
: navigate(`/projects/${projectId}/sessions/${sessionId}`);
2127

2228
return (
2329
<>
2430
{t("executionSucceed")}
25-
<Button
26-
className="flex cursor-pointer items-center gap-1 p-0 text-green-800"
27-
onClick={() => navigate(`/projects/${projectId}/deployments/${deploymentId}/sessions/${sessionId}`)}
28-
>
31+
<Button className="flex cursor-pointer items-center gap-1 p-0 text-green-800" onClick={goToSession}>
2932
{t("showMore")}
3033
<ExternalLinkIcon className="size-3.5 fill-green-800 duration-200" />
3134
</Button>

src/locales/en/global/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"copyFailure": "Could not copy",
44
"copySuccess": "Copied to clipboard successfully",
55
"copy": "Copy",
6+
"genericError": "Something went wrong, please try again later",
67
"pageTitles": {
78
"base": "AutoKitteh",
89
"template": "AutoKitteh - {{page}}",

0 commit comments

Comments
 (0)