Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
input_pill: Customize pills for deactivated users.
Hashir Sarwar130f1d715337
diff --git a/frontend_tests/node_tests/compose_pm_pill.js b/frontend_tests/node_tests/compose_pm_pill.jsindex 652fd532299..528ff831d0d 100644--- a/frontend_tests/node_tests/compose_pm_pill.js+++ b/frontend_tests/node_tests/compose_pm_pill.js@@ -37,6 +37,10 @@ run_test("pills", ({override}) => {full_name: "Hamlet",};+ people.add_active_user(othello);+ people.add_active_user(iago);+ people.add_active_user(hamlet);+people.get_realm_users = () => [iago, othello, hamlet];const recipient_stub = $("#private_message_recipient");@@ -113,6 +117,18 @@ run_test("pills", ({override}) => {assert.equal(res.user_id, iago.user_id);assert.equal(res.display_value, iago.full_name);})();++ (function test_deactivated_pill() {+ people.deactivate(iago);+ get_by_email_called = false;+ const res = handler(iago.email, pills.items());+ assert.ok(get_by_email_called);+ assert.equal(typeof res, "object");+ assert.equal(res.user_id, iago.user_id);+ assert.equal(res.display_value, iago.full_name + " (deactivated)");+ assert.ok(res.deactivated);+ people.add_active_user(iago);+ })();}function input_pill_stub(opts) {@@ -152,7 +168,9 @@ run_test("pills", ({override}) => {const persons = [othello, iago, hamlet];const items = compose_pm_pill.filter_taken_users(persons);- assert.deepEqual(items, [{email: "[email protected]", user_id: 2, full_name: "Iago"}]);+ assert.deepEqual(items, [+ {email: "[email protected]", user_id: 2, full_name: "Iago", is_moderator: false},+ ]);test_create_item(create_item_handler);diff --git a/frontend_tests/node_tests/settings_user_groups.js b/frontend_tests/node_tests/settings_user_groups.jsindex 23cc03c36eb..ed374e755aa 100644--- a/frontend_tests/node_tests/settings_user_groups.js+++ b/frontend_tests/node_tests/settings_user_groups.js@@ -121,6 +121,10 @@ test_ui("populate_user_groups", ({override}) => {full_name: "Bob",};+ people.add_active_user(iago);+ people.add_active_user(alice);+ people.add_active_user(bob);+people.get_realm_users = () => [iago, alice, bob];user_groups.get_realm_user_groups = () => [realm_user_group];@@ -321,6 +325,18 @@ test_ui("populate_user_groups", ({override}) => {assert.equal(res.user_id, bob.user_id);assert.equal(res.display_value, bob.full_name);})();++ (function test_deactivated_pill() {+ people.deactivate(bob);+ get_by_email_called = false;+ const res = handler(bob.email, pills.items());+ assert.ok(get_by_email_called);+ assert.equal(typeof res, "object");+ assert.equal(res.user_id, bob.user_id);+ assert.equal(res.display_value, bob.full_name + " (deactivated)");+ assert.ok(res.deactivated);+ people.add_active_user(bob);+ })();}pills.onPillRemove = (handler) => {diff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.jsindex 49db8acdf55..05f1b5b07de 100644--- a/frontend_tests/node_tests/user_pill.js+++ b/frontend_tests/node_tests/user_pill.js@@ -32,6 +32,7 @@ const isaac_item = {display_value: "Isaac Newton",type: "user",user_id: isaac.user_id,+ deactivated: false,img_src: `/avatar/${isaac.user_id}&s=50`,};diff --git a/static/js/input_pill.js b/static/js/input_pill.jsindex 66865e88691..3c9cb4966ac 100644--- a/static/js/input_pill.js+++ b/static/js/input_pill.js@@ -102,6 +102,7 @@ export function create(opts) {id: payload.id,display_value: item.display_value,has_image,+ deactivated: item.deactivated,};if (has_image) {diff --git a/static/js/user_pill.js b/static/js/user_pill.jsindex 5662b633ebc..1160d1fabb9 100644--- a/static/js/user_pill.js+++ b/static/js/user_pill.js@@ -48,8 +48,15 @@ export function create_item_from_email(email, current_items) {user_id: user.user_id,email: user.email,img_src: avatar_url,+ deactivated: false,};+ // We pass deactivated true for a deactivated user+ if (!people.is_person_active(user.user_id)) {+ item.deactivated = true;+ item.display_value = user.full_name + " (deactivated)";+ }+return item;}diff --git a/static/styles/zulip.css b/static/styles/zulip.cssindex ebc740d3abb..b7426589bb0 100644--- a/static/styles/zulip.css+++ b/static/styles/zulip.css@@ -1627,6 +1627,10 @@ div.focused_table {}}+.deactivated-pill {+ background-color: hsl(0, 86%, 86%) !important;+}+#message_view_header {z-index: 2;float: left;diff --git a/static/templates/input_pill.hbs b/static/templates/input_pill.hbsindex 1e1a249ca26..3fcab6bd385 100644--- a/static/templates/input_pill.hbs+++ b/static/templates/input_pill.hbs@@ -1,4 +1,4 @@-<div class='pill' data-id='{{ id }}' tabindex=0>+<div class='pill {{#if deactivated}} deactivated-pill {{/if}}' data-id='{{ id }}' tabindex=0>{{#if has_image}}<img class="pill-image" src="{{img_src}}" />{{/if}}