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

REF: button bar rework - template switch menu + Jira reporting button #572

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

klauer
Copy link
Contributor

@klauer klauer commented Aug 28, 2023

Description

  • Make template switch menu a bit more intuitive by listing classes and their corresponding displays to choose
  • Add a "Jira report button" to the top level
  • Remove buttons for swapping directly to different template types

Motivation and Context

How Has This Been Tested?

  • Interactively
  • Jira reporting still works

Where Has This Been Documented?

PR text

Screenshots (if appropriate):

The new toolbar:
image
! being "create jira report":
image -> image
... shows all templates from all categories:
image

@klauer
Copy link
Contributor Author

klauer commented Aug 28, 2023

Alternatively, a bit more drastic of a change:
image

I'd kinda like to get rid of the buttons that were once described as "too scary to click on" in user feedback

@ZLLentz
Copy link
Member

ZLLentz commented Aug 29, 2023

I think the fewer-buttons look is pretty nice fwiw

@klauer klauer marked this pull request as ready for review August 31, 2023 01:08
@tangkong
Copy link
Contributor

I think this looks pretty great, much simpler. One thought I had was maybe we could let the user know which template they're using. I'm not sure how easy that would be (as in I don't know how I'd implement it off hand), but I'm envisioning something like this:
image

Otherwise the user might one without knowing how to get back to the template they were using

@tangkong
Copy link
Contributor

tangkong commented Aug 31, 2023

A sort-of minimal implementation of my suggestion. We should of course set the stylesheet outside this callback but the idea remains:

def add_template(filename: pathlib.Path) -> None:
    def switch_template(*, filename: pathlib.Path = filename):
        self.force_template = filename

     action = base_menu.addAction(str(filename))
     action.triggered.connect(switch_template)
     if self.current_template == filename:
         base_menu.setDefaultAction(action)
     base_menu.setStyleSheet("QMenu::item:default { color: #ff0000; }")
     actions.append(action)

Kudos to @tangkong for the suggestion + implementation
@klauer
Copy link
Contributor Author

klauer commented Aug 31, 2023

Great suggestion @tangkong - pushed a commit with this:
image

(Styling may need some work)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thoughts about this ordering of template types + instead?
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's nice! It helps make the template organization/hierarchy a little more obvious.

Leads me to wonder if people would ever want the base templates. I'm sure there's a world where we do, but for now people probably don't care huh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there probably is little reason to display those - though maybe better to display more options than less just in case? The menu should look less cluttered for a non-development checkout version, but not much better admittedly.

Another thought is that this menu could also have nested submenus. I'm fond of seeing all the choices in a big list personally. That said, base/"advanced" ones still could be in an "Other screens" menu, maybe...

Copy link
Member

Choose a reason for hiding this comment

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

Quick note: the most up-to-date version of this looks even better with the shared prefixes cleaned up
I'm curious how this will end up looking for dev_conda

Copy link
Contributor

@tangkong tangkong left a comment

Choose a reason for hiding this comment

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

I think this looks good, we could quibble about the exact format of template menu but I think it's a clear improvement in its current state

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

Nothing to suggest about the code- just two unnecessary observations to distract you.

I'll run with the branch and take a look at it now

self.embedded_screen: "Embedded",
self.detailed_screen: "Detailed",
self.engineering_screen: "Engineering",
}[self]
Copy link
Member

Choose a reason for hiding this comment

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

It's wild to me that this works, the code reads pretty confusingly if you forget that this is an IntEnum (as I did, on initial review).

I don't think many other classes would be able to look themselves up in a dictionary of their own attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've used this pattern before with enums and kinda liked it - but if you think it's confusing it's worth redoing honestly as "clever code" is not good code

Copy link
Member

Choose a reason for hiding this comment

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

I don't necessarily think it's worth changes- the only reason I was confused is because:

  • The diff cut off at a point where I didn't see "IntEnum"
  • I briefly forgot that IntEnum can be used as an int

for template in DEFAULT_TEMPLATES_FLATTEN:
add_template(template)

prefix = os.path.commonprefix(
Copy link
Member

Choose a reason for hiding this comment

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

Why is this widely useful utility function hiding in the os.path module? Python weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't agree more...

Copy link
Member

Choose a reason for hiding this comment

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

Maybe unrelated to this PR and more as a consequence of #563: there's some edge cases now where you can accidentally pick a template that doesn't itself contain a button title bar, and there's no way to go back. Not sure how to handle this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good one... maybe the suite needs to be smarter and insert a title bar if it doesn't exist in the newly-created display?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, either a smart title bar or some alternate way to switch templates- right clicking?
Or, prevent us from swapping to the "dead end" templates I guess (somehow)

Copy link
Member

@ZLLentz ZLLentz left a comment

Choose a reason for hiding this comment

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

I'm 👍 on all the changes introduced here

@klauer klauer merged commit 811cd87 into pcdshub:master Sep 8, 2023
7 of 9 checks passed
@klauer klauer deleted the ref_template_switch_menu branch September 8, 2023 16:18
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.

Typhos Jira report widget unused for over 2 years Disambiguate duplicate template filenames
3 participants