Skip to content

Form validation improvement 2 #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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 @@ -24,6 +24,7 @@ const PipelineListWrapper: FC<Partial<RepoSummaryViewProps>> = () => {
/>
<CreatePipelineDialog
isOpen={createPipelineOpen}
useTranslationStore={useTranslationStore}
onClose={() => setCreatePipelineOpen(false)}
onSubmit={() => {
setCreatePipelineOpen(false)
Expand Down
4 changes: 2 additions & 2 deletions apps/design-system/src/subjects/views/signin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { noop } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { SignInPage } from '@harnessio/ui/views'

export const SignInView = () => {
return <SignInPage isLoading={false} handleSignIn={noop} error={''} />
return <SignInPage isLoading={false} handleSignIn={noop} error={''} useTranslationStore={useTranslationStore} />
}
4 changes: 2 additions & 2 deletions apps/design-system/src/subjects/views/signup/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { noop } from '@utils/viewUtils'
import { noop, useTranslationStore } from '@utils/viewUtils'

import { SignUpPage } from '@harnessio/ui/views'

export const SignUpView = () => {
return <SignUpPage isLoading={false} handleSignUp={noop} error={''} />
return <SignUpPage isLoading={false} handleSignUp={noop} error={''} useTranslationStore={useTranslationStore} />
}
2 changes: 2 additions & 0 deletions apps/gitness/src/pages-v2/pipeline/create-pipeline-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CreatePipelineDialog as CreatePipelineDialogView, CreatePipelineFormTyp

import { useRoutes } from '../../framework/context/NavigationContext'
import { useGetRepoRef } from '../../framework/hooks/useGetRepoPath'
import { useTranslationStore } from '../../i18n/stores/i18n-store'
import { PathParams } from '../../RouteDefinitions'
import { apiBranches2BranchNames, apiBranches2DefaultBranchName } from '../repo/transform-utils/branch-transform'
import { useCreatePipelineStore } from './stores/create-pipeline-dialog.store'
Expand Down Expand Up @@ -69,6 +70,7 @@ export default function CreatePipelineDialog({ open, onClose }: CreatePipelineDi
onSubmit={onSubmit}
onCancel={onCloseInternal}
useCreatePipelineStore={useCreatePipelineStore}
useTranslationStore={useTranslationStore}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ImporterProviderType, ImportSpaceRequestBody, useImportSpaceMutation }
import { ImportProjectFormFields, ImportProjectPage, ProviderOptionsEnum } from '@harnessio/ui/views'

import { useRoutes } from '../../framework/context/NavigationContext'
import { useTranslationStore } from '../../i18n/stores/i18n-store'

export const ImportProjectContainer = () => {
const routes = useRoutes()
Expand Down Expand Up @@ -53,6 +54,7 @@ export const ImportProjectContainer = () => {
onFormCancel={onCancel}
isLoading={isLoading}
apiErrorsValue={error?.message?.toString()}
useTranslationStore={useTranslationStore}
/>
)
}
4 changes: 2 additions & 2 deletions apps/gitness/src/pages-v2/repo/repo-create-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useListGitignoreQuery,
useListLicensesQuery
} from '@harnessio/code-service-client'
import { FormFields, RepoCreatePage as RepoCreatePageView } from '@harnessio/ui/views'
import { RepoCreateFormFields, RepoCreatePage as RepoCreatePageView } from '@harnessio/ui/views'

// import { Toaster } from '../../components-v2/toaster'
import { useRoutes } from '../../framework/context/NavigationContext'
Expand All @@ -21,7 +21,7 @@ export const CreateRepo = () => {
const spaceURL = useGetSpaceURLParam()
const navigate = useNavigate()

const onSubmit = (data: FormFields) => {
const onSubmit = (data: RepoCreateFormFields) => {
const repositoryRequest: OpenapiCreateRepositoryRequest = {
default_branch: 'main',
parent_ref: spaceURL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ImportMultipleReposFormFields, RepoImportMultiplePage } from '@harnessi
import { useRoutes } from '../../framework/context/NavigationContext'
import { useGetSpaceURLParam } from '../../framework/hooks/useGetSpaceParam'
import { useAPIPath } from '../../hooks/useAPIPath'
import { useTranslationStore } from '../../i18n/stores/i18n-store'
import { getRepoProviderConfig, PROVIDER_TYPE_MAP } from './constants/import-providers-map'

export const ImportMultipleRepos = () => {
Expand Down Expand Up @@ -73,13 +74,12 @@ export const ImportMultipleRepos = () => {

return (
// @TODO: Add loading states and error handling when API is available
<>
<RepoImportMultiplePage
onFormSubmit={onSubmit}
onFormCancel={onCancel}
isLoading={loading}
apiErrorsValue={apiError}
/>
</>
<RepoImportMultiplePage
onFormSubmit={onSubmit}
onFormCancel={onCancel}
isLoading={loading}
apiErrorsValue={apiError}
useTranslationStore={useTranslationStore}
/>
)
}
2 changes: 2 additions & 0 deletions apps/gitness/src/pages-v2/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useOnLoginMutation } from '@harnessio/code-service-client'
import { SignInData, SignInPage } from '@harnessio/ui/views'

import { useRoutes } from '../framework/context/NavigationContext'
import { useTranslationStore } from '../i18n/stores/i18n-store'

export const SignIn: FC = () => {
const routes = useRoutes()
Expand Down Expand Up @@ -32,6 +33,7 @@ export const SignIn: FC = () => {
})
}}
error={error?.message}
useTranslationStore={useTranslationStore}
/>
)
}
14 changes: 11 additions & 3 deletions apps/gitness/src/pages-v2/signup.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useEffect } from 'react'
import { FC, useEffect } from 'react'
import { useNavigate } from 'react-router-dom'

import { useOnRegisterMutation } from '@harnessio/code-service-client'
import { SignUpData, SignUpPage } from '@harnessio/ui/views'

import { useRoutes } from '../framework/context/NavigationContext'
import { useTranslationStore } from '../i18n/stores/i18n-store'

export const SignUp: React.FC = () => {
export const SignUp: FC = () => {
const routes = useRoutes()
const navigate = useNavigate()

Expand Down Expand Up @@ -34,5 +35,12 @@ export const SignUp: React.FC = () => {
})
}

return <SignUpPage isLoading={isLoading} handleSignUp={handleSignUp} error={error?.message} />
return (
<SignUpPage
isLoading={isLoading}
handleSignUp={handleSignUp}
error={error?.message}
useTranslationStore={useTranslationStore}
/>
)
}
6 changes: 0 additions & 6 deletions apps/gitness/src/pages/pull-request/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DiffModeEnum } from '@git-diff-view/react'
import { atom } from 'jotai'
import { z } from 'zod'

import {
EnumPullReqReviewDecision,
Expand Down Expand Up @@ -197,11 +196,6 @@ export interface FilterViewProps {

export type EnumPullReqReviewDecisionExtended = EnumPullReqReviewDecision | 'outdated'

export const formSchema = z.object({
title: z.string().min(1, { message: 'Please provide a pull request title' }),
description: z.string().optional()
})
export type FormFields = z.infer<typeof formSchema> // Automatically generate a type from the schema
export const changesInfoAtom = atom<{ path?: string; raw?: string; fileViews?: Map<string, string> }>({})

export interface TypesDiffStats {
Expand Down
Loading