Skip to content

Commit

Permalink
fix edit and create project (#2723)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbeno authored Nov 21, 2024
1 parent 200154c commit 5b9a469
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 199 deletions.
29 changes: 13 additions & 16 deletions app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NextUIProvider } from "@nextui-org/react";
import { ClientBootstrapProvider } from "core/bootstrap/client-bootstrap-context";
import { InitBootstrapAuth } from "core/bootstrap/init-bootstrap-auth";
import { InitBootstrapImpersonation } from "core/bootstrap/init-bootstrap-impersonation";
import { NavigationStateProvider } from "providers/navigation-state/navigation-state";
import { PropsWithChildren } from "react";
import { useMediaQuery } from "usehooks-ts";

Expand Down Expand Up @@ -37,21 +36,19 @@ export default function Providers({ children }: PropsWithChildren) {
<QueryProvider>
<NextUIProvider>
<OnboardingProvider>
<NavigationStateProvider>
<StackProvider>
<SidePanelStackProvider>
<ToasterProvider>
<ToasterAtom />
<InitBootstrapImpersonation />
<InitBootstrapAuth />
<Stacks />
<Toaster />
{/* Hide tooltips on mobile */ isSm && <Tooltip />}
{children}
</ToasterProvider>
</SidePanelStackProvider>
</StackProvider>
</NavigationStateProvider>
<StackProvider>
<SidePanelStackProvider>
<ToasterProvider>
<ToasterAtom />
<InitBootstrapImpersonation />
<InitBootstrapAuth />
<Stacks />
<Toaster />
{/* Hide tooltips on mobile */ isSm && <Tooltip />}
{children}
</ToasterProvider>
</SidePanelStackProvider>
</StackProvider>
</OnboardingProvider>
</NextUIProvider>
</QueryProvider>
Expand Down
9 changes: 0 additions & 9 deletions components/layout/base-link/base-link.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import NextLink from "next/link";
import { useNavigationState } from "providers/navigation-state/navigation-state";
import { MouseEvent } from "react";

import { cn } from "src/utils/cn";
Expand All @@ -20,9 +19,6 @@ export function BaseLink({
onClick,
...props
}: TBaseLink.Props) {
const { block } = useNavigationState();
const [shouldBlock] = block.state;
const [, setConfirmation] = block.confirmation;
const isExternal = href?.toString()?.startsWith("http") ?? false;
const isActive = useMatchPath(String(matchPathOptions?.pattern || href), matchPathOptions);

Expand All @@ -33,11 +29,6 @@ export function BaseLink({
const relProps = rel || relExternal;

function handleClick(event: MouseEvent<HTMLAnchorElement>) {
if (shouldBlock) {
event.preventDefault();
setConfirmation(true, event.currentTarget.pathname);
return;
}
onClick?.(event);
}

Expand Down
23 changes: 0 additions & 23 deletions providers/navigation-state/hooks/useNatifBlock.ts

This file was deleted.

11 changes: 0 additions & 11 deletions providers/navigation-state/navigation-state.context.ts

This file was deleted.

66 changes: 0 additions & 66 deletions providers/navigation-state/navigation-state.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions providers/navigation-state/navigation-state.type.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/_pages/ProjectCreation/ProjectCreation.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type CreateProject = {
installedRepos: number[];
organizations: UseGithubOrganizationsResponse[];
organizationsLoading: boolean;
isSubmitting: boolean;
PoolingFeedback: React.ReactElement;
ecosystems: TSelectAutocomplete.Item[];
projectCategories: TSelectAutocomplete.Item[];
Expand All @@ -76,6 +77,7 @@ export const CreateProjectContext = createContext<CreateProject>({
projectCategories: [],
organizations: [],
organizationsLoading: false,
isSubmitting: false,
PoolingFeedback: <></>,
helpers: {
saveInSession: () => null,
Expand Down Expand Up @@ -334,6 +336,7 @@ export function CreateProjectProvider({
organizationsLoading: isLoading && !organizationsData?.length,
organizations: (organizationsData || []).sort((a, b) => a.login.localeCompare(b.login)),
PoolingFeedback,
isSubmitting: restCreateProjectMutation.isPending || form.formState.isSubmitting,
helpers: {
saveInSession: onSaveInSession,
goTo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FieldInput } from "src/components/New/Field/Input";
import { FieldSwitch } from "src/components/New/Field/Switch";
import { FieldTextarea } from "src/components/New/Field/Textarea";
import { Flex } from "src/components/New/Layout/Flex";
import { Spinner } from "src/components/Spinner/Spinner";
import CheckLine from "src/icons/CheckLine";
import InformationLine from "src/icons/InformationLine";

Expand All @@ -28,6 +29,7 @@ export const ProjectInformationsPage = () => {
form,
ecosystems,
projectCategories,
isSubmitting,
helpers: { prev },
} = useContext(CreateProjectContext);
const suggested = form?.watch("categorySuggestions") || [];
Expand All @@ -52,10 +54,11 @@ export const ProjectInformationsPage = () => {
<Button
htmlType="submit"
onBackground={ButtonOnBackground.Blue}
disabled={!form.formState?.isValid || form.formState.isSubmitting}
disabled={!form.formState?.isValid || isSubmitting}
className="w-full md:w-auto"
>
<CheckLine className="-ml-1 text-2xl" /> {T("common.publish")}
{isSubmitting ? <Spinner /> : <CheckLine className="-ml-1 text-2xl" />}
{T("common.publish")}
</Button>
}
prev={prev}
Expand Down
11 changes: 6 additions & 5 deletions src/_pages/ProjectDetails/ProjectEdition/EditContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { NEXT_ROUTER } from "constants/router";
import { useIntl } from "hooks/translate/use-translate";

import { useProjectDetailsLastAddedRepoStorage } from "../hooks/useProjectDetailsStorage";
import { ConfirmationModal } from "./components/ConfirmationModal/ConfirmationModal";
import { EditPanelProvider } from "./components/Panel/context";
import { useEditValidationSchema } from "./hooks/useValidationSchema";

Expand Down Expand Up @@ -303,14 +302,17 @@ export function EditProvider({ children, project }: EditContextProps) {
// Replace the current path on the history stack if different

if (data.projectSlug !== project.slug) {
const newPathname = NEXT_ROUTER.projects.details.edit(data.projectSlug);
const newPathname = NEXT_ROUTER.projects.details.root(data.projectSlug);

// Navigate before invalidating queries so the new data can use the updated params
router.replace(newPathname, { scroll: false });
router.push(newPathname);

queryClient.invalidateQueries({ queryKey: MeApi.tags.all });
queryClient.invalidateQueries({ queryKey: ProjectApi.tags.detail_by_slug(data.projectSlug) });
} else {
queryClient.invalidateQueries({ queryKey: ProjectApi.tags.detail_by_slug(data.projectSlug) });
router.push(NEXT_ROUTER.projects.details.root(project.slug));
}
queryClient.invalidateQueries({ queryKey: ProjectApi.tags.detail_by_slug(data.projectSlug) });
},
},
});
Expand Down Expand Up @@ -378,7 +380,6 @@ export function EditProvider({ children, project }: EditContextProps) {
<form onSubmit={form.handleSubmit(onSubmit)} className="h-full overflow-hidden">
{children}
</form>
<ConfirmationModal />
</EditPanelProvider>
</EditContext.Provider>
);
Expand Down

This file was deleted.

0 comments on commit 5b9a469

Please sign in to comment.