mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #15029 from overleaf/mf-remove-angular-settings-dependency-rename-project
[web] Remove angular settings dependency when renaming a project in editor top bar GitOrigin-RevId: 45a8b71fc84135f5291217f613cc95aea7192c35
This commit is contained in:
parent
9daa8f5d98
commit
3324a14202
5 changed files with 15 additions and 10 deletions
|
@ -30,6 +30,7 @@ export type ProjectSettings = {
|
||||||
imageName: string
|
imageName: string
|
||||||
rootDocId: string
|
rootDocId: string
|
||||||
spellCheckLanguage: string
|
spellCheckLanguage: string
|
||||||
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SaveUserSettings = Partial<
|
type SaveUserSettings = Partial<
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { useProjectContext } from './project-context'
|
||||||
import { useDetachContext } from './detach-context'
|
import { useDetachContext } from './detach-context'
|
||||||
import getMeta from '../../utils/meta'
|
import getMeta from '../../utils/meta'
|
||||||
import { useUserContext } from './user-context'
|
import { useUserContext } from './user-context'
|
||||||
|
import { saveProjectSettings } from '@/features/editor-left-menu/utils/api'
|
||||||
|
|
||||||
export const EditorContext = createContext()
|
export const EditorContext = createContext()
|
||||||
|
|
||||||
|
@ -42,18 +43,23 @@ EditorContext.Provider.propTypes = {
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EditorProvider({ children, settings }) {
|
export function EditorProvider({ children }) {
|
||||||
const ide = useIdeContext()
|
const ide = useIdeContext()
|
||||||
const { id: userId } = useUserContext()
|
const { id: userId } = useUserContext()
|
||||||
const { role } = useDetachContext()
|
const { role } = useDetachContext()
|
||||||
|
|
||||||
const { owner, features } = useProjectContext({
|
const {
|
||||||
|
owner,
|
||||||
|
features,
|
||||||
|
_id: projectId,
|
||||||
|
} = useProjectContext({
|
||||||
owner: PropTypes.shape({
|
owner: PropTypes.shape({
|
||||||
_id: PropTypes.string.isRequired,
|
_id: PropTypes.string.isRequired,
|
||||||
}),
|
}),
|
||||||
features: PropTypes.shape({
|
features: PropTypes.shape({
|
||||||
compileGroup: PropTypes.string,
|
compileGroup: PropTypes.string,
|
||||||
}),
|
}),
|
||||||
|
_id: PropTypes.string.isRequired,
|
||||||
})
|
})
|
||||||
|
|
||||||
const cobranding = useMemo(() => {
|
const cobranding = useMemo(() => {
|
||||||
|
@ -106,7 +112,7 @@ export function EditorProvider({ children, settings }) {
|
||||||
newName => {
|
newName => {
|
||||||
setProjectName(oldName => {
|
setProjectName(oldName => {
|
||||||
if (oldName !== newName) {
|
if (oldName !== newName) {
|
||||||
settings.saveProjectSettings({ name: newName }).catch(response => {
|
saveProjectSettings(projectId, { name: newName }).catch(response => {
|
||||||
setProjectName(oldName)
|
setProjectName(oldName)
|
||||||
const { data, status } = response
|
const { data, status } = response
|
||||||
if (status === 400) {
|
if (status === 400) {
|
||||||
|
@ -122,7 +128,7 @@ export function EditorProvider({ children, settings }) {
|
||||||
return newName
|
return newName
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[settings, ide, setProjectName]
|
[ide, setProjectName, projectId]
|
||||||
)
|
)
|
||||||
|
|
||||||
const { setTitle } = useBrowserWindow()
|
const { setTitle } = useBrowserWindow()
|
||||||
|
@ -192,7 +198,6 @@ export function EditorProvider({ children, settings }) {
|
||||||
|
|
||||||
EditorProvider.propTypes = {
|
EditorProvider.propTypes = {
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
settings: PropTypes.object,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useEditorContext(propTypes) {
|
export function useEditorContext(propTypes) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { SplitTestProvider } from './split-test-context'
|
||||||
import { FileTreeDataProvider } from './file-tree-data-context'
|
import { FileTreeDataProvider } from './file-tree-data-context'
|
||||||
import { ProjectSettingsProvider } from '../../features/editor-left-menu/context/project-settings-context'
|
import { ProjectSettingsProvider } from '../../features/editor-left-menu/context/project-settings-context'
|
||||||
|
|
||||||
export function ContextRoot({ children, ide, settings }) {
|
export function ContextRoot({ children, ide }) {
|
||||||
return (
|
return (
|
||||||
<SplitTestProvider>
|
<SplitTestProvider>
|
||||||
<IdeProvider ide={ide}>
|
<IdeProvider ide={ide}>
|
||||||
|
@ -22,7 +22,7 @@ export function ContextRoot({ children, ide, settings }) {
|
||||||
<ProjectProvider>
|
<ProjectProvider>
|
||||||
<FileTreeDataProvider>
|
<FileTreeDataProvider>
|
||||||
<DetachProvider>
|
<DetachProvider>
|
||||||
<EditorProvider settings={settings}>
|
<EditorProvider>
|
||||||
<ProjectSettingsProvider>
|
<ProjectSettingsProvider>
|
||||||
<LayoutProvider>
|
<LayoutProvider>
|
||||||
<LocalCompileProvider>
|
<LocalCompileProvider>
|
||||||
|
@ -45,7 +45,6 @@ export function ContextRoot({ children, ide, settings }) {
|
||||||
ContextRoot.propTypes = {
|
ContextRoot.propTypes = {
|
||||||
children: PropTypes.any,
|
children: PropTypes.any,
|
||||||
ide: PropTypes.object,
|
ide: PropTypes.object,
|
||||||
settings: PropTypes.object,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rootContext = createSharedContext(ContextRoot)
|
export const rootContext = createSharedContext(ContextRoot)
|
||||||
|
|
|
@ -229,7 +229,7 @@ export const ScopeDecorator = (
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextRoot ide={ide} settings={{}}>
|
<ContextRoot ide={ide}>
|
||||||
<Story />
|
<Story />
|
||||||
</ContextRoot>
|
</ContextRoot>
|
||||||
)
|
)
|
||||||
|
|
|
@ -117,7 +117,7 @@ export function EditorProviders({
|
||||||
<ProjectProvider>
|
<ProjectProvider>
|
||||||
<FileTreeDataProvider>
|
<FileTreeDataProvider>
|
||||||
<DetachProvider>
|
<DetachProvider>
|
||||||
<EditorProvider settings={{}}>
|
<EditorProvider>
|
||||||
<ProjectSettingsProvider>
|
<ProjectSettingsProvider>
|
||||||
<LayoutProvider>
|
<LayoutProvider>
|
||||||
<LocalCompileProvider>
|
<LocalCompileProvider>
|
||||||
|
|
Loading…
Reference in a new issue