diff --git a/adminSiteClient/ImagesIndexPage.tsx b/adminSiteClient/ImagesIndexPage.tsx index 24ba88b42c..ecd8a452f9 100644 --- a/adminSiteClient/ImagesIndexPage.tsx +++ b/adminSiteClient/ImagesIndexPage.tsx @@ -14,6 +14,7 @@ import { Popover, Table, Upload, + notification, } from "antd" import { AdminLayout } from "./AdminLayout.js" import { AdminAppContext } from "./AdminAppContext.js" @@ -31,6 +32,7 @@ import { RcFile } from "antd/es/upload/interface.js" import { CLOUDFLARE_IMAGES_URL } from "../settings/clientSettings.js" import { Dictionary, keyBy } from "lodash" import cx from "classnames" +import { NotificationInstance } from "antd/es/notification/interface.js" type ImageMap = Record @@ -237,10 +239,12 @@ function createColumns({ api, users, usage, + notificationApi, }: { api: ImageEditorApi users: UserMap usage: Dictionary + notificationApi: NotificationInstance }): ColumnsType { return [ { @@ -376,7 +380,11 @@ function createColumns({ return ( - + - - + <> + + + + ) } +const NotificationContext = React.createContext(null) + export function ImageIndexPage() { const { admin } = useContext(AdminAppContext) + const [notificationApi, notificationContextHolder] = + notification.useNotification() const [images, setImages] = useState({}) const [users, setUsers] = useState({}) const [usage, setUsage] = useState>({}) @@ -605,8 +630,8 @@ export function ImageIndexPage() { ) const columns = useMemo( - () => createColumns({ api, users, usage }), - [api, users, usage] + () => createColumns({ api, users, usage, notificationApi }), + [api, users, usage, notificationApi] ) useEffect(() => { @@ -617,18 +642,23 @@ export function ImageIndexPage() { return ( -
- - setFilenameSearchValue(e.target.value)} - style={{ width: 500, marginBottom: 20 }} - /> - - - - + + {notificationContextHolder} +
+ + + setFilenameSearchValue(e.target.value) + } + style={{ width: 500, marginBottom: 20 }} + /> + + +
+ + ) } diff --git a/adminSiteServer/apiRouter.ts b/adminSiteServer/apiRouter.ts index 945d6b6670..5cf0e042bc 100644 --- a/adminSiteServer/apiRouter.ts +++ b/adminSiteServer/apiRouter.ts @@ -3241,6 +3241,7 @@ putRouteWithRWTransaction(apiRouter, "/images/:id", async (req, res, trx) => { const originalCloudflareId = image.cloudflareId const originalFilename = image.filename + const originalAltText = image.defaultAlt if (!originalCloudflareId) { throw new JsonError( @@ -3262,6 +3263,7 @@ putRouteWithRWTransaction(apiRouter, "/images/:id", async (req, res, trx) => { cloudflareId: newCloudflareId, updatedAt: new Date().getTime(), userId: res.locals.user.id, + defaultAlt: originalAltText, hash, version: image.version + 1, })