-
-
Notifications
You must be signed in to change notification settings - Fork 826
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
chore: convert Dropdown
components to TS
#3608
Conversation
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
Co-authored-by: David Wheatley <hi@davwheat.dev>
disabled: this.isGroupDisabled(group.id()) && this.isGroupDisabled(Group.MEMBER_ID) && this.isGroupDisabled(Group.GUEST_ID), | ||
const groupButtons = app.store | ||
.all<Group>('groups') | ||
.filter((group) => ![Group.ADMINISTRATOR_ID, Group.GUEST_ID, Group.MEMBER_ID].includes(group.id()!)) |
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.
Can we break this array out into a constant? Also, is it just me, or did we have a groups selector component at one point?
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 component itself is the selector you're referring to I believe. It doesn't just list groups though, but different times of items depending on the permission.
|
||
getButtonContent(children: Mithril.ChildArray): Mithril.ChildArray { | ||
const activeChild = children.find(isActive); | ||
let label = (activeChild && typeof activeChild === 'object' && 'children' in activeChild && activeChild.children) || this.attrs.defaultLabel; |
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.
We should really consider investing in a util file full of these guards/
// these attrs to a new button, so that it has exactly the same behaviour as | ||
// the first child. | ||
const firstChild = this.getFirstChild(children); | ||
const buttonAttrs = Object.assign({}, firstChild?.attrs); |
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.
const buttonAttrs = Object.assign({}, firstChild?.attrs); | |
const buttonAttrs = Object.assign({}, firstChild?.attrs ?? {}); |
Is this necessary?
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.
Why not
{ ...firstChild?.attrs ?? {} }
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 don't think this is necessary, the getFirstChild
method is typed to explicitly return a Vnode
. if somehow it returns a non Vnode
then it should probably be fixed at that level?
@@ -126,7 +126,7 @@ export default class ForumApplication extends Application { | |||
// Route the home link back home when clicked. We do not want it to register | |||
// if the user is opening it in a new tab, however. | |||
document.getElementById('home-link')!.addEventListener('click', (e) => { | |||
if (e.ctrlKey || e.metaKey || e.which === 2) return; | |||
if (e.ctrlKey || e.metaKey || e.button === 1) return; |
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.
Let's add a comment explaining this one
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.
are you referring to the conditional statement or just the e.button
part?
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 this is quite self-explanatory?
The comment above explains everything this line does.
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
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.
Approved, tentative on #3608 (comment)
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
These changes seem to have broken implementations like |
Changes proposed in this pull request:
Converts the Dropdown component and its descendants to TS.
Necessity
Confirmed
composer test
).