-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
@@ -3,28 +3,23 @@ import { ImmerStateCreator } from '@/utils/typescript' | |||
|
|||
interface State { | |||
rules: TestRule[] | |||
selectedRuleId: string | null |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
{ruleId !== undefined && ( | ||
<TabNavLink | ||
route="rule" | ||
params={{ | ||
path, | ||
ruleId, | ||
}} | ||
label="Rule" | ||
/> | ||
)} |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this 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:
- Change something in generator
- Navigate to another tab
- 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,
}
generator: '/generator/:path/', | ||
rule: '/generator/:path/rule/:ruleId', | ||
loadProfile: '/generator/:path/loadProfile', | ||
thinkTime: '/generator/:path/thinkTime', | ||
testData: '/generator/:path/testData', | ||
} |
There was a problem hiding this comment.
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 🙌
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
No description provided.