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