2021-08-28 13:31:58 +02:00
|
|
|
From 9062a3705c67f576a2484fe69a39847ae7ff293a Mon Sep 17 00:00:00 2001
|
2020-12-20 16:12:40 +01:00
|
|
|
From: Luke Granger-Brown <git@lukegb.com>
|
|
|
|
Date: Sun, 20 Dec 2020 14:29:22 +0000
|
2021-04-06 11:27:20 +02:00
|
|
|
Subject: [PATCH 7/7] Keep left padding on account chip if no avatar provider
|
2020-12-20 16:12:40 +01:00
|
|
|
present
|
|
|
|
|
|
|
|
At the moment, if there's no plugin that provides avatars then the left
|
|
|
|
padding is still removed if there *would* be an avatar there, which
|
|
|
|
leads to some weirdly offset text.
|
|
|
|
|
|
|
|
Change-Id: I1ff0745aa267d7fb227e39460c8ea80ef5ec2f55
|
|
|
|
---
|
|
|
|
.../gr-account-label/gr-account-label.ts | 6 ++
|
|
|
|
.../gr-account-label/gr-account-label_test.js | 63 +++++++++++++++++++
|
|
|
|
2 files changed, 69 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
|
2021-04-06 11:27:20 +02:00
|
|
|
index 64bae58c41..220fcf413b 100644
|
2020-12-20 16:12:40 +01:00
|
|
|
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
|
|
|
|
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
|
2021-04-06 11:27:20 +02:00
|
|
|
@@ -151,7 +151,13 @@ export class GrAccountLabel extends PolymerElement {
|
2020-12-20 16:12:40 +01:00
|
|
|
change: ChangeInfo,
|
|
|
|
force: boolean
|
|
|
|
) {
|
|
|
|
+ const avatarsAvailable = (
|
|
|
|
+ !!config &&
|
|
|
|
+ !!config.change &&
|
|
|
|
+ !!config.plugin.has_avatars
|
|
|
|
+ );
|
|
|
|
return (
|
|
|
|
+ avatarsAvailable &&
|
|
|
|
!hideAvatar &&
|
|
|
|
!this._hasAttention(config, highlight, account, change, force)
|
|
|
|
);
|
|
|
|
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.js b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.js
|
2021-04-06 11:27:20 +02:00
|
|
|
index f37aa01a2d..4a21222dca 100644
|
2020-12-20 16:12:40 +01:00
|
|
|
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.js
|
|
|
|
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.js
|
2021-04-06 11:27:20 +02:00
|
|
|
@@ -44,6 +44,69 @@ suite('gr-account-label tests', () => {
|
2020-12-20 16:12:40 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
+ suite('_computeCancelLeftPadding', () => {
|
|
|
|
+ test('config not ready', () => {
|
|
|
|
+ assert.isFalse(
|
|
|
|
+ element._computeCancelLeftPadding(
|
|
|
|
+ /*hideAvatar=*/false,
|
|
|
|
+ /*config=*/undefined,
|
|
|
|
+ /*highlight=*/false,
|
|
|
|
+ /*account=*/element.account,
|
|
|
|
+ /*change=*/element.change,
|
|
|
|
+ /*force=*/false));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ test('no avatar provider', () => {
|
|
|
|
+ const config = {
|
|
|
|
+ plugin: {},
|
|
|
|
+ };
|
|
|
|
+ assert.isFalse(
|
|
|
|
+ element._computeCancelLeftPadding(
|
|
|
|
+ /*hideAvatar=*/false,
|
|
|
|
+ /*config=*/config,
|
|
|
|
+ /*highlight=*/false,
|
|
|
|
+ /*account=*/element.account,
|
|
|
|
+ /*change=*/element.change,
|
|
|
|
+ /*force=*/false));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ test('avatar provider present', () => {
|
|
|
|
+ const config = {
|
|
|
|
+ plugin: {
|
|
|
|
+ has_avatars: true,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ assert.isTrue(
|
|
|
|
+ element._computeCancelLeftPadding(
|
|
|
|
+ /*hideAvatar=*/false,
|
|
|
|
+ /*config=*/config,
|
|
|
|
+ /*highlight=*/false,
|
|
|
|
+ /*account=*/element.account,
|
|
|
|
+ /*change=*/element.change,
|
|
|
|
+ /*force=*/false));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ test('has attention', () => {
|
|
|
|
+ const config = {
|
|
|
|
+ change: {enable_attention_set: true},
|
|
|
|
+ user: {anonymous_coward_name: 'Anonymous Coward'},
|
|
|
|
+ plugin: {has_avatars: true},
|
|
|
|
+ };
|
|
|
|
+ const selfAccount = createAccount('kermit', 31);
|
|
|
|
+ const account = createAccount('ernie', 42);
|
|
|
|
+ const change = {attention_set: {42: {}}};
|
|
|
|
+
|
|
|
|
+ assert.isFalse(
|
|
|
|
+ element._computeCancelLeftPadding(
|
|
|
|
+ /*hideAvatar=*/false,
|
|
|
|
+ /*config=*/config,
|
|
|
|
+ /*highlight=*/true,
|
|
|
|
+ /*account=*/account,
|
|
|
|
+ /*change=*/change,
|
|
|
|
+ /*force=*/false));
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
suite('_computeName', () => {
|
|
|
|
test('not showing anonymous', () => {
|
|
|
|
const account = {name: 'Wyatt'};
|
|
|
|
--
|
2021-08-28 13:31:58 +02:00
|
|
|
2.32.0
|
2020-12-20 16:12:40 +01:00
|
|
|
|