From 4164277d2243da39f037437cf617b7de075849b8 Mon Sep 17 00:00:00 2001 From: Adam Obuchowicz Date: Fri, 21 Jun 2024 13:28:30 +0200 Subject: [PATCH] Renaming project in GUI (#10243) Fixes #10073 [Screencast from 2024-06-11 13-01-10.webm](https://github.com/enso-org/enso/assets/3919101/2917ad41-e080-482b-9a69-690e80087132) --- CHANGELOG.md | 2 + app/gui2/shared/languageServer.ts | 5 ++ app/gui2/shared/languageServerTypes.ts | 6 +- app/gui2/src/App.vue | 9 ++- app/gui2/src/components/GraphEditor.vue | 14 +--- app/gui2/src/components/NavBar.vue | 20 ++--- app/gui2/src/components/NavBreadcrumb.vue | 16 +++- app/gui2/src/components/NavBreadcrumbs.vue | 31 ++++++-- app/gui2/src/components/TopBar.vue | 16 +--- app/gui2/src/providers/graphStackNavigator.ts | 5 ++ .../src/stores/project/executionContext.ts | 76 +++++++++++++++++-- app/gui2/src/stores/project/index.ts | 43 +++++++---- .../src/util/__tests__/qualifiedName.test.ts | 14 ++++ app/gui2/src/util/qualifiedName.ts | 16 ++++ app/gui2/src/views/ProjectView.vue | 5 ++ .../lib/dashboard/src/layouts/Editor.tsx | 39 +++++++++- app/ide-desktop/lib/types/types.d.ts | 1 + 17 files changed, 247 insertions(+), 71 deletions(-) create mode 100644 app/gui2/src/providers/graphStackNavigator.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index a4a670d59dd..554528445fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - [Copy-pasting multiple nodes][10194]. - The documentation editor has [formatting toolbars][10064]. - The documentation editor supports [rendering images][10205]. +- [Project may be renamed in Project View][10243] - [Fixed a bug where drop-down were not displayed for some arguments][10297]. For example, `locale` parameter of `Equal_Ignore_Case` kind in join component. - [Node previews][10310]: Node may be previewed by hovering output port while @@ -19,6 +20,7 @@ [10194]: https://github.com/enso-org/enso/pull/10194 [10198]: https://github.com/enso-org/enso/pull/10198 [10205]: https://github.com/enso-org/enso/pull/10205 +[10243]: https://github.com/enso-org/enso/pull/10243 [10297]: https://github.com/enso-org/enso/pull/10297 [10310]: https://github.com/enso-org/enso/pull/10310 diff --git a/app/gui2/shared/languageServer.ts b/app/gui2/shared/languageServer.ts index 94ad7f02569..2f514fd9c51 100644 --- a/app/gui2/shared/languageServer.ts +++ b/app/gui2/shared/languageServer.ts @@ -479,6 +479,11 @@ export class LanguageServer extends ObservableV2> { + return this.request('refactoring/renameProject', { namespace, oldName, newName }) + } + /** [Documentation](https://github.com/enso-org/enso/blob/develop/docs/language-server/protocol-language-server.md#profilingstart) */ profilingStart(memorySnapshot?: boolean): Promise> { return this.request('profiling/start', { memorySnapshot }) diff --git a/app/gui2/shared/languageServerTypes.ts b/app/gui2/shared/languageServerTypes.ts index 2898847fb50..9aac47a2fb1 100644 --- a/app/gui2/shared/languageServerTypes.ts +++ b/app/gui2/shared/languageServerTypes.ts @@ -343,7 +343,11 @@ export type Notifications = { 'file/event': (param: { path: Path; kind: FileEventKind }) => void 'file/rootAdded': (param: {}) => void 'file/rootRemoved': (param: {}) => void - 'refactoring/projectRenamed': (param: {}) => void + 'refactoring/projectRenamed': (param: { + oldNormalizedName: string + newNormalizedName: string + newName: string + }) => void } export type Event = Parameters[0] diff --git a/app/gui2/src/App.vue b/app/gui2/src/App.vue index 8de0a73fdd0..ad1446574df 100644 --- a/app/gui2/src/App.vue +++ b/app/gui2/src/App.vue @@ -25,6 +25,7 @@ const props = defineProps<{ logEvent: LogEvent hidden: boolean ignoreParamsRegex?: RegExp + renameProject: (newName: string) => void }>() const classSet = provideAppClassSet() @@ -71,7 +72,13 @@ registerAutoBlurHandler() :unrecognizedOptions="appConfig.unrecognizedOptions" :config="appConfig.config" /> - + diff --git a/app/gui2/src/components/GraphEditor.vue b/app/gui2/src/components/GraphEditor.vue index 53a4b9f3c5b..3e19c45fbd0 100644 --- a/app/gui2/src/components/GraphEditor.vue +++ b/app/gui2/src/components/GraphEditor.vue @@ -28,19 +28,19 @@ import { useDoubleClick } from '@/composables/doubleClick' import { keyboardBusy, keyboardBusyExceptIn, unrefElement, useEvent } from '@/composables/events' import { groupColorVar } from '@/composables/nodeColors' import type { PlacementStrategy } from '@/composables/nodeCreation' -import { useStackNavigator } from '@/composables/stackNavigator' import { useSyncLocalStorage } from '@/composables/syncLocalStorage' import { provideGraphNavigator, type GraphNavigator } from '@/providers/graphNavigator' import { provideNodeColors } from '@/providers/graphNodeColors' import { provideNodeCreation } from '@/providers/graphNodeCreation' import { provideGraphSelection } from '@/providers/graphSelection' +import { provideStackNavigator } from '@/providers/graphStackNavigator' import { provideInteractionHandler } from '@/providers/interactionHandler' import { provideKeyboard } from '@/providers/keyboard' import { provideWidgetRegistry } from '@/providers/widgetRegistry' import { provideGraphStore, type NodeId } from '@/stores/graph' import { asNodeId } from '@/stores/graph/graphDatabase' import type { RequiredImport } from '@/stores/graph/imports' -import { provideProjectStore } from '@/stores/project' +import { useProjectStore } from '@/stores/project' import { provideSuggestionDbStore } from '@/stores/suggestionDatabase' import type { Typename } from '@/stores/suggestionDatabase/entry' import { provideVisualizationStore } from '@/stores/visualization' @@ -70,7 +70,7 @@ import { } from 'vue' const keyboard = provideKeyboard() -const projectStore = provideProjectStore() +const projectStore = useProjectStore() const suggestionDb = provideSuggestionDbStore(projectStore) const graphStore = provideGraphStore(projectStore, suggestionDb) const widgetRegistry = provideWidgetRegistry(graphStore.db) @@ -194,7 +194,7 @@ function panToSelected() { // == Breadcrumbs == -const stackNavigator = useStackNavigator(projectStore, graphStore) +const stackNavigator = provideStackNavigator(projectStore, graphStore) // === Toasts === @@ -706,14 +706,8 @@ const groupColors = computed(() => { v-model:showColorPicker="showColorPicker" v-model:showCodeEditor="showCodeEditor" v-model:showDocumentationEditor="showDocumentationEditor" - :breadcrumbs="stackNavigator.breadcrumbLabels.value" - :allowNavigationLeft="stackNavigator.allowNavigationLeft.value" - :allowNavigationRight="stackNavigator.allowNavigationRight.value" :zoomLevel="100.0 * graphNavigator.targetScale" :componentsSelected="nodeSelection.selected.size" - @breadcrumbClick="stackNavigator.handleBreadcrumbClick" - @back="stackNavigator.exitNode" - @forward="stackNavigator.enterNextNodeFromHistory" @recordOnce="onRecordOnceButtonPress()" @fitToAllClicked="zoomToSelected" @zoomIn="graphNavigator.stepZoom(+1)" diff --git a/app/gui2/src/components/NavBar.vue b/app/gui2/src/components/NavBar.vue index baa98579def..b979d0ecd7b 100644 --- a/app/gui2/src/components/NavBar.vue +++ b/app/gui2/src/components/NavBar.vue @@ -1,14 +1,10 @@ diff --git a/app/gui2/src/components/NavBreadcrumb.vue b/app/gui2/src/components/NavBreadcrumb.vue index d9816dc5781..74cbb209dfa 100644 --- a/app/gui2/src/components/NavBreadcrumb.vue +++ b/app/gui2/src/components/NavBreadcrumb.vue @@ -1,10 +1,20 @@ diff --git a/app/gui2/src/components/NavBreadcrumbs.vue b/app/gui2/src/components/NavBreadcrumbs.vue index d5822fe646f..37e99640cfb 100644 --- a/app/gui2/src/components/NavBreadcrumbs.vue +++ b/app/gui2/src/components/NavBreadcrumbs.vue @@ -1,31 +1,50 @@