handle remove logo

This commit is contained in:
Alex Holliday committed 2026-02-03 20:11:47 +00:00
1 parent f10f7385b0
commit 90fd9930db
3 files changed
+9 -4

No files matched your search

+4 -2
View File
@@ -94,8 +94,10 @@ const CreateStatusPage = () => {
}); });
// Handle logo upload // Handle logo upload
if (data.logo?.data && data.logo.data !== "") { if (data.logo === null) {
// Only upload if it's a blob URL (new upload), not base64 (existing) // Signal to remove the logo
fd.append("removeLogo", "true");
} else if (data.logo?.data && data.logo.data !== "") {
if (data.logo.data.startsWith("blob:")) { if (data.logo.data.startsWith("blob:")) {
try { try {
const imageResult = await axios.get(data.logo.data, { const imageResult = await axios.get(data.logo.data, {
@@ -105,14 +105,16 @@ class MongoStatusPagesRepository implements IStatusPagesRepository {
return this.mapDocuments(statusPages); return this.mapDocuments(statusPages);
}; };
updateById = async (id: string, teamId: string, image: Express.Multer.File | undefined, patch: Partial<StatusPage>): Promise<StatusPage> => { updateById = async (id: string, teamId: string, image: Express.Multer.File | undefined, patch: Partial<StatusPage> & { removeLogo?: string }): Promise<StatusPage> => {
const { logo: _logo, ...restPatch } = patch; const { logo: _logo, removeLogo, ...restPatch } = patch;
const updateData: StatusPageUpdateData = { ...restPatch }; const updateData: StatusPageUpdateData = { ...restPatch };
if (image) { if (image) {
updateData.logo = { updateData.logo = {
data: image.buffer as Buffer, data: image.buffer as Buffer,
contentType: image.mimetype, contentType: image.mimetype,
}; };
} else if (removeLogo === "true") {
updateData.logo = null;
} }
const statusPage = await StatusPageModel.findOneAndUpdate({ teamId, _id: id }, updateData, { const statusPage = await StatusPageModel.findOneAndUpdate({ teamId, _id: id }, updateData, {
+1
View File
@@ -480,6 +480,7 @@ const createStatusPageBodyValidation = joi.object({
showCharts: joi.boolean().optional(), showCharts: joi.boolean().optional(),
showUptimePercentage: joi.boolean(), showUptimePercentage: joi.boolean(),
showAdminLoginLink: joi.boolean().optional(), showAdminLoginLink: joi.boolean().optional(),
removeLogo: joi.string().valid("true", "false").optional(),
}); });
const imageValidation = joi const imageValidation = joi