mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
feat(logo-cuatomization): added size and ext to files
This commit is contained in:
parent
bbed67982c
commit
9ce78034ef
@ -32,7 +32,7 @@ global.strapi = {
|
||||
hash: 'filename_123',
|
||||
ext: '.png',
|
||||
mime: 'image/png',
|
||||
size: 1024 * 1024,
|
||||
size: 123,
|
||||
}),
|
||||
},
|
||||
'image-manipulation': {
|
||||
@ -49,6 +49,8 @@ global.strapi = {
|
||||
url: 'file/url',
|
||||
width: 100,
|
||||
height: 100,
|
||||
ext: 'png',
|
||||
size: 123,
|
||||
},
|
||||
}),
|
||||
set: storeSet,
|
||||
@ -62,7 +64,7 @@ describe('Project setting', () => {
|
||||
it('Should parse valid files object', async () => {
|
||||
const files = {
|
||||
menuLogo: {
|
||||
size: 24085,
|
||||
size: 123,
|
||||
path: '/tmp/filename_123',
|
||||
name: 'file.png',
|
||||
type: 'image/png',
|
||||
@ -77,7 +79,7 @@ describe('Project setting', () => {
|
||||
hash: 'filename_123',
|
||||
ext: '.png',
|
||||
mime: 'image/png',
|
||||
size: 1024 * 1024,
|
||||
size: 123,
|
||||
stream: null,
|
||||
width: 100,
|
||||
height: 100,
|
||||
@ -111,6 +113,8 @@ describe('Project setting', () => {
|
||||
url: 'file/url',
|
||||
width: 100,
|
||||
height: 100,
|
||||
ext: 'png',
|
||||
size: 123,
|
||||
},
|
||||
};
|
||||
|
||||
@ -208,7 +212,7 @@ describe('Project setting', () => {
|
||||
hash: 'filename_123',
|
||||
ext: '.png',
|
||||
mime: 'image/png',
|
||||
size: 1024 * 1024,
|
||||
size: 123,
|
||||
stream: null,
|
||||
width: 100,
|
||||
height: 100,
|
||||
@ -225,6 +229,8 @@ describe('Project setting', () => {
|
||||
url: '/uploads/filename_123.png',
|
||||
width: 100,
|
||||
height: 100,
|
||||
ext: 'png',
|
||||
size: 123,
|
||||
},
|
||||
};
|
||||
|
||||
@ -265,6 +271,8 @@ describe('Project setting', () => {
|
||||
url: 'file/url',
|
||||
width: 100,
|
||||
height: 100,
|
||||
ext: 'png',
|
||||
size: 123,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -55,6 +55,7 @@ const getProjectSettings = async () => {
|
||||
const store = await strapi.store({ type: 'core', name: 'admin' });
|
||||
const projectSettings = await store.get({ key: 'project-settings' });
|
||||
|
||||
// Filter file input fields
|
||||
PROJECT_SETTINGS_FILE_INPUTS.forEach(inputName => {
|
||||
if (projectSettings[inputName]) {
|
||||
projectSettings[inputName] = pick(projectSettings[inputName], [
|
||||
@ -62,6 +63,8 @@ const getProjectSettings = async () => {
|
||||
'url',
|
||||
'width',
|
||||
'height',
|
||||
'ext',
|
||||
'size',
|
||||
]);
|
||||
}
|
||||
});
|
||||
@ -120,6 +123,8 @@ const updateProjectSettings = async ({ body, files }) => {
|
||||
url: newSettings[inputName].url,
|
||||
width: newSettings[inputName].width,
|
||||
height: newSettings[inputName].height,
|
||||
ext: newSettings[inputName].ext.replace('.', ''),
|
||||
size: newSettings[inputName].size,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@ -23,13 +23,12 @@ const updateProjectSettingsFiles = yup
|
||||
})
|
||||
.noUnknown();
|
||||
|
||||
const updateProjectSettingsImagesDimensions = yup
|
||||
.object({
|
||||
menuLogo: yup.object({
|
||||
width: yup.number().max(MAX_IMAGE_WIDTH),
|
||||
height: yup.number().max(MAX_IMAGE_HEIGHT),
|
||||
}),
|
||||
})
|
||||
const updateProjectSettingsImagesDimensions = yup.object({
|
||||
menuLogo: yup.object({
|
||||
width: yup.number().max(MAX_IMAGE_WIDTH),
|
||||
height: yup.number().max(MAX_IMAGE_HEIGHT),
|
||||
}),
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
validateUpdateProjectSettings: validateYupSchemaSync(updateProjectSettings),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user