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

Add Not subscribe tab in channels settings. #30021

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sujalshah-bit
Copy link
Collaborator

@sujalshah-bit sujalshah-bit commented May 8, 2024

PR summary:

  • Add a Not Subscribed tab to the channels settings that will contain all the channels the user is not subscribed to.
  • Display the text No Channels to show. View all channels. when no channels is available to show.
  • Changes the redirect links for Browse channel and Browse 1 more channels to the Not subscribed tab.
  • Hide the Not subscribed tab if the user is a guest user.
  • Add a tooltip for for the disabled tabs for guests. ( Originally posted by @alya in stream_settings: Add not-subscribed tab to stream settings. #26049 (comment) )

Fixes: #21869

Continuing the works of: #26049


not-subscribed.mp4

tooltip
image
Empty view
image

Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@zulipbot
Copy link
Member

zulipbot commented May 8, 2024

Hello @zulip/server-streams members, this pull request was labeled with the "area: stream settings" label, so you may want to check it out!

@sujalshah-bit sujalshah-bit changed the title Not subscribe tab Add Not subscribe tab in channels settings May 8, 2024
@sujalshah-bit sujalshah-bit changed the title Add Not subscribe tab in channels settings Add Not subscribe tab in channels settings May 8, 2024
@sujalshah-bit sujalshah-bit changed the title Add Not subscribe tab in channels settings Add Not subscribe tab in **channels settings**. May 8, 2024
@sujalshah-bit sujalshah-bit changed the title Add Not subscribe tab in **channels settings**. Add Not subscribe tab in channels settings. May 8, 2024
@alya
Copy link
Contributor

alya commented May 8, 2024

Thanks! The tooltip should refer to "channels", not "streams" now.

@sujalshah-bit
Copy link
Collaborator Author

@alya made the changes :)

@timabbott
Copy link
Sponsor Member

@sahil839 can you review this one?

Copy link
Collaborator

@sahil839 sahil839 left a comment

Choose a reason for hiding this comment

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

Posted few comments.

Also, the "Fixes .." line in commit message should be in the last commit which completes all the points mentioned in the issue. In the previous commit, you can write "Fixes part of ..".

}
case "not-subscribed": {
browser_history.update("#channels/notsubscribed");

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these extra lines before break can be removed.

@@ -744,6 +757,11 @@ export function change_state(section, left_side_tab, right_side_tab) {
return;
}

if (section === "notsubscribed") {
toggler.goto("not-subscribed");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this not call empty_right_panel?


export function is_subscribed_stream_tab_active() {
// Returns true if "Subscribed" tab in stream settings is open
// otherwise false.
return show_subscribed;
}

export function is_not_subscribed_stream_tab_active() {
// Returns true if "Subscribed" tab in stream settings is open
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is incorrect.

case "all-streams": {
stream_ui_updates.set_show_subscribed(false);
stream_ui_updates.set_show_not_subscribed(false);

Copy link
Collaborator

Choose a reason for hiding this comment

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

These empty lines can also be removed.

web/src/hash_util.ts Show resolved Hide resolved
@@ -508,6 +513,7 @@ export function get_left_panel_params() {
const params = {
input,
show_subscribed: stream_ui_updates.show_subscribed,
show_not_subscribed: stream_ui_updates.show_not_subscribed,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can just store the selected name in a single variable instead of using two boolean variables, but I am not sure.

Let us keep it as it is for now and wait for further feedback.

(is_subscribed_stream_tab_active() && sub.subscribed) ||
(is_not_subscribed_stream_tab_active() && !sub.subscribed)
) {
$row.removeClass("notdisplayed");
} else if (sub.invite_only || current_user.is_guest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This becomes confusing as we show the non-subscribed stream in the tab even when the stream is private, but then the stream is hidden ultimately as the client will receive the "remove" event. So, the behavior is fine but we can probably improve the code to avoid any future bugs.

Not sure what would be the best way to handle this, but just mentioning it here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently we have same behavior if private stream is unsubscribed it is shown in the all streams tab.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is shown for admins only and not non-admins.

Just to be clear, the behavior in the PR is correct, I am just not sure whether we should remove the stream here only or we should wait for "remove" event.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should I ask it on CZO ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can wait for a review by Tim first.

@sujalshah-bit
Copy link
Collaborator Author

@sahil839 made the changes according to your feedbacks kindly review :)

Copy link
Collaborator

@sahil839 sahil839 left a comment

Choose a reason for hiding this comment

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

Posted one comment. Also, please update the commit message to include "Fixes .." line.

<i class="fa fa-plus-circle" aria-hidden="true"></i>
{{~t "Browse {can_subscribe_stream_count} more channels" ~}}
{{~t "Browse {can_subscribe_stream_count} mores channels" ~}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a typo.

(is_subscribed_stream_tab_active() && sub.subscribed) ||
(is_not_subscribed_stream_tab_active() && !sub.subscribed)
) {
$row.removeClass("notdisplayed");
} else if (sub.invite_only || current_user.is_guest) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is shown for admins only and not non-admins.

Just to be clear, the behavior in the PR is correct, I am just not sure whether we should remove the stream here only or we should wait for "remove" event.

This commit changes the variable and function name from
"subscribed_only" to "show_subscribed" and
"set_subscribed_only" to "set_show_subscribed"
so that in the next commit, when the "not subscribed" tab is added,
we can use a similar variable named "show_unsubscribed" and function
named "set_show_unsubscribed".
This commit adds a new tab to the stream settings overlay called
"Not subscribed" which lists all the streams the user is not
subscribed to. This tab is disabled if the user is a guest.

Introduced a new variable called "show_not_subscribed" to replicate
a similar model to how the subscribed tab is working. Currently,
there are only two tabs: "subscribed" and "all streams" so we can
use an if-else condition.

Refactored the 'update_stream_row_in_settings_tab' function inside
stream_ui_updates.js to include the case of a 'Not-subscribed' tab,
so that the tab is immediately updated in any add/remove subscription
event.

Fixed and added the node tests for these changes.
In the "not-subscribed" tab, when there are no channels to show, we
display a text message saying "No channels to show. View all channels"
along with a link that redirects the user to the "All channels" tab
(All channels(#channels/all)).

Updated the update_empty_left_panel_message function in
stream_settings_ui.js to modify and determine which banner to display
when no channels are available to show, modified that function to also
display the banner of the "not-subscribed" tab using a new classname
called 'not_subscribed_streams_tab_empty_text'.
This commit changes the redirect links for "Browse channels" and
"Browse 1 more stream" to the Not subscribed(#streams/notsubscribed)
tab.
Render tooltips for both the tabs if the user is guest user.

Fixes zulip#21869.
@sujalshah-bit
Copy link
Collaborator Author

@sahil839 made the changes. kindly review :)

@sahil839
Copy link
Collaborator

sahil839 commented May 23, 2024

Looks good to me. @timabbott ready for your review. There are a couple of things - here and here, that I am not sure and need feeback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an "Unsubscribed" streams tab
5 participants