Skip to content

Commit

Permalink
UI: update sync conflict modal message
Browse files Browse the repository at this point in the history
Fix: add missing imports
  • Loading branch information
AbdulrhmnGhanem committed Nov 7, 2022
1 parent 4496ed9 commit 12af2ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/NewProject/ConflictModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ConflictModal = ({
open={conflictModalOpen}
onClose={onClose}
>
<Modal.Header>Heads up!</Modal.Header>
<Modal.Header>A project with that name already exists.</Modal.Header>
<Modal.Content>
<p>{message}</p>
<Form>
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/NewProject/Sync/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useRouter } from 'next/router'
import isEmpty from 'lodash/isEmpty'

import { AuthContext } from '@contexts/AuthContext'
import { deleteRepo, mirrorRepo } from '@utils/giteaApi'
import { urlToName } from '@utils/index'
import { deleteRepo, mirrorRepo, repoExists } from '@utils/giteaApi'
import { urlToName, waitFor } from '@utils/index'
import SyncRepoFromModel from '@models/SyncRepoForm'
import useForm from '@hooks/useForm'
import { SyncOp, NoOp } from '../Ops'
Expand All @@ -24,7 +24,7 @@ const Sync = ({ setUserOp }) => {
const [loading, setLoading] = useState(false)
const [message, setMessage] = useState({})
const [conflictModalOpen, setConflictModalOpen] = useState(false)
const projectName = urlToName(form.url)
const repoName = urlToName(form.url)

const uid = user?.id
const username = user?.username
Expand Down Expand Up @@ -134,7 +134,7 @@ const Sync = ({ setUserOp }) => {
const repoName = urlToName(repoURL)

const deletedRepoSuccessfully = await deleteRepo(
`${user.username}/${projectName}`,
`${user.username}/${repoName}`,
apiToken,
)

Expand All @@ -154,7 +154,7 @@ const Sync = ({ setUserOp }) => {

setLoading(false)
setMessage({
content: `Couldn't overwrite "${projectName}"`,
content: `Couldn't overwrite "${repoName}"`,
color: 'red',
})
}
Expand Down Expand Up @@ -205,7 +205,7 @@ const Sync = ({ setUserOp }) => {
</div>
<SyncConflictModal
conflictModalOpen={conflictModalOpen}
originalProjectName={projectName}
originalProjectName={repoName}
onClose={() => {
setUserOp(NoOp)
// Close the modal
Expand Down
4 changes: 2 additions & 2 deletions frontend/test/ConflictModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ it('opens conflict modal if the project name conflict with existing project', as
// Click the Sync button
fireEvent.click(screen.getByText('Sync'))
// Wait the modal to appear
await screen.findByText('Heads up!')
await screen.findByText('A project with that name already exists.')
// It should set the userOp to sync
expect(setUserOp).toHaveBeenCalled()

Expand Down Expand Up @@ -82,7 +82,7 @@ it('changes the overwrite button to OK if the new project name does not cause co
// Click the Sync button
fireEvent.click(screen.getByText('Sync'))
// Wait the modal to appear.
await screen.findByText('Heads up!')
await screen.findByText('A project with that name already exists.')

const conflictModalInput = screen.getAllByRole('textbox')[1] as HTMLInputElement
// Change the project name.
Expand Down

0 comments on commit 12af2ab

Please sign in to comment.