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

feat: switch template UI #9093

Merged
merged 22 commits into from
Mar 25, 2024
Merged

feat: switch template UI #9093

merged 22 commits into from
Mar 25, 2024

Conversation

nickoferrall
Copy link
Contributor

Fix #9087

Demo: https://www.loom.com/share/758f0aef94a943dc9ec28009125b325c

This PR won't be merged until the functionality is added in a subsequent PR.

I'm using the "Options" button from Standups. One small UI thing is the avatar list gets larger and smaller depending on the screen size whereas "options" remains the same height. As that affects Standups, I'll tackle it in a separate PR.

I created a reusable menu & menu item component in this PR:
Screenshot 2023-11-01 at 18 51 25

To test

  • Create a retro, go to the "Reflect" phase and see "options"
  • Clicking on the "Change template" menu item opens the right drawer with all the templates
  • This doesn't show up in the group phase

@github-actions github-actions bot added the size/m label Nov 1, 2023
@@ -174,6 +174,7 @@ const User: UserResolvers = {
...activity,
sortOrder: getScore(activity, teamIds)
}))
.filter((activity) => !type || activity.type === type)
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 could add type to the dataloader (or create a second dataloader) so that we only get retrospective templates. But as this query is used in the activity library, which will probably be executed for the org before the user gets to the retro drawer, it should be more efficient to keep it as it is and get the templates from the cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we don't need another dataloader, but I don't really understand the rationale. The dataloader cache is only valid for the duration of one query and the corresponding subscription notifications.
Instead if we wouldn't include this type filter and instead do all filtering on the client side, there is the possibility that relay reads it from its cache.

Copy link
Contributor

@igorlesnenko igorlesnenko left a comment

Choose a reason for hiding this comment

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

If we are introducing new radix components here, I would ideally make them similar to our previous radix components:

packages/client/ui/Menu/MenuItem.tsx Outdated Show resolved Hide resolved
Comment on lines 37 to 55
<Menu
trigger={
<OptionsButton>
<IconLabel icon='tune' iconLarge />
<div className='text-slate-700'>Options</div>
</OptionsButton>
}
>
<div ref={originRef} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<MenuItem
value='template'
label='Change template'
onClick={handleClick}
isDisabled={hasReflections}
icon={<SwapHorizIcon />}
/>
</div>
{tooltipPortal('You can only change the template before reflections have been added.')}
</Menu>
Copy link
Contributor

@igorlesnenko igorlesnenko Nov 2, 2023

Choose a reason for hiding this comment

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

+1 I would ideally keep radix structure rather than passing components as props

<Menu>
  <MenuTrigger>
        <OptionsButton>
          <IconLabel icon='tune' iconLarge />
          <div className='text-slate-700'>Options</div>
        </OptionsButton>
  </MenuTrigger>
  <MenuContent>
    <MenuItem>Change template</MenuItem>
  </MenuContent>
</Menu>

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 prefer including trigger as a prop because it's always required, and it means the dev just needs to import Menu & MenuItem. I've removed the icon as a prop though

packages/client/ui/Menu/MenuItem.tsx Outdated Show resolved Hide resolved
packages/client/components/MeetingOptions.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@igorlesnenko igorlesnenko left a comment

Choose a reason for hiding this comment

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

A note for the future: I noticed that I can add reflections while drawer is opened, so theoretically I can click on new template with already existing reflections

packages/client/ui/Menu/Menu.tsx Outdated Show resolved Hide resolved
@igorlesnenko
Copy link
Contributor

We don't need a feature flag here?

@nickoferrall
Copy link
Contributor Author

We don't need a feature flag here?

Nope, I suggested that we don't use a feature flag here and just roll it out to all users. I won't merge this PR until the logic is in place though.

packages/client/ui/Menu/Menu.tsx Outdated Show resolved Hide resolved
@@ -174,6 +174,7 @@ const User: UserResolvers = {
...activity,
sortOrder: getScore(activity, teamIds)
}))
.filter((activity) => !type || activity.type === type)
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that we don't need another dataloader, but I don't really understand the rationale. The dataloader cache is only valid for the duration of one query and the corresponding subscription notifications.
Instead if we wouldn't include this type filter and instead do all filtering on the client side, there is the possibility that relay reads it from its cache.

</TooltipTrigger>
</div>
<TooltipContent>
{'You can only change the template before reflections have been added.'}
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I would rephrase this slightly to "You can only change the template if no reflections have been added." because it also works if you remove them again.

@nickoferrall
Copy link
Contributor Author

@Dschoordsch this PR is relevant for recurring retros. It shouldn't be merged until #9088 is ready as it'd be confusing to have the UI without the functionality.

Would you like to work on this as you're working on recurring retros now?

@nickoferrall nickoferrall merged commit 2171065 into master Mar 25, 2024
5 checks passed
@nickoferrall nickoferrall deleted the feat/9087/switch-template-ui branch March 25, 2024 19:05
@github-actions github-actions bot mentioned this pull request Mar 27, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement switching templates during a retro UI
4 participants