Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the correct key is used for metacard favourite info #4321

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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