diff --git a/CHANGELOG.md b/CHANGELOG.md index ceecac24d848..deda25fb5c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -133,8 +133,8 @@ - [File associations are created on Windows and macOS][6077]. This allows opening Enso files by double-clicking them in the file explorer. - [Feedback when renaming a project][6366]. When the user tries to rename the - project to an invalid name, a helpful error message is shown and the name is - reverted. + project to an invalid name, a helpful error message is shown and the text + field stays the same as to give the user the opportunity to fix the mistake. [6366]: https://github.com/enso-org/enso/pull/6366 diff --git a/app/gui/controller/engine-protocol/src/common/error.rs b/app/gui/controller/engine-protocol/src/common/error.rs index ea842f8c46c6..adbe8c46aadd 100644 --- a/app/gui/controller/engine-protocol/src/common/error.rs +++ b/app/gui/controller/engine-protocol/src/common/error.rs @@ -30,4 +30,7 @@ pub mod code { /// Signals that requested project is already under version control. pub const VCS_ALREADY_EXISTS: i64 = 1005; + + /// Signals that project name is invalid. + pub const PROJECT_NAME_INVALID: i64 = 4001; } diff --git a/app/gui/src/model/project/synchronized.rs b/app/gui/src/model/project/synchronized.rs index 54070a9bee4a..4849bd9e005a 100644 --- a/app/gui/src/model/project/synchronized.rs +++ b/app/gui/src/model/project/synchronized.rs @@ -30,14 +30,6 @@ use parser::Parser; -// ================= -// === Constants === -// ================= - -const ERROR_CODE_PROJECT_NAME_INVALID: i64 = 4001; - - - // ================= // === Profiling === // ================= @@ -725,8 +717,7 @@ impl model::project::API for Project { let project_name = ProjectName::new_unchecked(name); project_manager.rename_project(&project_id, &project_name).await.map_err(|error| { match error { - RpcError::RemoteError(cause) - if cause.code == ERROR_CODE_PROJECT_NAME_INVALID => + RpcError::RemoteError(cause) if cause.code == code::PROJECT_NAME_INVALID => failure::Error::from(ProjectNameInvalid { cause: cause.message }), error => error.into(), } diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs b/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs index caa3dd698a78..5061c6f7568a 100644 --- a/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs +++ b/app/gui/view/graph-editor/src/component/breadcrumbs/project_name.rs @@ -230,7 +230,7 @@ impl ProjectNameModel { let parser = Parser::new(); match parser.parse_line_ast(name).map(|ast| ast.shape().clone()) { Ok(ast::Shape::Cons(_)) => Ok(()), - _ => Err("The project name should be in Upper_Snake_Case.".to_owned()), + _ => Err("The project name should use the 'Upper_Snake' case.".to_owned()), } } diff --git a/app/gui/view/src/popup.rs b/app/gui/view/src/popup.rs index 778f423134b2..88bf615f8273 100644 --- a/app/gui/view/src/popup.rs +++ b/app/gui/view/src/popup.rs @@ -91,8 +91,9 @@ ensogl::define_endpoints! { // ============ /// A temporary text message on top of the screen. -#[derive(Debug, Clone, CloneRef)] +#[derive(Debug, Clone, CloneRef, Deref)] pub struct View { + #[deref] frp: Frp, model: Model, } @@ -107,7 +108,7 @@ impl View { frp::extend! { network init <- source_(); let scene_shape = app.display.default_scene.shape(); - _eval <- all_with(scene_shape, &init, f!([model] (scene_shape, _init) + _eval <- all_with(scene_shape, &init, f!((scene_shape, _init) model.set_label_position(scene_shape.height); )); @@ -134,11 +135,3 @@ impl display::Object for View { self.model.label.display_object() } } - -impl Deref for View { - type Target = Frp; - - fn deref(&self) -> &Self::Target { - &self.frp - } -}