-
Notifications
You must be signed in to change notification settings - Fork 93
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 tabs & lint #1303
Fix tabs & lint #1303
Conversation
I don't get it. A |
Also, could you please clean up the history? I think a dependency update commit somehow got into it. |
|
Nope, I included it because there was a conflict in the deps and was preventing the lint to fully works properly. Now it's working and also fixes some lint issues in the AppSidebars components (minor) |
Ah, ok. 👍 But now that the lint works again, it shows an error in |
Fixed in #1304 already ;) |
But as far as I understood it, its only fine if there is no |
https://github.com/nextcloud/server/blob/4485cb30a1bd4b86492203b20c43e0c8fdd47f71/apps/files_sharing/src/views/SharingTab.vue (This is because of the API implementation) |
I see. But then you should get rid of this warning https://github.com/nextcloud/nextcloud-vue/pull/1303/files#diff-9d00c73ea5b493b4a9fa09a15ee85430R235 completely, because it has no sense if it isn't enforced. |
I don't even remember why it's here to be honest |
Or at least change the string, as the warning is not about mixing tabs and non-tabs, but that a component doesn't have the wanted properties. |
No it's not, it's because we allowed devs to provide anything they want if it's only one tab. It's either multiple tabs and you have to use Tabs or one component and you CANNOT use tabs. |
😆 I don't know either. I just saw that it falsely complains and tried to fix it in #1281 |
Exactly. But wrapping Tabs into another component cancels this check. You cannot distinguish anymore between using multiple tabs or not, because basically anything can be a tab now (as long as it has name, id and icon). |
I am fine with either, but please adjust the tests, so it is clear what the wanted behavior actually is. |
And hey, calling #1281 "Bugged" in the release notes is not fair 😀 It did exactly what I thought was the wanted behavior 😉 Sorry for breaking the server ShareTabs stuff 🙈 |
Well, we do need to warn devs of unwanted behaviours :p |
&& IsValidString(tab?.id) | ||
&& IsValidString(tab?.icon)) { | ||
tabs.push(tab) | ||
} else { | ||
console.debug('Ignoring invalid tab', tabNode) |
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.
Could be fixed by checking if the entry has a tag or non-whitespace text, similar to https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/AppSidebarTabs/AppSidebarTabs.vue#L230:
this.$slots.default.filter(elem => elem.tag || elem.text.trim())
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.
It only warns not when the node contains more than only whitespace.
However, it still prints a debug message on the console when you correctly provide a single node and no tabs. But since it is only a debug message it might be ok (although I would prefer to not have this output).
@skjnldsv What do you think?
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.
Found another issue, needs to be fixed.
a126f6e
to
8114700
Compare
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.
Good to be merged now, with a minor nitpick. See #1303 (comment).
8114700
to
414bb0d
Compare
&& IsValidString(tab?.id) | ||
&& IsValidString(tab?.icon)) { | ||
tabs.push(tab) | ||
} else { | ||
// Don't warn if the node only contains whitespace | ||
if (tabNode.tag || tabNode.text.trim()) { |
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.
Maybe we could warn if the $slots.default count is greater than 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.
But only after we filtered the default slots for nodes with only whitespace. Maybe we should just push the invalid nodes to a separate array and output it if we found tabs. I will try to write a test function for this in the evening.
Please rebase :) |
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
414bb0d
to
0e76134
Compare
@skjnldsv Rebased, but #1303 (comment) needs to be fixed still. |
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.
Tested and works
Looks good except for @raimund-schluessler's remark: https://github.com/nextcloud/nextcloud-vue/pull/1303/files#r473747513
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
@skjnldsv I adjusted the tests to check for the console output and adjusted the code to only warn for invalid tabs if there are also valid tabs (mixing tabs and non-tabs content). |
After #1281
We cannot check for the VNode tag name as we can wrap the Tab and it should be ok.
Otherwise the files app Sidebar doesn't work
That way you can actually provide any tab as long as they're providing the necessary data.
Next step: build it with a render function, would be much cleaner (as we're now have the tabs split from the Sidebar component)