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

fix: Improve rule selection #81

Merged
merged 2 commits into from
Aug 6, 2024
Merged

fix: Improve rule selection #81

merged 2 commits into from
Aug 6, 2024

Conversation

going-confetti
Copy link
Collaborator

No description provided.

@@ -3,28 +3,23 @@ import { ImmerStateCreator } from '@/utils/typescript'

interface State {
rules: TestRule[]
selectedRuleId: string | null
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removing this as currently we have two sources of truth for the selected rule: the store prop and the route param. Keeping selectedRuleId in the store also means we need to remember to reset it when a new file is opened


import { useGeneratorStore } from '@/store/generator'
import { TestRule } from '@/types/rules'
import { createEmptyRule } from '@/utils/rules'
import { useGeneratorParams } from './Generator.hooks'

export function NewRuleMenu() {
Copy link
Collaborator Author

@going-confetti going-confetti Aug 2, 2024

Choose a reason for hiding this comment

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

image

Copy link
Member

Choose a reason for hiding this comment

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

🤩

gap="1"
css={css`
background-color: var(--color-background);
z-index: 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's currently a z-index issue in main that's only visible when you scroll the list of rules

@going-confetti going-confetti marked this pull request as draft August 2, 2024 15:31
Comment on lines +14 to 23
{ruleId !== undefined && (
<TabNavLink
route="rule"
params={{
path,
ruleId,
}}
label="Rule"
/>
)}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When you navigate to any tab from the rule editor, the rule selection gets reset. This feels weird - since for now we're not moving the editor to the main area, I'll need to find a solution for this on Monday. I have some ideas 🤔

Copy link
Collaborator

@e-fisher e-fisher 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 it's fine that rule editor tab closes when switching tabs - but maybe a warning about unsaved changes would be useful here? This goes not only for rules, but options and other generator changes. How I imagine it:

  1. Change something in generator
  2. Navigate to another tab
  3. See a dialog: Save changes? [Save] [Discard]

If we decided to keep the rule form open upon navigation we'd probably need to move it to store and have a selected rule per every generator, e.g.:

  Record<GenetorFileName, RuleId>

  selectedRuleMap: {
    '2024-08-05T08/21/04.327Z': 1,
    '2024-08-05T08/21/02.327Z': 5,
  }

Comment on lines +17 to +22
generator: '/generator/:path/',
rule: '/generator/:path/rule/:ruleId',
loadProfile: '/generator/:path/loadProfile',
thinkTime: '/generator/:path/thinkTime',
testData: '/generator/:path/testData',
}
Copy link
Member

Choose a reason for hiding this comment

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

I love how neat this looks 🙌

@going-confetti going-confetti marked this pull request as ready for review August 5, 2024 11:45
@going-confetti
Copy link
Collaborator Author

going-confetti commented Aug 5, 2024

I think it's fine that rule editor tab closes when switching tabs - but maybe a warning about unsaved changes would be useful here? This goes not only for rules, but options and other generator changes.

Currently, any change is done to the respective store object/property, so changes are "saved" when navigating to other tabs (you still need to save the updated generator to disk though). I see lots of pros/cons in forcing the user to commit changes - let's discuss it with the WG tomorrow maybe?

Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

LGTM! 🙌

Copy link
Collaborator

@e-fisher e-fisher left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@going-confetti going-confetti merged commit 217c07e into main Aug 6, 2024
1 check passed
@going-confetti going-confetti deleted the fix/rule-selection branch August 6, 2024 08:08
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.

3 participants