Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Add and use application name #3445

Merged
merged 1 commit into from
Nov 16, 2018
Merged

Conversation

paul-marechal
Copy link
Member

@paul-marechal paul-marechal commented Nov 8, 2018

Add customizable application name.
Display application name when no workspace is opened, instead of showing
the URL. It was particulary bad on Electron.

Remove native menus when creating a new Electron BrowserWindow, which will be
re-added by the application when ready.

Signed-off-by: marechal-p paul.marechal@ericsson.com

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 3 times, most recently from 61539c5 to 3ca249d Compare November 8, 2018 20:08
Copy link
Contributor

@elaihau elaihau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, except for that email :)

@vince-fugnitto
Copy link
Member

vince-fugnitto commented Nov 9, 2018

it lworks and looks great @marechal-p, perhaps we can simply display Theia when no workspace is present instead of <No Workspace> - Theia? I know vscode does something similar, namely:

  • Visual Studio Code for no workspaces.
  • ${Workspace Name} - Visual Studio Code when a workspace is present.

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 2 times, most recently from 73f62f3 to 2b85538 Compare November 9, 2018 15:48
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @marechal-p works and looks great!

@akosyakov
Copy link
Member

@kittaakos can you have a look

I feel a bit unsure since it does additional remote calls at runtime to fetch information which actually is available at the build time. Maybe it should be mixed into frontend config to avoid fetching what is already known.

@paul-marechal
Copy link
Member Author

@akosyakov it was my concern, part of why I waited to merge.

Is there a cache of the props already, or should I make one?

@kittaakos
Copy link
Contributor

I feel a bit unsure since it does additional remote calls at runtime to fetch information which actually is available at the build time. Maybe it should be mixed into frontend config to avoid fetching what is already known.

I am OK with both approaches. The build-time solution is faster, no questions at all. But fetching the application name once when setting the workspace also seems OK.

@kittaakos kittaakos self-requested a review November 13, 2018 14:15
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works nicely. @akosyakov, if you prefer having the application name at build time instead of fetching it, please request the change.

@paul-marechal
Copy link
Member Author

TBH I would prefer having the applicationName set at build time too, but while I know how to write something inside the generated sources (modifying the generators), I fail to see a clean way of fetching the value afterward, from any Theia component...

How would you go about it? @akosyakov @kittaakos

@kittaakos
Copy link
Contributor

How would you go about it? @akosyakov @kittaakos

Let's spare @akosyakov for the review ;)

I can take a look but then, let's fuse this PR with #3459. What do you think, @marechal-p?

@paul-marechal
Copy link
Member Author

I'll fuze them now

@kittaakos
Copy link
Contributor

I will create my patch on the generate-app-name-patch branch which is a branch from your mp/startup-window-title.

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch from 2b85538 to 2f315f8 Compare November 13, 2018 15:51
@kittaakos
Copy link
Contributor

@marechal-p, I could not create a PR against your branch (due to the force push) but here is the commit: 9aa985d.

It worked without a problem locally. Let me know if you have questions.

@paul-marechal
Copy link
Member Author

paul-marechal commented Nov 13, 2018

I didn't know about that FrontendApplicationConfigProvider, thank you very much :)

Do you allow me to simply fuze your changes inside this PR?

@kittaakos
Copy link
Contributor

Sure. Use as much as you need.

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 3 times, most recently from 1afd575 to 2f0042e Compare November 13, 2018 18:07
@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 2 times, most recently from 4a33ffd to c884bd9 Compare November 13, 2018 19:58
@paul-marechal
Copy link
Member Author

@kittaakos updated everything accordingly.

  • I used the build time string like advised.
  • I changed the initial setting of the menus to an empty template instead of null because it wasn't working on OSX, it now does.
  • Also fixed menu instantiation under OSX to handle the case where we can only set the whole application menu globally, so I hooked the menu creation to each Electron BrowserWindow on the focus event. Tested on our OSX machine and it seemed to work, if anyone wants to also give it a try.

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 2 times, most recently from 2beefae to f8f0659 Compare November 13, 2018 20:15
@kittaakos
Copy link
Contributor

  • I used the build time string like advised.

