mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Show modal for error renaming project (#19040)
GitOrigin-RevId: 229e64775897d646ed8c13f12d3bcc9400f2a3b9
This commit is contained in:
parent
bee698c01d
commit
6db455d63e
1 changed files with 8 additions and 12 deletions
|
@ -18,6 +18,7 @@ import getMeta from '../../utils/meta'
|
|||
import { useUserContext } from './user-context'
|
||||
import { saveProjectSettings } from '@/features/editor-left-menu/utils/api'
|
||||
import { PermissionsLevel } from '@/features/ide-react/types/permissions'
|
||||
import { useModalsContext } from '@/features/ide-react/context/modals-context'
|
||||
|
||||
type writefullAdButtons = '' | 'try-it' | 'log-in'
|
||||
|
||||
|
@ -59,6 +60,7 @@ export const EditorProvider: FC = ({ children }) => {
|
|||
const ide = useIdeContext()
|
||||
const { id: userId } = useUserContext()
|
||||
const { role } = useDetachContext()
|
||||
const { showGenericMessageModal } = useModalsContext()
|
||||
|
||||
const { owner, features, _id: projectId } = useProjectContext()
|
||||
|
||||
|
@ -119,24 +121,18 @@ export const EditorProvider: FC = ({ children }) => {
|
|||
(response: any) => {
|
||||
setProjectName(oldName)
|
||||
const { data, status } = response
|
||||
if (status === 400) {
|
||||
return ide.showGenericMessageModal(
|
||||
'Error renaming project',
|
||||
data
|
||||
)
|
||||
} else {
|
||||
return ide.showGenericMessageModal(
|
||||
'Error renaming project',
|
||||
'Please try again in a moment'
|
||||
)
|
||||
}
|
||||
|
||||
showGenericMessageModal(
|
||||
'Error renaming project',
|
||||
status === 400 ? data : 'Please try again in a moment'
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
return newName
|
||||
})
|
||||
},
|
||||
[ide, setProjectName, projectId]
|
||||
[setProjectName, projectId, showGenericMessageModal]
|
||||
)
|
||||
|
||||
const { setTitle } = useBrowserWindow()
|
||||
|
|
Loading…
Reference in a new issue