feat(pull_request): continue work on the pr flow@@ -1,5 +1,5 @@
{
- "_generatedAtUnix": 1665171143196,
+ "_generatedAtUnix": 1665173644819,
"_hashAlgorithm": "sha1",
"_version": 2,
"islands": {
@@ -58,7 +58,7 @@
"pathSourceMap": "./public/.islands/RepositoryInitialSetup.bundle.js.map"
},
"RepositoryPullRequestCreateForm": {
- "hash": "4afb6f0d440189a20c78373cab3ecf5ef89a1276",
+ "hash": "a0a6064032fc7cc6034090bb18cdf52b6de02d16",
"pathSource": "./app/islands/RepositoryPullRequestCreateForm.tsx",
"pathBundle": "./public/.islands/RepositoryPullRequestCreateForm.bundle.js",
"pathSourceMap": "./public/.islands/RepositoryPullRequestCreateForm.bundle.js.map"
@@ -120,7 +120,7 @@
"pathSource": "./app/views/repository/RepositoryForkView.tsx"
},
"RepositoryPullRequestCreateView": {
- "hash": "558b11388971dfa905738fac13c30076576f48c2",
+ "hash": "84f98ab3cd89b3a3842a5e0118a08ae141179a73",
"pathSource": "./app/views/repository/RepositoryPullRequestCreateView.tsx"
},
"RepositoryPullRequestsView": {
@@ -21,8 +21,16 @@ const postRepositoryPullRequestCreateAction: ReqHandler = async (
) => {
const { orgSlug, repoSlug } =
request.params as AppRoutesParams[AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]["params"];
- const { state_from: fromState, state_dest: desiredState } =
- request.body as AppRoutesParams[AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]["body"];
+ const {
+ state_from: fromState,
+ state_dest: desiredState,
+ source_parent_org_slug: sourceParentOrgSlug,
+ source_repository_from_branch: sourceRepoFromBranch,
+ source_repository_slug: sourceRepoSlug,
+ target_parent_org_slug: targetParentOrgSlug,
+ target_repository_dest_branch: targetRepoDestBranch,
+ target_repository_slug: targetRepoSlug,
+ } = request.body as AppRoutesParams[AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]["body"];
const orgService = makeOrganizationService({ request });
const repoService = makeRepositoryService({ request });
@@ -50,18 +58,51 @@ const postRepositoryPullRequestCreateAction: ReqHandler = async (
let variant: RepositoryPullRequestCreateFormVariant | null = null;
if (desiredState === PullRequestFormState.COMPARE) {
+ // source
+ const sourceParentOrg = await orgService.getOrganizationBySlug(
+ sourceParentOrgSlug
+ );
+ const sourceRepo = await repoService.getRepository(
+ sourceParentOrgSlug,
+ sourceRepoSlug
+ );
+ // target
+ const targetParentOrg = await orgService.getOrganizationBySlug(
+ targetParentOrgSlug
+ );
+ const targetRepo = await repoService.getRepository(
+ targetParentOrgSlug,
+ targetRepoSlug
+ );
+
+ if (
+ sourceParentOrg == null ||
+ sourceRepo == null ||
+ targetParentOrg == null ||
+ targetRepo == null
+ ) {
+ return reply.status(404).callNotFound();
+ }
+
+ const fileDiffs = await repoService.getRepositoryRefDiff(
+ sourceRepo,
+ sourceRepoFromBranch,
+ targetRepoDestBranch
+ );
+
variant = {
state: desiredState,
data: {
+ fileDiffs,
source: {
- parentOrg,
- repo,
- branch: "",
+ parentOrg: sourceParentOrg,
+ repo: sourceRepo,
+ branch: sourceRepoFromBranch,
},
target: {
- parentOrg,
- repo,
- branch: "",
+ parentOrg: targetParentOrg,
+ repo: targetRepo,
+ branch: targetRepoDestBranch,
},
},
};
@@ -5,8 +5,15 @@ import React from "react";
// generated via script[generate:prisma]
import type { Organization, Repository } from "@prisma/client";
// app
-import type { RepositoryForkedFromRepoMeta } from "../types";
+import type {
+ AppThemeScheme,
+ RepositoryFileDiff,
+ RepositoryForkedFromRepoMeta,
+} from "../types";
import { Grid } from "../components/Grid";
+import { IslandWrapper } from "../components/IslandWrapper.styled";
+// app islands
+import RepositoryFilesDiffsList from "./RepositoryFilesDiffsList";
export enum PullRequestFormState {
CONFIGURE = "configure",
@@ -39,6 +46,7 @@ export type RepositoryPullRequestCreateFormPropsByState<
}
: S extends PullRequestFormState.COMPARE
? {
+ fileDiffs: RepositoryFileDiff[];
source: RepositoryPullRequestTarget;
target: RepositoryPullRequestTarget;
}
@@ -72,6 +80,7 @@ export type RepositoryPullRequestCreateFormVariant =
export interface RepositoryPullRequestCreateFormProps
extends RepositoryPullRequestCreateFormPropsCommon {
+ themeScheme: AppThemeScheme;
variant: RepositoryPullRequestCreateFormVariant;
}
@@ -117,7 +126,7 @@ const isErrorStateData = (
typeof i !== "undefined" && i != null && s === PullRequestFormState.ERROR;
const RepositoryPullRequestCreateForm: ReactIsland<RepositoryPullRequestCreateFormProps> =
- ({ variant: { state, data } }) => {
+ ({ themeScheme, variant: { state, data } }) => {
// PullRequestFormState.CONFIGURE
if (isConfigureState(state) && isConfigureStateData(state, data)) {
return (
@@ -143,6 +152,20 @@ const RepositoryPullRequestCreateForm: ReactIsland<RepositoryPullRequestCreateFo
name={"source_repository_slug"}
value={data.source.repo.slug}
/>
+ <input
+ type={"hidden"}
+ name={"target_parent_org_slug"}
+ value={
+ data.initialTarget?.parentOrg.slug || data.source.parentOrg.slug
+ }
+ />
+ <input
+ type={"hidden"}
+ name={"target_repository_slug"}
+ value={
+ data.initialTarget?.parentOrg.slug || data.source.repo.slug
+ }
+ />
<div>
<span>Source:</span>
@@ -202,7 +225,7 @@ const RepositoryPullRequestCreateForm: ReactIsland<RepositoryPullRequestCreateFo
/>
{" / "}
<select
- name={"target_repository_from_branch"}
+ name={"target_repository_dest_branch"}
defaultValue={
data.initialTarget != null
? data.initialTarget.branch
@@ -228,11 +251,6 @@ const RepositoryPullRequestCreateForm: ReactIsland<RepositoryPullRequestCreateFo
<button type={"submit"}>Go to COMPARE step</button>
</form>
- <div>
- <pre>
- <code>{JSON.stringify(data, null, 2)}</code>
- </pre>
- </div>
</Grid.Col>
);
}
@@ -253,11 +271,15 @@ const RepositoryPullRequestCreateForm: ReactIsland<RepositoryPullRequestCreateFo
/>
<button type={"submit"}>Go to DETAILS step</button>
</form>
- <div>
- <pre>
- <code>{JSON.stringify(data, null, 2)}</code>
- </pre>
- </div>
+ <IslandWrapper data-islandid={`${RepositoryFilesDiffsList.name}$$0`}>
+ <RepositoryFilesDiffsList
+ filesDiffs={data.fileDiffs}
+ themeScheme={themeScheme}
+ orgSlug={data.source.parentOrg.slug}
+ repoSlug={data.source.repo.slug}
+ commitHash={""}
+ />
+ </IslandWrapper>
</Grid.Col>
);
}
@@ -38,7 +38,10 @@ const RepositoryPullRequestCreateView: ReactView<RepositoryPullRequestCreateView
<IslandWrapper
data-islandid={`${RepositoryPullRequestCreateForm.name}$$0`}
>
- <RepositoryPullRequestCreateForm variant={variant} />
+ <RepositoryPullRequestCreateForm
+ themeScheme={commonProps.themeScheme}
+ variant={variant}
+ />
</IslandWrapper>
</PageWrapper>
</Layout>