Skip to content
Merged
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
useGetProjectGitConfigurationQuery,
} from '@/ee/shared/mutations/automation/projectGit.queries';
import {useToast} from '@/hooks/use-toast';
import {useProject} from '@/pages/automation/project/hooks/useProject';
import {Project, Workflow} from '@/shared/middleware/automation/configuration';
import {useDeleteProjectMutation, useDuplicateProjectMutation} from '@/shared/mutations/automation/projects.mutations';
import {
Expand All @@ -26,7 +25,7 @@ import {useNavigate, useSearchParams} from 'react-router-dom';
export const useSettingsMenu = ({project, workflow}: {project: Project; workflow: Workflow}) => {
const {data: projectGitConfiguration} = useGetProjectGitConfigurationQuery(project.id!);

const {projectId} = useProject();
const projectId = project.id;

const navigate = useNavigate();
const [searchParams] = useSearchParams();
Expand Down Expand Up @@ -103,7 +102,7 @@ export const useSettingsMenu = ({project, workflow}: {project: Project; workflow
(projectWorkflowId) => projectWorkflowId !== deletedWorkflowId
);

if (!projectId || !firstRemainingWorkflowId || !deletedWorkflowId) {
if (!projectId || !deletedWorkflowId) {
return;
}

Expand All @@ -117,7 +116,17 @@ export const useSettingsMenu = ({project, workflow}: {project: Project; workflow
queryKey: ProjectWorkflowKeys.projectWorkflows(projectId),
});

navigate(`/automation/projects/${projectId}/project-workflows/${firstRemainingWorkflowId}?${searchParams}`);
// exact here prevents double fetchs of project
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

queryClient.invalidateQueries({
exact: true,
queryKey: ProjectKeys.project(projectId),
});

const baseUrl = '/automation/projects';
const firstRemainingWorkflowUrlSuffix = firstRemainingWorkflowId
? `/${projectId}/project-workflows/${firstRemainingWorkflowId}?${searchParams}`
: '';
navigate(baseUrl + firstRemainingWorkflowUrlSuffix);
Comment on lines 124 to 131
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want an empty line between variable declaration and its usage.

i would also like it if you rewrote the firstRemainingWorkflowUrlSuffix so that it's an empty string by default, and if firstRemainingWorkflowId exists, change its value to the complicated string...

the pattern is something like this:

let firstRemainingWorkflowUrlSuffix = '';

if (foo) {
  firstRemainingWorkflowUrlSuffix = ...
}

otherwise, great job!

},
});

Expand Down
Loading