Skip to content

Commit ac662f8

Browse files
committed
refactor: Update navigation flow after deploy
After a user deploys a release, automatically redirect them to the deployment details page Signed-off-by: Jasmina <jasmina.piric@secomind.com>
1 parent f4e8fde commit ac662f8

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

frontend/src/components/AddAvailableApplications.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Select, { SingleValue } from "react-select";
2626

2727
import type { AddAvailableApplications_GetApplicationsWithReleases_Query } from "@/api/__generated__/AddAvailableApplications_GetApplicationsWithReleases_Query.graphql";
2828
import type { AddAvailableApplications_DeployRelease_Mutation } from "@/api/__generated__/AddAvailableApplications_DeployRelease_Mutation.graphql";
29+
import { useNavigate, Route } from "@/Navigation";
2930

3031
const GET_APPLICATIONS_WITH_RELEASES_QUERY = graphql`
3132
query AddAvailableApplications_GetApplicationsWithReleases_Query(
@@ -91,6 +92,7 @@ const AddAvailableApplications = ({
9192
onDeployComplete,
9293
}: AddAvailableApplicationsProps) => {
9394
const intl = useIntl();
95+
const navigate = useNavigate();
9496

9597
const [selectedApp, setSelectedApp] = useState<string | null>(null);
9698
const [selectedRelease, setSelectedRelease] = useState<string | null>(null);
@@ -204,7 +206,7 @@ const AddAvailableApplications = ({
204206
releaseId: selectedRelease,
205207
},
206208
},
207-
onCompleted: (_data, errors) => {
209+
onCompleted: (data, errors) => {
208210
if (errors) {
209211
const errorFeedback = errors
210212
.map(({ fields, message }) =>
@@ -217,6 +219,15 @@ const AddAvailableApplications = ({
217219
setSelectedApp(null); // Reset selected app
218220
setSelectedRelease(null); // Reset selected release
219221
setErrorFeedback(null);
222+
223+
const deploymentId = data?.deployRelease?.result?.id;
224+
225+
if (deploymentId) {
226+
return navigate({
227+
route: Route.deploymentEdit,
228+
params: { deviceId, deploymentId },
229+
});
230+
}
220231
},
221232
onError: () => {
222233
setErrorFeedback(
@@ -234,6 +245,7 @@ const AddAvailableApplications = ({
234245
deployRelease,
235246
setErrorFeedback,
236247
onDeployComplete,
248+
navigate,
237249
]);
238250

239251
return (

0 commit comments

Comments
 (0)