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

Multiple custom layouts for tracing views #3299

Merged
merged 33 commits into from
Oct 10, 2018

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Oct 2, 2018

This PR addes the possibility to add muliple layouts.

URL of deployed dev instance (used for testing):

Steps to test:

  • open a tracing
  • create a new layout (should have the previous layout set as initial layout)
  • change freely between the layouts
  • try deleting a non-active layout
  • an active layout should not be removable -> thus guaranteeing to always have a layout
  • the last active layout at closing a tracing, should be the initial layout on next startup
  • important -> try this in all four kinds of tracing views as their layout is treated separately
  • test the migration into the new "layout saving schema"

Issues:


@MichaelBuessemeyer
Copy link
Contributor Author

@philippotto shall we / I add a short "feature explanation" to the documentation? Right now I can't find anything about the custom viewports / layout feature.

@philippotto philippotto changed the title Mulitple custom layouts for tacing views Multiple custom layouts for tacing views Oct 2, 2018
Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

Wow! 👍 Awesome work! I just tested it and it seems to work pretty well. I left some review comments for the code and I also have some remarks for the UI:

  • the icons to delete a layout should be aligned to the far right in my opinion
  • can we add a way to edit the name of an existing layout?
  • we should make it more clear that we store different layouts for the different UI setups. One way would be to add an information icon which has some explanation text. Another idea would be to list all layouts in a categorized way, but disable the ones which can not be used.
    E.g.:

---- Orthogonal Mode ----
Default Layout
Layout 1
Layout 2
---- Arbitrary Mode ------
Default Layout
Layout 1

(cursive is disabled).

What do you think? Maybe you can brainstorm a bit, too, so that we can discuss afterwards with which solution we want to go?

@@ -103,17 +106,16 @@ export class GoldenLayoutAdapter extends React.PureComponent<Props<*>, *> {
}

onStateChange() {
console.log("changing gl state");
Copy link
Member

Choose a reason for hiding this comment

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

This log can probably be removed.


export function setActiveLayout(layoutKey: LayoutKeys, activeLayout: string) {
const newLayouts = getDeepCopyOfStoredLayouts();
if (newLayouts[layoutKey] && newLayouts[layoutKey][activeLayout]) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we throw an error if this if-check fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like an error toast that says e.g. "The selected layout was not found. Please add a layout for the selected name."?

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of a simple js throw via throw new Error("Active layout could not be set ..."). This case should never occur, right? If there is no plausible way for the user, to hit this case, we do not need to add code here for a user-facing error message (so, no toast). But if the if-check shouldn't pass for some reason (e.g., future changes break something), then it would be very helpful to see an error in the console, when debugging this. That's why, you should usually just throw an error in these cases, since the error would be silently swallowed otherwise.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "webknossos",
"version": "0.17.146",
"version": "1.10.1",
Copy link
Member

Choose a reason for hiding this comment

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

I think this change was added when you executed yarn version. Can you undo this?

if (version !== 5) {
return defaultLayoutSchema;
}
// migrate to newst schema
Copy link
Member

Choose a reason for hiding this comment

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

newEst

},
OrthoLayout: {
"Custom Layout": layouts.OrthoLayout || defaultLayouts.OrthoLayout,
lastActive: "Custom Layout",
Copy link
Member

Choose a reason for hiding this comment

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

This lastActive attribute has some disadvantages in my opinion. Two example symptoms are that a layout must not be named "lastActive" and that "lastActive" has to be ignored when listing layout names. In general, the problem is that OrthoLayout (and co) contain a map from layout name to layout config AND the information what is active. These are two different things which can be stored independently.
For example, you could have:

...
OrthoLayout: {...},
LastActiveLayouts: {
  OrthoLayout: "Custom Layout",
  ArbitraryLayout: "Layout X",
}

as a format. Do you agree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure it was obvious to me that my solution is not so good. I like your idea way more than mine and it makes the code even better 😃

<React.Fragment>
<h5 style={{ color: "#fff" }}>Where is my layout?</h5>
<p>
{`The tracing views are seperated into four classes. Each of them has their own layouts. If you
Copy link
Member

Choose a reason for hiding this comment

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

separated

OrthoLayoutView: "Othogonal Tracings - View Only",
VolumeTracingView: "Volume Tracings",
ArbitraryLayout: "Arbitray View Mode",
OrthoLayout: "Othogonal Tracings",
Copy link
Member

Choose a reason for hiding this comment

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

oRthogonal (same in line 110)

Copy link
Member

Choose a reason for hiding this comment

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

Can you rename "Tracings" to "Mode" in these labels?

@daniel-wer daniel-wer changed the title Multiple custom layouts for tacing views Multiple custom layouts for tracing views Oct 8, 2018
@philippotto
Copy link
Member

Nice, nice, nice :) I made another comment ("Tracing" vs "Mode") and I also have another request: Can we remove the bullet points in front of the custom layout names? I think it would look better without the bullets.

@MichaelBuessemeyer
Copy link
Contributor Author

MichaelBuessemeyer commented Oct 9, 2018

@philippotto could you please have a look at this PR again? I applied the feedback, but the frontend test didn't run correctly the first time on CircleCI. But without changing a thing the second try worked out. I don't know why 🤔

@philippotto
Copy link
Member

@philippotto could you please have a look at this PR again? I applied the feedback, but the frontend test did run correctly the first time on CircleCI. But without changing a thing the second try worked out. I don't know why thinking

So, both runs worked out? :)

The PR looks really good. I also just tested the conversion between the persisted layouts and it seems to work pretty well.

What's a bit weird is that I can sometimes delete the last layout (so that the list is empty) and sometimes I can't delete it. But I think that's not a blocker. Feel free to merge!

@philippotto
Copy link
Member

Please wait with merging until tomorrow, as the lab is conducting live tests at the moment.

@MichaelBuessemeyer
Copy link
Contributor Author

but the frontend test did run correctly the first time on CircleCI.

meant: "but the frontend test didn't run correctly the first time on CircleCI." 🙂

@MichaelBuessemeyer MichaelBuessemeyer merged commit 3c762e9 into master Oct 10, 2018
@philippotto philippotto deleted the mulitple-tracing-custom-layouts branch January 24, 2019 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-defined and/or customizable layout presets
2 participants