Skip to content

Commit

Permalink
Ensure the correct key is used metacard favourite info (#4321)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox authored Jun 2, 2020
1 parent 9dab0de commit 9011c81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { CfAPIResource } from './store/types/cf-api.types';

export function getFavoriteFromCfEntity<T extends IEntityMetadata = IEntityMetadata>(
entity,
entityKey: string,
entityType: string,
favoritesConfigMapper: FavoritesConfigMapper
): UserFavorite<T> {
if (isCfEntity(entity as CfAPIResource)) {
return favoritesConfigMapper.getFavoriteFromEntity<T>(
entityKey,
entityType,
'cf',
entity.entity.cfGuid,
entity
Expand Down
8 changes: 4 additions & 4 deletions src/frontend/packages/core/src/core/user-favorite-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export function isEndpointTypeFavorite(favorite: UserFavorite<IFavoriteMetadata>
// Uses the endpoint definition to get the helper that can look up an entitty
export function getFavoriteFromEntity<T extends IEntityMetadata = IEntityMetadata>(
entity,
entityKey: string,
entityType: string,
favoritesConfigMapper: FavoritesConfigMapper,
entityType: string
endpointType: string
): UserFavorite<T> {
// Use entity catalog to get favorite for the given endpoint type
const endpoint = entityCatalog.getEndpoint(entityType);
const endpoint = entityCatalog.getEndpoint(endpointType);
if (endpoint && endpoint.definition && endpoint.definition.favoriteFromEntity) {
return endpoint.definition.favoriteFromEntity(entity, entityKey, favoritesConfigMapper);
return endpoint.definition.favoriteFromEntity(entity, entityType, favoritesConfigMapper);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function createMetaCardMenuItemSeparator() {
return {
label: '-',
separator: true,
action: () => {}
action: () => { }
};
}

Expand Down Expand Up @@ -79,7 +79,7 @@ export class MetaCardComponent implements OnDestroy {
first(),
tap(entity => this.favorite = getFavoriteFromEntity(
entity,
entityConfig.schema.key,
entityConfig.schema.entityType,
this.favoritesConfigMapper,
entityConfig.schema.endpointType
))
Expand Down

0 comments on commit 9011c81

Please sign in to comment.