Adding alert popup whenever user deletes the entities from playlist entity table (#19219)
* Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- added test cases Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- error message changed Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- error message changed Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- test file changes Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- test file changes added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name when adding a shortcut- test file changes removed Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test cases Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test cases Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test cases Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test cases Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test case error message added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut with test case error message removed Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut fixed review changes Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Limit the use of the same shortcut name and url when adding a shortcut fixed review changes Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Added play list alert when deleting playlist from table changes added as per review Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Playlist entity remove review changes added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Playlist entity remove review changes added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Playlist entity remove review changes added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> * Playlist entity remove review changes added Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com> --------- Signed-off-by: AmbrishRamachandiran <ambrish.r@infosys.com>
This commit is contained in:
committed by
GitHub
parent
405b56950d
commit
8a997547f0
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-playlist': patch
|
||||
---
|
||||
|
||||
Adding alert popup whenever user delete the entities from playlist entity table
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
Table,
|
||||
TableFilter,
|
||||
} from '@backstage/core-components';
|
||||
import { errorApiRef, useApi } from '@backstage/core-plugin-api';
|
||||
import { errorApiRef, useApi, alertApiRef } from '@backstage/core-plugin-api';
|
||||
import { EntityRefLink } from '@backstage/plugin-catalog-react';
|
||||
import { usePermission } from '@backstage/plugin-permission-react';
|
||||
import { permissions } from '@backstage/plugin-playlist-common';
|
||||
@@ -42,6 +42,7 @@ export const PlaylistEntitiesTable = ({
|
||||
}) => {
|
||||
const errorApi = useApi(errorApiRef);
|
||||
const playlistApi = useApi(playlistApiRef);
|
||||
const alertApi = useApi(alertApiRef);
|
||||
const [openAddEntitiesDrawer, setOpenAddEntitiesDrawer] = useState(false);
|
||||
|
||||
const { allowed: editAllowed } = usePermission({
|
||||
@@ -73,16 +74,30 @@ export const PlaylistEntitiesTable = ({
|
||||
const removeEntity = useCallback(
|
||||
async (_, entity: Entity | Entity[]) => {
|
||||
try {
|
||||
const entityArray = [entity].flat();
|
||||
const entityNames = entityArray.map(
|
||||
item => item.metadata.title ?? item.metadata.name,
|
||||
);
|
||||
await playlistApi.removePlaylistEntities(
|
||||
playlistId,
|
||||
[entity].flat().map(stringifyEntityRef),
|
||||
);
|
||||
loadEntities();
|
||||
const message =
|
||||
entityNames.length === 1
|
||||
? `Removed entity '${entityNames[0]}'`
|
||||
: `Removed entities: '${entityNames.join("', '")}'`;
|
||||
|
||||
alertApi.post({
|
||||
message,
|
||||
severity: 'success',
|
||||
display: 'transient',
|
||||
});
|
||||
} catch (e) {
|
||||
errorApi.post(e);
|
||||
}
|
||||
},
|
||||
[errorApi, loadEntities, playlistApi, playlistId],
|
||||
[errorApi, loadEntities, playlistApi, playlistId, alertApi],
|
||||
);
|
||||
|
||||
const singularTitleLowerCase = useTitle({
|
||||
|
||||
Reference in New Issue
Block a user