Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
popovers: Add tabs for profile, groups and streams in user_info modal.
m-e-l-u-h-a-nb08041796049
diff --git a/static/js/popovers.js b/static/js/popovers.jsindex 320a4a084e9..2c28a5d08cb 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -11,12 +11,15 @@ import render_playground_links_popover_content from "../templates/playground_linimport render_remind_me_popover_content from "../templates/remind_me_popover_content.hbs";import render_user_group_info_popover from "../templates/user_group_info_popover.hbs";import render_user_group_info_popover_content from "../templates/user_group_info_popover_content.hbs";+import render_user_group_list_item from "../templates/user_group_list_item.hbs";import render_user_info_popover_content from "../templates/user_info_popover_content.hbs";import render_user_info_popover_title from "../templates/user_info_popover_title.hbs";import render_user_profile_modal from "../templates/user_profile_modal.hbs";+import render_user_stream_list_item from "../templates/user_stream_list_item.hbs";import * as blueslip from "./blueslip";import * as buddy_data from "./buddy_data";+import * as components from "./components";import * as compose_actions from "./compose_actions";import * as compose_state from "./compose_state";import * as compose_ui from "./compose_ui";@@ -26,6 +29,7 @@ import * as feature_flags from "./feature_flags";import * as giphy from "./giphy";import * as hash_util from "./hash_util";import {$t} from "./i18n";+import * as ListWidget from "./list_widget";import * as message_edit from "./message_edit";import * as message_edit_history from "./message_edit_history";import * as message_lists from "./message_lists";@@ -44,6 +48,7 @@ import * as rows from "./rows";import * as settings_account from "./settings_account";import * as settings_data from "./settings_data";import * as settings_profile_fields from "./settings_profile_fields";+import * as stream_data from "./stream_data";import * as stream_popover from "./stream_popover";import * as user_groups from "./user_groups";import * as user_status from "./user_status";@@ -372,6 +377,54 @@ export function hide_user_profile() {overlays.close_modal("#user-profile-modal");}+function compare_by_name(a, b) {+ return a.name.localeCompare(b.name);+}++function format_user_stream_list_item(stream) {+ return render_user_stream_list_item({+ name: stream.name,+ stream_id: stream.stream_id,+ stream_color: stream.color,+ invite_only: stream.invite_only,+ is_web_public: stream.is_web_public,+ stream_edit_url: hash_util.stream_edit_uri(stream),+ });+}++function format_user_group_list_item(group) {+ return render_user_group_list_item({+ group_id: group.id,+ name: group.name,+ });+}++function render_user_stream_list(streams, user) {+ streams.sort(compare_by_name);+ const container = $("#user-profile-modal .user-stream-list");+ container.empty();+ ListWidget.create(container, streams, {+ name: `user-${user.user_id}-stream-list`,+ modifier(item) {+ return format_user_stream_list_item(item);+ },+ simplebar_container: $("#user-profile-modal .modal-body"),+ });+}++function render_user_group_list(groups, user) {+ groups.sort(compare_by_name);+ const container = $("#user-profile-modal .user-group-list");+ container.empty();+ ListWidget.create(container, groups, {+ name: `user-${user.user_id}-group-list`,+ modifier(item) {+ return format_user_group_list_item(item);+ },+ simplebar_container: $("#user-profile-modal .modal-body"),+ });+}+export function show_user_profile(user) {hide_all();@@ -380,7 +433,8 @@ export function show_user_profile(user) {const profile_data = page_params.custom_profile_fields.map((f) => get_custom_profile_field_data(user, f, field_types, dateFormat)).filter((f) => f.name !== undefined);-+ const user_streams = stream_data.subscribed_subs();+ const groups_of_user = user_groups.get_user_groups_of_user(user.user_id);const args = {full_name: user.full_name,email: people.get_visible_email(user),@@ -396,7 +450,45 @@ export function show_user_profile(user) {};$("#user-profile-modal-holder").html(render_user_profile_modal(args));- overlays.open_modal("#user-profile-modal");+ $("#user-profile-modal").modal("show");+ $(".tabcontent").hide();+ $("#profile-tab").show(); // Show general profile details by default.+ const opts = {+ selected: 0,+ child_wants_focus: true,+ values: [+ {label: $t({defaultMessage: "Profile"}), key: "profile-tab"},+ {label: $t({defaultMessage: "Streams"}), key: "streams-tab"},+ {label: $t({defaultMessage: "User groups"}), key: "groups-tab"},+ ],+ callback(name, key) {+ function hide_profile_tab() {+ $("#profile-tab").hide();+ $(".subscription-group-list").show();+ }+ switch (name) {+ case "User groups":+ hide_profile_tab();+ $("#streams-tab").hide();+ render_user_group_list(groups_of_user, user);+ break;+ case "Streams":+ hide_profile_tab();+ $("#groups-tab").hide();+ render_user_stream_list(user_streams, user);+ break;+ default:+ // default is profile section+ $(".subscription-group-list").hide();+ break;+ }+ $("#" + key).show();+ },+ };++ const elem = components.toggle(opts).get();+ elem.addClass("large allow-overflow");+ $("#tab-toggle").append(elem);settings_account.initialize_custom_user_type_fields("#user-profile-modal #content",diff --git a/static/styles/night_mode.css b/static/styles/night_mode.cssindex a577812dafa..a91685c01a4 100644--- a/static/styles/night_mode.css+++ b/static/styles/night_mode.css@@ -925,6 +925,12 @@ on a dark background, and don't change the dark labels dark either. */}}}++ .subscription-group-list,+ .subscription-group-list .user-stream-list tr,+ .subscription-group-list .user-group-list tr {+ border-color: hsla(0, 0%, 0%, 0.4);+ }}/* Arrows: */diff --git a/static/styles/popovers.css b/static/styles/popovers.cssindex a336d1e0fad..761c195203c 100644--- a/static/styles/popovers.css+++ b/static/styles/popovers.css@@ -257,6 +257,21 @@ ul {#user-profile-modal {border-radius: 4px;+ height: 60vh;+ #tab-toggle {+ font-weight: initial;+ margin: 6px 4px 6px 0;+ width: 100%;+ .tab-switcher {+ margin-left: 2px;+ }+ }+ .name {+ color: hsl(0, 0%, 20%);+ display: inline-block;+ min-width: 120px;+ font-weight: 600;+ }#exit-sign {font-size: 1.5rem;@@ -276,7 +291,19 @@ ul {outline: 9px solid hsl(0, 0%, 100%);}}+ #name {+ font-size: 26px;+ font-weight: 700;+ margin-bottom: 5px;+ max-width: 100%;+ text-align: center;+ line-height: 30px;+ #edit-button {+ font-size: 18px;+ margin-left: 10px;+ }+ }#default-section {font-size: 15px;display: inline-block;@@ -284,31 +311,11 @@ ul {.default-field {margin-bottom: 5px;-- .name {- color: hsl(0, 0%, 20%);- display: inline-block;- min-width: 120px;- font-weight: 600;- }}#user-type {margin-bottom: 15px;}-- #name {- font-size: 26px;- font-weight: 700;- margin-bottom: 5px;- max-width: 300px;- line-height: 30px;-- #edit-button {- font-size: 18px;- margin-left: 10px;- }- }}hr {@@ -351,6 +358,61 @@ ul {margin: 10px 0;}}++ .tab-data {+ .active {+ display: block;+ }++ margin-bottom: 20px;+ }++ .subscription-group-list {+ position: relative;+ border: 1px solid hsl(0, 0%, 83%);+ border-radius: 4px;+ overflow: auto;+ text-align: left;+ margin-bottom: 5px;+ -webkit-overflow-scrolling: touch;++ .user-stream-list,+ .user-group-list {+ width: 100%;+ margin: auto;+ border-radius: 6px;++ tr {+ border-bottom: 1px solid hsl(0, 0%, 87%);++ &:last-of-type {+ border-bottom: none;+ }++ td {+ padding: 4px 0;++ &:first-of-type {+ padding-left: 10px;+ }+ }+ }++ tbody:empty::after,+ &:empty::after {+ content: attr(data-empty);+ display: block;++ text-align: center;+ color: hsl(0, 0%, 67%);+ }++ &:empty {+ display: block;+ padding: 5px;+ }+ }+ }}@media (width < $md_min) {diff --git a/static/templates/user_group_list_item.hbs b/static/templates/user_group_list_item.hbsnew file mode 100644index 00000000000..9973a58c7ca--- /dev/null+++ b/static/templates/user_group_list_item.hbs@@ -0,0 +1,5 @@+<tr data-group-id="{{group_id}}">+ <td class="group_list_item">+ {{name}}+ </td>+</tr>diff --git a/static/templates/user_profile_modal.hbs b/static/templates/user_profile_modal.hbsindex 49b825895e3..70e892653e0 100644--- a/static/templates/user_profile_modal.hbs+++ b/static/templates/user_profile_modal.hbs@@ -1,67 +1,82 @@-<div id="user-profile-modal" class="modal modal-bg fade{{#unless profile_data.length}} no-fields{{/unless}}" tabindex="-1"- role="dialog" aria-labelledby="user_profile_modal label" aria-hidden="true">+<div id="user-profile-modal" class="modal new-style modal-bg fade{{#unless profile_data.length}} no-fields{{/unless}}"+ tabindex="-1" role="dialog" aria-labelledby="user_profile_modal label" aria-hidden="true"><div class="modal-body" id="body" data-simplebar data-simplebar-auto-hide="false"><button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true" id="exit-sign">×</span></button>- <div id="avatar"{{#if user_is_guest}} class="guest-avatar"{{/if}} style="background-image: url('{{user_avatar}}');" ></div>- <div id="default-section">- <div id="name">- {{full_name}}- {{#if is_me}}- <a href="/#settings/your-account">- <i class="fa fa-edit" id="edit-button" aria-hidden="true"></i>- </a>- {{/if}}- </div>- <br />- {{#if show_email}}- <div id="email" class="default-field">- <span class="name">{{#tr}}Email{{/tr}}</span>- <span class="value">{{email}}</span>- </div>- {{/if}}- <div id="date-joined" class="default-field">- <span class="name">{{#tr}}Joined{{/tr}}</span>- <span class="value">{{date_joined}}</span>- </div>- <div id="user-type" class="default-field">- <span class="name">{{#tr}}Role{{/tr}}</span>- <span class="value">{{user_type}}</span>- </div>- <div class="default-field">- <span class="name">{{#tr}}Last active{{/tr}}</span>- <span class="value">{{last_seen}}</span>- </div>- {{#if user_time}}- <div class="default-field">- <span class="name">{{#tr}}Local time{{/tr}}</span>- <span class="value">{{user_time}}</span>- </div>+ <div id="name">+ {{full_name}}+ {{#if is_me}}+ <a href="/#settings/your-account">+ <i class="fa fa-edit" id="edit-button" aria-hidden="true"></i>+ </a>{{/if}}</div>- <hr />- <div id="content">- {{#each profile_data}}- <div data-type="{{this.type}}" class="field-section custom_user_field" data-field-id="{{this.id}}">- <div class="name">{{this.name}}</div>- {{#if this.is_user_field}}- <div class="pill-container not-editable" data-field-id="{{this.id}}">- <div class="input" contenteditable="false" style="display: none;"></div>+ <div id="tab-toggle" class="center"></div>+ <div class="tab-data">+ <div class="tabcontent active" id="profile-tab">+ <div id="avatar" {{#if user_is_guest}} class="guest-avatar" {{/if}}+ style="background-image: url('{{user_avatar}}');"></div>+ <div id="default-section">+ {{#if show_email}}+ <div id="email" class="default-field">+ <span class="name">{{#tr}}Email{{/tr}}</span>+ <span class="value">{{email}}</span></div>- {{else if this.is_link}}- <a href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>- {{else if this.is_external_account}}- <a href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>- {{else}}- {{#if this.rendered_value}}- <div class="value rendered_markdown">{{rendered_markdown this.rendered_value}}</div>- {{else}}- <div class="value">{{this.value}}</div>{{/if}}- {{/if}}+ <div id="date-joined" class="default-field">+ <span class="name">{{#tr}}Joined{{/tr}}</span>+ <span class="value">{{date_joined}}</span>+ </div>+ <div id="user-type" class="default-field">+ <span class="name">{{#tr}}Role{{/tr}}</span>+ <span class="value">{{user_type}}</span>+ </div>+ <div class="default-field">+ <span class="name">{{#tr}}Last active{{/tr}}</span>+ <span class="value">{{last_seen}}</span>+ </div>+ {{#if user_time}}+ <div class="default-field">+ <span class="name">{{#tr}}Local time{{/tr}}</span>+ <span class="value">{{user_time}}</span>+ </div>+ {{/if}}+ </div>+ <div id="content">+ {{#each profile_data}}+ <div data-type="{{this.type}}" class="field-section custom_user_field" data-field-id="{{this.id}}">+ <div class="name">{{this.name}}</div>+ {{#if this.is_user_field}}+ <div class="pill-container not-editable" data-field-id="{{this.id}}">+ <div class="input" contenteditable="false" style="display: none;"></div>+ </div>+ {{else if this.is_link}}+ <a href="{{this.value}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>+ {{else if this.is_external_account}}+ <a href="{{this.link}}" target="_blank" rel="noopener noreferrer" class="value">{{this.value}}</a>+ {{else}}+ {{#if this.rendered_value}}+ <div class="value rendered_markdown">{{rendered_markdown this.rendered_value}}</div>+ {{else}}+ <div class="value">{{this.value}}</div>+ {{/if}}+ {{/if}}+ </div>+ {{/each}}+ </div>+ </div>++ <div class="subscription-group-list">+ <div class="tabcontent" id="groups-tab">+ <table class="user-group-list" data-empty="{{t 'No user group subscriptions.'}}"></table>+ </div>++ <div class="tabcontent" id="streams-tab">+ <table class="user-stream-list" data-empty="{{t 'No stream subscriptions.'}}"></table>+ </div></div>- {{/each}}+</div></div></div>diff --git a/static/templates/user_stream_list_item.hbs b/static/templates/user_stream_list_item.hbsnew file mode 100644index 00000000000..6e0de610dfb--- /dev/null+++ b/static/templates/user_stream_list_item.hbs@@ -0,0 +1,8 @@+<tr data-stream-id="{{stream_id}}">+ <td class="subscription_list_stream">+ <span id="stream_sidebar_privacy_swatch_{{stream_id}}" class="stream-privacy filter-icon" style="color: {{stream_color}}">+ {{> stream_privacy }}+ </span>+ <a href="{{stream_edit_url}}">{{name}}</a>+ </td>+</tr>