feat(user-settings): Search for user avatar also in the entities

If the identity system doesn't provide an avatar, but the existing
user entity does have the correct annotation use that as the profile
avatar.

Fixes #26838

Signed-off-by: Łukasz Jernaś <lukasz.jernas@allegro.com>
This commit is contained in:
Łukasz Jernaś
2024-09-26 22:00:49 +02:00
parent d02c467eed
commit 0040632c8c
11 changed files with 210 additions and 33 deletions
+28 -1
View File
@@ -17,10 +17,37 @@
import React from 'react';
import { CatalogEntityPage } from '@backstage/plugin-catalog';
import { createDevApp } from '@backstage/dev-utils';
import { userSettingsPlugin, UserSettingsPage } from '../src/plugin';
import { UserSettingsPage, userSettingsPlugin } from '../src';
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react';
import {
CompoundEntityRef,
Entity,
UserEntity,
} from '@backstage/catalog-model';
const userEntity: UserEntity = {
apiVersion: 'backstage.io/v1beta1',
kind: 'User',
metadata: {
name: 'Guest',
},
spec: {},
};
createDevApp()
.registerPlugin(userSettingsPlugin)
.registerApi({
api: catalogApiRef,
deps: {},
factory() {
return {
async getEntityByRef(
_: string | CompoundEntityRef,
): Promise<Entity | undefined> {
return userEntity;
},
} as Partial<CatalogApi> as unknown as CatalogApi;
},
})
.addPage({
title: 'Settings',
path: '/settings',