Show display names for third-party users

Whenever possible, always show display names instead of usernames on
annotation cards if the creator of the card is a third-party user.

Even if the client_display_names feature flag is turned off, display
names _will_ still be shown for third-party users.

Display names will _not_ be shown for first-party users, unless the
client_display_names feature flag is on.

If the api_render_user_info feature flag is turned off in h, or if the
user doesn't have a display name, then of course the username must be
shown as the client has no access to a display name.
parent 21b62e27
......@@ -14,7 +14,8 @@ function AnnotationHeaderController(features, groups, settings, serviceUrl) {
this.displayName = () => {
var userInfo = this.annotation.user_info;
if (features.flagEnabled('client_display_names')) {
var isThirdPartyUser = persona.isThirdPartyUser(this.annotation.user, settings.authDomain);
if (features.flagEnabled('client_display_names') || isThirdPartyUser) {
// userInfo is undefined if the api_render_user_info feature flag is off.
if (userInfo) {
// display_name is null if the user doesn't have a display name.
......
......@@ -141,6 +141,42 @@ describe('sidebar.components.annotation-header', function () {
isThirdPartyUser: false,
expectedResult: 'Bill Jones',
},
{
context: 'when the client_display_names feature flag is off but ' +
'the user is a third-party user',
it: 'returns display_name even though client_display_names is off',
user_info: { display_name: 'Bill Jones' },
client_display_names: false,
isThirdPartyUser: true,
expectedResult: 'Bill Jones',
},
{
context: 'when client_display_names is on and the user is a ' +
'third-party user',
it: 'returns the display_name',
user_info: { display_name: 'Bill Jones' },
client_display_names: true,
isThirdPartyUser: true,
expectedResult: 'Bill Jones',
},
{
context: 'when the user is a third-party user but the ' +
'api_render_user_info feature flag is turned off in h',
it: 'returns the username',
user_info: undefined,
client_display_names: true,
isThirdPartyUser: true,
expectedResult: 'TEST_USERNAME',
},
{
context: "when the user is a third-party user but doesn't have a " +
'display_name',
it: 'returns the username',
user_info: { display_name: null},
client_display_names: true,
isThirdPartyUser: true,
expectedResult: 'TEST_USERNAME',
},
].forEach((test) => {
context(test.context, () => {
it(test.it, () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment