-
Notifications
You must be signed in to change notification settings - Fork 95
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
adds a collapsible "create new app" section #163
base: master
Are you sure you want to change the base?
Conversation
should run now pretty. |
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.
Thanks for the PR. Generally, I am aligned with the intention, but implementation needs to be reconsidered.
src/containers/apps/Apps.tsx
Outdated
hasPersistency | ||
) | ||
<details id="create-new-app"> | ||
<summary style={{display: 'none'}}></summary> |
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.
Look into hide-on-deman
usage in the code.
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.
what is the meaning of the "-on-demand" part?
Note: i hide the summary element, as the button to open the details element needs to be somewhere else.
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.
Yes, you can just create a div element and use hide-on-demand class to hide it and show it when it needs to. There are many examples of that in the code.
src/containers/apps/AppsTable.tsx
Outdated
}} | ||
> | ||
<Button | ||
onClick={() => document.getElementById('create-new-app')?.toggleAttribute('open')} |
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.
This is an antipattern in react. You must use callbacks and redux if needed.
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 tried to implement the minimalistic change here and relied on basic html5 feature. Since there is no state-tracking possibility of the "open" state of the element, the only other approach would be to use useRef.
Since Apps.tsx and AppsTable.tsx are separated i don't have the exact overview of your hierarchy, so i found that this is the simplest approach. Also, it is just frontend only.
But feel free to adjust it if you are not happy with my approach here.
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.
Typically, you should just use a call back if it's the parent, or use redux. Modifying DOM elements are not recommended approach when using react.js.
If you want you can leave the pr as is. I'll make the change later.
<Button | ||
onClick={() => document.getElementById('create-new-app')?.toggleAttribute('open')} | ||
type="primary" | ||
> |
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.
The button needs to hide when the create app panel is visible.
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.
Also create app panel needs to have a close button that result in this button being visible again.
fixes caprover/caprover#2171
This is just a small ui adjustment and should not break anything. It uses standard html
<dialog>
functionality.Screenshots of this change is in the linked issue