Skip to content

Commit

Permalink
Fixing Electron runner (#5633)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdanilo authored Feb 19, 2023
1 parent 2acc61d commit 663ed1e
Show file tree
Hide file tree
Showing 79 changed files with 7,601 additions and 3,831 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/gui/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
ensogl = { path = "../../../lib/rust/ensogl" }
enso-prelude = { path = "../../../lib/rust/prelude" }
enso-json-to-struct = { path = "../../../lib/rust/json-to-struct" }
semver = "1.0.0"

[build-dependencies]
Expand Down
61 changes: 27 additions & 34 deletions app/gui/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use enso_prelude::*;

use ensogl::system::web;
use enso_json_to_struct::json_to_struct;



Expand All @@ -37,37 +37,30 @@ pub fn engine_version_requirement() -> semver::VersionReq {
// === Args ===
// ============

ensogl::read_args! {
application_config_url: String,
authentication_enabled: bool,
dark_theme: bool,
data_gathering: bool,
debug: bool,
email: Option<String>,
emit_user_timing_measurements: bool,
enable_new_component_browser: bool,
enable_skip_and_freeze: bool,
enable_spector:bool,
entry: String,
frame: bool,
is_in_cloud: bool,
language_server_data: Option<String>,
language_server_rpc: Option<String>,
loader_download_to_init_ratio: f32,
max_before_main_entry_points_time_ms: f32,
namespace: Option<String>,
node_labels: bool,
pkg_js_url: String,
pkg_wasm_url: String,
platform: Option<web::platform::Platform>,
preferred_engine_version: Option<semver::Version>,
project: Option<String>,
project_manager: Option<String>,
shaders_url: String,
skip_min_version_check: bool,
/// When profiling the application (e.g. with the `./run profile` command), this argument
/// chooses what is profiled.
test_workflow: Option<String>,
theme: String,
use_loader: bool,
json_to_struct!(
"../../../../lib/rust/ensogl/pack/js/src/runner/config.json",
"../../../../app/ide-desktop/lib/content-config/src/config.json"
);

pub fn read_args() -> Args {
debug_span!("Reading application arguments from JS.").in_scope(|| {
let mut args = Args::default();
if let Ok(js_app) = ensogl::system::js::app::app() {
for param in js_app.config().params() {
if let Some(value) = param.value() {
let path = format!("{}.value", param.structural_name());
if let Some(err) = args.set(&path, value) {
error!("{}", err.display())
}
}
}
} else {
error!("Could not connect to JS application. Using default configuration.")
}
args
})
}

lazy_static! {
pub static ref ARGS: Args = read_args();
}
2 changes: 1 addition & 1 deletion app/gui/language/parser-scala/src/jsclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl From<serde_json::error::Error> for Error {

impl From<JsValue> for Error {
fn from(jsvalue: JsValue) -> Self {
Error::ScalaException(format!("{:?}", jsvalue))
Error::ScalaException(format!("{jsvalue:?}"))
}
}

Expand Down
50 changes: 31 additions & 19 deletions app/gui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,44 @@ impl BackendService {
/// Read backend configuration from the web arguments. See also [`web::Arguments`]
/// documentation.
pub fn from_web_arguments(args: &Args) -> FallibleResult<Self> {
if let Some(endpoint) = &args.project_manager {
if args.language_server_rpc.is_some() || args.language_server_data.is_some() {
let endpoint = args.groups.engine.options.project_manager_url.value.as_str();
let rpc_url_option = &args.groups.engine.options.rpc_url;
let data_url_option = &args.groups.engine.options.data_url;
let rpc_url = rpc_url_option.value.as_str();
let data_url = data_url_option.value.as_str();
if !endpoint.is_empty() {
if !rpc_url.is_empty() || !data_url.is_empty() {
Err(MutuallyExclusiveOptions.into())
} else {
let endpoint = endpoint.clone();
let endpoint = endpoint.to_owned();
Ok(Self::ProjectManager { endpoint })
}
} else {
match (&args.language_server_rpc, &args.language_server_data) {
(Some(json_endpoint), Some(binary_endpoint)) => {
let json_endpoint = json_endpoint.clone();
let binary_endpoint = binary_endpoint.clone();
let default_namespace = || constants::DEFAULT_PROJECT_NAMESPACE.to_owned();
let namespace = args.namespace.clone().unwrap_or_else(default_namespace);
let missing_project_name = || MissingOption(args.names().project());
let project_name = args.project.clone().ok_or_else(missing_project_name)?;
match (rpc_url, data_url) {
("", "") => Ok(default()),
("", _) => Err(MissingOption(rpc_url_option.__name__.to_owned()).into()),
(_, "") => Err(MissingOption(data_url_option.__name__.to_owned()).into()),
(json_endpoint, binary_endpoint) => {
let json_endpoint = json_endpoint.to_owned();
let binary_endpoint = binary_endpoint.to_owned();
let def_namespace = || constants::DEFAULT_PROJECT_NAMESPACE.to_owned();
let namespace = args.groups.engine.options.namespace.value.clone();
let namespace = if namespace.is_empty() { def_namespace() } else { namespace };
let project_name_option = &args.groups.startup.options.project;
let project_name = project_name_option.value.as_str();
let no_project_name = || MissingOption(project_name_option.__name__.to_owned());
let project_name = if project_name.is_empty() {
Err(no_project_name())
} else {
Ok(project_name.to_owned())
}?;
Ok(Self::LanguageServer {
json_endpoint,
binary_endpoint,
namespace,
project_name,
})
}
(None, None) => Ok(default()),
(None, _) => Err(MissingOption(args.names().language_server_rpc()).into()),
(_, None) => Err(MissingOption(args.names().language_server_data()).into()),
}
}
}
Expand Down Expand Up @@ -111,11 +123,11 @@ impl Startup {
/// Read configuration from the web arguments. See also [`web::Arguments`] documentation.
pub fn from_web_arguments() -> FallibleResult<Startup> {
let backend = BackendService::from_web_arguments(&ARGS)?;
let project_name = ARGS.project.clone().map(Into::into);
let initial_view = match ARGS.project {
Some(_) => InitialView::Project,
None => InitialView::WelcomeScreen,
};
let project_name = ARGS.groups.startup.options.project.value.as_str();
let no_project_name = project_name.is_empty();
let initial_view =
if no_project_name { InitialView::WelcomeScreen } else { InitialView::Project };
let project_name = (!no_project_name).as_some_from(|| project_name.to_owned().into());
let dom_parent_id = None;
Ok(Startup { backend, project_name, initial_view, dom_parent_id })
}
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/controller/ide/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ impl ManagingProjectAPI for Handle {
let name = make_project_name(&template);
let name = choose_unique_project_name(&existing_names, &name);
let name = ProjectName::new_unchecked(name);
let version =
enso_config::ARGS.preferred_engine_version.as_ref().map(ToString::to_string);
let version = &enso_config::ARGS.groups.engine.options.preferred_version.value;
let version = (!version.is_empty()).as_some_from(|| version.clone());
let action = MissingComponentAction::Install;

let create_result = self
Expand Down
7 changes: 4 additions & 3 deletions app/gui/src/ide/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Initializer {
config::InitialView::Project => view.switch_view_to_project(),
}

if enso_config::ARGS.emit_user_timing_measurements {
if enso_config::ARGS.groups.profile.options.emit_user_timing_measurements.value {
ensogl_app.display.connect_profiler_to_user_timing();
}
let status_bar = view.status_bar().clone_ref();
Expand Down Expand Up @@ -185,7 +185,8 @@ impl WithProjectManager {
pub async fn create_project(&self) -> FallibleResult<Uuid> {
use project_manager::MissingComponentAction::Install;
info!("Creating a new project named '{}'.", self.project_name);
let version = enso_config::ARGS.preferred_engine_version.as_ref().map(ToString::to_string);
let version = &enso_config::ARGS.groups.engine.options.preferred_version.value;
let version = (!version.is_empty()).as_some_from(|| version.clone());
let name = &self.project_name;
let response = self.project_manager.create_project(name, &None, &version, &Install);
Ok(response.await?.project_id)
Expand Down Expand Up @@ -244,7 +245,7 @@ pub fn register_views(app: &Application) {
type PlaceholderEntryType = ensogl_component::list_view::entry::Label;
app.views.register::<ensogl_component::list_view::ListView<PlaceholderEntryType>>();

if enso_config::ARGS.is_in_cloud {
if enso_config::ARGS.groups.startup.options.platform.value == "web" {
app.views.register::<ide_view::window_control_buttons::View>();
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/gui/src/profile_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub async fn main() {
// Run selected workflow.
let need_workflow = "`profile` entry point requires --workflow argument. \
Try --workflow=help to see a list of options.";
let selected = enso_config::ARGS.test_workflow.as_ref().expect(need_workflow);
let selected = &enso_config::ARGS.groups.profile.options.workflow.value;
if selected.is_empty() {
panic!("{need_workflow}");
}
reflect_match!(match selected as options {
"collapse_nodes" => profile_collapse_nodes().await,
"create_node" => profile_create_node().await,
Expand Down
6 changes: 3 additions & 3 deletions app/gui/view/graph-editor/src/component/node/action_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Icons {
let visibility = ToggleButton::new();
let skip = ToggleButton::new();
display_object.add_child(&visibility);
if ARGS.enable_skip_and_freeze {
if ARGS.groups.feature_preview.options.skip_and_freeze.value {
display_object.add_child(&freeze);
display_object.add_child(&skip);
}
Expand Down Expand Up @@ -198,12 +198,12 @@ impl Model {
self.icons.set_x(-size.x / 2.0);

self.place_button_in_slot(&self.icons.visibility, 0);
if ARGS.enable_skip_and_freeze {
if ARGS.groups.feature_preview.options.skip_and_freeze.value {
self.place_button_in_slot(&self.icons.skip, 1);
self.place_button_in_slot(&self.icons.freeze, 2);
}

let buttons_count = if ARGS.enable_skip_and_freeze {
let buttons_count = if ARGS.groups.feature_preview.options.skip_and_freeze.value {
// Toggle visualization, skip and freeze buttons.
3
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/gui/view/graph-editor/src/component/node/output/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl Model {

#[profile(Debug)]
fn set_label(&self, content: impl Into<String>) {
let str = if ARGS.node_labels { content.into() } else { default() };
let node_labels = ARGS.groups.style.options.node_labels.value;
let str = if node_labels { content.into() } else { default() };
self.label.set_content(str);
}

Expand Down
6 changes: 4 additions & 2 deletions app/gui/view/graph-editor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ const MACOS_TRAFFIC_LIGHTS_VERTICAL_CENTER: f32 =
const MAX_ZOOM: f32 = 1.0;

fn traffic_lights_gap_width() -> f32 {
let is_macos = ARGS.platform.map(|p| p.is_macos()) == Some(true);
if is_macos && !ARGS.frame {
let platform_str = ARGS.groups.startup.options.platform.value.as_str();
let platform = web::platform::Platform::try_from(platform_str);
let is_macos = platform.map(|p| p.is_macos()).ok() == Some(true);
if is_macos && !ARGS.groups.window.options.frame.value {
MACOS_TRAFFIC_LIGHTS_CONTENT_WIDTH + MACOS_TRAFFIC_LIGHTS_SIDE_OFFSET
} else {
0.0
Expand Down
7 changes: 4 additions & 3 deletions app/gui/view/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub enum SearcherVariant {

impl SearcherVariant {
fn new(app: &Application) -> Self {
if ARGS.enable_new_component_browser {
if ARGS.groups.feature_preview.options.new_component_browser.value {
Self::ComponentBrowser(app.new_view::<component_browser::View>())
} else {
Self::OldNodeSearcher(Rc::new(app.new_view::<searcher::View>()))
Expand Down Expand Up @@ -261,7 +261,8 @@ impl Model {
let code_editor = app.new_view::<code_editor::View>();
let fullscreen_vis = default();
let debug_mode_popup = debug_mode_popup::View::new(app);
let window_control_buttons = ARGS.is_in_cloud.as_some_from(|| {
let runs_in_web = ARGS.groups.startup.options.platform.value == "web";
let window_control_buttons = runs_in_web.as_some_from(|| {
let window_control_buttons = app.new_view::<crate::window_control_buttons::View>();
display_object.add_child(&window_control_buttons);
scene.layers.panel.add(&window_control_buttons);
Expand Down Expand Up @@ -446,7 +447,7 @@ impl Deref for View {
impl View {
/// Constructor.
pub fn new(app: &Application) -> Self {
let theme = match ARGS.theme.as_ref() {
let theme = match ARGS.groups.feature_preview.options.theme.value.as_ref() {
"dark" => Theme::Dark,
_ => Theme::Light,
};
Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/welcome-screen/src/side_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Model {
fn create_new_project_button(projects_list: &web::Element) -> ClickableElement {
let element = web::document.create_element_or_panic("li");
element.set_id(crate::css_id::NEW_PROJECT);
element.set_inner_html(r#"<img src="/assets/new-project.svg" />Create a new project"#);
element.set_inner_html(r#"<img src="/new-project.svg" />Create a new project"#);
projects_list.append_or_warn(&element);
ClickableElement::new(element)
}
Expand All @@ -83,7 +83,7 @@ impl Model {

fn create_project_list_entry(project_name: &str) -> ClickableElement {
let element = web::document.create_element_or_panic("li");
element.set_inner_html(&format!(r#"<img src="assets/project.svg"/> {project_name}"#));
element.set_inner_html(&format!(r#"<img src="project.svg"/> {project_name}"#));
ClickableElement::new(element)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/gui/view/welcome-screen/src/template_cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct CardDefinition {

const CARD_SPREADSHEETS: CardDefinition = CardDefinition {
class: crate::css_class::CARD_SPREADSHEETS,
background_image_url: Some("/assets/spreadsheets.png"),
background_image_url: Some("/spreadsheets.png"),
header: "Combine spreadsheets",
content: "Glue multiple spreadsheets together to analyse all your data at once.",
template: "orders",
Expand Down
4 changes: 2 additions & 2 deletions app/gui/view/welcome-screen/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

.enso-internal-templates-view .enso-internal-card-geo {
flex: 0 0 530px;
background-image: url("/assets/geo.png");
background-image: url("/geo.png");
background-size: 100%;
}

Expand All @@ -131,6 +131,6 @@

.enso-internal-templates-view .enso-internal-card-visualize {
flex: 0 0 820px;
background-image: url("/assets/visualize.png");
background-image: url("/visualize.png");
background-size: 100% 100%;
}
Loading

0 comments on commit 663ed1e

Please sign in to comment.