Rename the storage location of the starred entities from /settings/starredEntities to /starredEntitites/entitifyRefs
Signed-off-by: Dominik Henneke <dominik.henneke@sda-se.com>
This commit is contained in:
@@ -6,4 +6,7 @@
|
||||
Introduce a new `StarredEntitiesApi` that is used in the `useStarredEntities` hook.
|
||||
The `@backstage/plugin-catalog` installs a default implementation that is backed by the `StorageApi`, but one can also override the `starredEntitiesApiRef`.
|
||||
|
||||
**BREAKING** All previously stored entities get lost with this update, because the storage format has been migrated from a custom string to an entity reference.
|
||||
**BREAKING** All previously stored entities get lost with this update, because:
|
||||
|
||||
1. The storage format has been migrated from a custom string to an entity reference.
|
||||
2. The storage key in the local storage has been changed.
|
||||
|
||||
@@ -52,8 +52,8 @@ describe('DefaultStarredEntitiesApi', () => {
|
||||
});
|
||||
|
||||
it('should unstar starred entity', async () => {
|
||||
const bucket = mockStorage.forBucket('settings');
|
||||
await bucket.set('starredEntities', ['component:default/mock']);
|
||||
const bucket = mockStorage.forBucket('starredEntities');
|
||||
await bucket.set('entityRefs', ['component:default/mock']);
|
||||
|
||||
expect(starredEntitiesApi.isStarred(mockEntity)).toBe(true);
|
||||
|
||||
@@ -78,8 +78,8 @@ describe('DefaultStarredEntitiesApi', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const bucket = mockStorage.forBucket('settings');
|
||||
bucket.set('starredEntities', ['component:default/mock']).then();
|
||||
const bucket = mockStorage.forBucket('starredEntities');
|
||||
bucket.set('entityRefs', ['component:default/mock']).then();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ export class DefaultStarredEntitiesApi implements StarredEntitiesApi {
|
||||
private starredEntities: Set<string>;
|
||||
|
||||
constructor(opts: { storageApi: StorageApi }) {
|
||||
this.settingsStore = opts.storageApi.forBucket('settings');
|
||||
this.settingsStore = opts.storageApi.forBucket('starredEntities');
|
||||
|
||||
this.starredEntities = new Set(
|
||||
this.settingsStore.get<string[]>('starredEntities') ?? [],
|
||||
this.settingsStore.get<string[]>('entityRefs') ?? [],
|
||||
);
|
||||
|
||||
this.settingsStore.observe$<string[]>('starredEntities').subscribe({
|
||||
this.settingsStore.observe$<string[]>('entityRefs').subscribe({
|
||||
next: next => {
|
||||
this.starredEntities = new Set(next.newValue ?? []);
|
||||
this.notifyChanges();
|
||||
@@ -56,7 +56,7 @@ export class DefaultStarredEntitiesApi implements StarredEntitiesApi {
|
||||
}
|
||||
|
||||
await this.settingsStore.set(
|
||||
'starredEntities',
|
||||
'entityRefs',
|
||||
Array.from(this.starredEntities),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ describe('useStarredEntities', () => {
|
||||
|
||||
it('should return a set with the current items when there are items in storage', async () => {
|
||||
const expectedIds = ['i', 'am', 'some', 'test', 'ids'];
|
||||
const store = mockStorage?.forBucket('settings');
|
||||
await store?.set('starredEntities', expectedIds);
|
||||
const store = mockStorage?.forBucket('starredEntities');
|
||||
await store?.set('entityRefs', expectedIds);
|
||||
|
||||
const { result, waitForNextUpdate } = renderHook(
|
||||
() => useStarredEntities(),
|
||||
|
||||
Reference in New Issue
Block a user