👍

  • instead of null because it wasn't working on OSX, it now does.

I am a bit puzzled; your change was already approved twice: #3445 (review) and #3445 (review) and you are saying; it works now. I still do not understand what does this fix.

  • handle the case where we can only set the whole application menu globally

I do not understand this.

  • if anyone wants to also give it a try.

I would like to. What was the original issue?

@paul-marechal
Copy link
Member Author

paul-marechal commented Nov 14, 2018

  • I changed the initial setting of the menus to an empty template instead of null because it wasn't working on OSX, it now does.

I am a bit puzzled; your change was already approved twice: #3445 (review) and #3445 (review) and you are saying; it works now. I still do not understand what does this fix.

Exactly what I said. Despite being approved already, it wasn't working on OSX when I tested after (I remembered we had a OSX machine to test on). So I covered that case. It now works on Ubuntu/Windows/OSX. Now correctly hides the default electron menus until the application sets it up.

  • Also fixed menu instantiation under OSX to handle the case where we can only set the whole application menu globally, so I hooked the menu creation to each Electron BrowserWindow on the focus event. Tested on our OSX machine and it seemed to work, if anyone wants to also give it a try.

Well, again, on Ubuntu/Windows, we can set the menus on a per-window basis. But not on OSX, where the menu bar is unique and global to all windows, and lives at the top of the screen. Problem is, when you have two electron windows opened, and only one menu bar (OSX), in what window should New Terminal open a new terminal in? So my fix sets the "global" OSX menus each time you change windows so that it will target the one you will use, because it is focused.

But I will move that menu change to an other PR, no issues :)

@kittaakos
Copy link
Contributor

Problem is, when you have two electron windows opened, and only one menu bar (OSX), in what window should New Terminal open a new terminal in? So my fix sets the "global" OSX menus each time you change windows so that it will target the one you will use, because it is focused.

Thank you for taking the time and explaining it to me again. It makes sense.

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch 4 times, most recently from 77c11f4 to bf5d47d Compare November 14, 2018 18:19
@paul-marechal
Copy link
Member Author

@kittaakos it should be better now :)

@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch from bf5d47d to ab1f48a Compare November 15, 2018 13:42
@paul-marechal
Copy link
Member Author

Ok, I didn't see the failing tests, still addressing that :(

Add customizable application name.
Display application name when no workspace is opened, instead of showing
the URL. It was particulary bad on Electron.

Remove native menus when creating a new Electron BrowserWindow, which will be
re-added by the application when ready.

Signed-off-by: marechal-p <paul.marechal@ericsson.com>
@paul-marechal paul-marechal force-pushed the mp/startup-window-title branch from ab1f48a to b10a6e5 Compare November 15, 2018 20:40
@paul-marechal
Copy link
Member Author

@kittaakos I know this PR is taking longer than it should to get ready, but there is a last point where I want your opinion:

Currently, the application configuration requires us to define the package.json in the following way:

{
  "theia": {
    "frontend": {
      "config": {
        "applicationName": "Theia Browser Example"
      }
    }
  }
}

Wouldn't it be better to have the application name as a "global", along with the target?

{
  "theia": {
    "applicationName": "Theia Browser Example"
  }
}

It sounds rather specific to have it in the frontend config member. On the other hand, only the frontend could care about that, because it is only in the frontend logic that we would try to display this name. The backend would hardly need such a string, or I'm just failing to find a use case for it.

Other than that I'm happy with how the changes are right now, feel free check if everything is ready to merge :)

@kittaakos
Copy link
Contributor

Wouldn't it be better to have the application name as a "global", along with the target?

I would leave as is.

Other than that I'm happy with how the changes are right now, feel free check if everything is ready to merge :)

It looks great! I'll try it out once more on Windows and merge the changes.

@kittaakos kittaakos merged commit 316c760 into master Nov 16, 2018
@kittaakos kittaakos deleted the mp/startup-window-title branch November 16, 2018 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants