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 tabs & lint #1303

Merged
merged 3 commits into from
Aug 21, 2020
Merged

Fix tabs & lint #1303

merged 3 commits into from
Aug 21, 2020

Conversation

skjnldsv
Copy link
Contributor

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)

@skjnldsv skjnldsv added bug Something isn't working 3. to review Waiting for reviews high High priority feature: app-sidebar Related to the app-sidebar component labels Aug 18, 2020
@skjnldsv skjnldsv self-assigned this Aug 18, 2020
@raimund-schluessler
Copy link
Contributor

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.

I don't get it. A <random-component name="Tab" id="tab1" icon="tab-icon" /> would also be considered a valid AppSidebarTab, although it doesn't implement the tab logic https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/AppSidebarTab/AppSidebarTab.vue#L60-L64 and would never be visible. How is this desired?

@raimund-schluessler
Copy link
Contributor

Also, could you please clean up the history? I think a dependency update commit somehow got into it.

@skjnldsv
Copy link
Contributor Author

skjnldsv commented Aug 18, 2020

I don't get it. A <random-component name="Tab" id="tab1" icon="tab-icon" /> would also be considered a valid AppSidebarTab, although it doesn't implement the tab logic https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/AppSidebarTab/AppSidebarTab.vue#L60-L64 and would never be visible. How is this desired?

isActive is only here for the Tab, it's not mandatory. It's a helper. It could be removed tbh.
And yes, randomComponent is fine to have.

@skjnldsv
Copy link
Contributor Author

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)

@raimund-schluessler
Copy link
Contributor

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 src/mixins/userStatus.js. Might have been better to fix that separetly 🙈

@skjnldsv
Copy link
Contributor Author

Ah, ok. But now that the lint works again, it shows an error in src/mixins/userStatus.js. Might have been better to fix that separetly

Fixed in #1304 already ;)

@raimund-schluessler
Copy link
Contributor

isActive is only here for the Tab, it's not mandatory. It's a helper. It could be removed tbh.
And yes, randomComponent is fine to have.

But as far as I understood it, its only fine if there is no AppSidebarTab as mixing tabs and non-tabs is not possible. Could you please point me to the code in server where this fails? I think I don't understand the problem yet.

@skjnldsv
Copy link
Contributor Author

skjnldsv commented Aug 18, 2020

But as far as I understood it, its only fine if there is no AppSidebarTab as mixing tabs and non-tabs is not possible. Could you please point me to the code in server where this fails? I think I don't understand the problem yet.

https://github.com/nextcloud/server/blob/4485cb30a1bd4b86492203b20c43e0c8fdd47f71/apps/files_sharing/src/views/SharingTab.vue
We need to implement our own logic before the tab. Meaning the Tab is not the direct children but the SharingTab is :)

(This is because of the API implementation)

image

@raimund-schluessler
Copy link
Contributor

We need to implement our own logic before the tab. Meaning the Tab is not the direct children but the SharingTab is :)

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.

@skjnldsv
Copy link
Contributor Author

I see. But then you should get rid of this warning #1303 (files) completely, because it has no sense if it isn't enforced.

I don't even remember why it's here to be honest

@raimund-schluessler
Copy link
Contributor

We need to implement our own logic before the tab. Meaning the Tab is not the direct children but the SharingTab is :)

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.

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.

@skjnldsv
Copy link
Contributor Author

skjnldsv commented Aug 18, 2020

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.
so you can put anything without a Tab if you don't provide more than one children. That why that was here.

It's either multiple tabs and you have to use Tabs or one component and you CANNOT use tabs.

@raimund-schluessler
Copy link
Contributor

I don't even remember why it's here to be honest

😆 I don't know either. I just saw that it falsely complains and tried to fix it in #1281

@raimund-schluessler
Copy link
Contributor

raimund-schluessler commented Aug 18, 2020

No it's not, it's because we allowed devs to provide anything they want if it's only one tab.
so you can put anything without a Tab if you don't provide more than one children. That why that was here.

It's either multiple tabs and you have to use Tabs or one component and you CANNOT use tabs.

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).

@raimund-schluessler
Copy link
Contributor

I am fine with either, but please adjust the tests, so it is clear what the wanted behavior actually is.

@raimund-schluessler
Copy link
Contributor

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 🙈

@skjnldsv
Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if you want this, but the Netlify example now prints a lot of these warning, since this.$slots.default contains entries only consisting of whitespace:

Untitled

Copy link
Contributor

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())

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this for the empty content example (with no tabs and only a single node):

debug

Copy link
Contributor

@raimund-schluessler raimund-schluessler left a 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.

@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Aug 18, 2020
Copy link
Contributor

@raimund-schluessler raimund-schluessler left a 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).

&& 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()) {
Copy link
Contributor Author

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?

Copy link
Contributor

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.

@skjnldsv skjnldsv added 2. developing Work in progress 3. to review Waiting for reviews and removed 3. to review Waiting for reviews 2. developing Work in progress labels Aug 20, 2020
@skjnldsv
Copy link
Contributor Author

Please rebase :)

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
@raimund-schluessler
Copy link
Contributor

@skjnldsv Rebased, but #1303 (comment) needs to be fixed still.

Copy link
Contributor

@georgehrke georgehrke left a comment

Choose a reason for hiding this comment

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

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
@raimund-schluessler
Copy link
Contributor

@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).

@skjnldsv skjnldsv merged commit 7b68f89 into master Aug 21, 2020
@skjnldsv skjnldsv deleted the fix/tabs branch August 21, 2020 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug Something isn't working feature: app-sidebar Related to the app-sidebar component high High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants