fix: implement icon in backend and show icon in table if available
Signed-off-by: David Weber <david.weber@w3tec.ch> Signed-off-by: David Weber <david.weber.schenker@gmail.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { Notification } from '@backstage/plugin-notifications-common';
|
||||
import SvgIcon from '@material-ui/core/SvgIcon';
|
||||
import { useApp } from '@backstage/core-plugin-api';
|
||||
import { SeverityIcon } from './SeverityIcon';
|
||||
|
||||
export const NotificationIcon = ({
|
||||
notification,
|
||||
}: {
|
||||
notification: Notification;
|
||||
}) => {
|
||||
const app = useApp();
|
||||
|
||||
if (notification.payload.icon) {
|
||||
const Icon = app.getSystemIcon(notification.payload.icon) ?? SvgIcon;
|
||||
return <Icon />;
|
||||
}
|
||||
return <SeverityIcon severity={notification.payload.severity} />;
|
||||
};
|
||||
@@ -34,10 +34,9 @@ import {
|
||||
} from '@backstage/core-components';
|
||||
|
||||
import { notificationsApiRef } from '../../api';
|
||||
|
||||
import { SeverityIcon } from './SeverityIcon';
|
||||
import { SelectAll } from './SelectAll';
|
||||
import { BulkActions } from './BulkActions';
|
||||
import { NotificationIcon } from './NotificationIcon';
|
||||
|
||||
const ThrottleDelayMs = 1000;
|
||||
|
||||
@@ -184,7 +183,6 @@ export const NotificationsTable = ({
|
||||
|
||||
const compactColumns = React.useMemo((): TableColumn<Notification>[] => {
|
||||
const showToolbar = notifications.length > 0;
|
||||
|
||||
return [
|
||||
{
|
||||
/* selection column */
|
||||
@@ -220,7 +218,7 @@ export const NotificationsTable = ({
|
||||
return (
|
||||
<Grid container>
|
||||
<Grid item className={classes.severityItem}>
|
||||
<SeverityIcon severity={notification.payload?.severity} />
|
||||
<NotificationIcon notification={notification} />
|
||||
</Grid>
|
||||
<Grid item xs={11}>
|
||||
<Box>
|
||||
|
||||
Reference in New Issue
Block a user