Skip to content

Commit

Permalink
Merge pull request #178 from github-community-projects/fix-edit-dialog
Browse files Browse the repository at this point in the history
fix: edit mirror dialog to display current mirror name
  • Loading branch information
zkoppert authored Jun 13, 2024
2 parents 55bf136 + 07f6ad9 commit 22a0ee6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/app/components/dialog/EditMirrorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, FormControl, Label, Link, Text, TextInput } from '@primer/react'
import { Stack } from '@primer/react/lib-esm/Stack'
import { Dialog } from '@primer/react/lib-esm/drafts'

import { useState } from 'react'
import { useEffect, useState } from 'react'

interface EditMirrorDialogProps {
orgLogin: string
Expand All @@ -29,8 +29,12 @@ export const EditMirrorDialog = ({
closeDialog,
editMirror,
}: EditMirrorDialogProps) => {
// set to default value of 'repository-name' for display purposes
const [newMirrorName, setNewMirrorName] = useState('repository-name')
// set to the current mirror name for display purposes
const [newMirrorName, setNewMirrorName] = useState(mirrorName)

useEffect(() => {
setNewMirrorName(mirrorName)
}, [mirrorName, setNewMirrorName])

if (!isOpen) {
return null
Expand All @@ -45,7 +49,7 @@ export const EditMirrorDialog = ({
content: 'Cancel',
onClick: () => {
closeDialog()
setNewMirrorName('repository-name')
setNewMirrorName(mirrorName)
},
},
{
Expand All @@ -57,14 +61,14 @@ export const EditMirrorDialog = ({
mirrorName,
newMirrorName,
})
setNewMirrorName('repository-name')
setNewMirrorName(mirrorName)
},
disabled: newMirrorName === 'repository-name' || newMirrorName === '',
disabled: newMirrorName === mirrorName || newMirrorName === '',
},
]}
onClose={() => {
closeDialog()
setNewMirrorName('repository-name')
setNewMirrorName(mirrorName)
}}
width="large"
>
Expand All @@ -74,7 +78,7 @@ export const EditMirrorDialog = ({
<TextInput
onChange={(e) => setNewMirrorName(e.target.value)}
block
placeholder="e.g. repository-name"
placeholder={mirrorName}
maxLength={100}
/>
<FormControl.Caption>
Expand Down

0 comments on commit 22a0ee6

Please sign in to comment.