mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 08:16:35 +00:00
Merge branch 'features/deits' into deits/fix-telemetry
This commit is contained in:
commit
f4e94e77bf
@ -73,7 +73,7 @@ const DynamicZoneComponent = ({
|
||||
|
||||
const mainField = get(modifiedData, [name, index, mainFieldKey]) ?? '';
|
||||
|
||||
const displayedValue = mainFieldKey === 'id' ? '' : mainField.trim();
|
||||
const displayedValue = mainFieldKey === 'id' ? '' : String(mainField).trim();
|
||||
|
||||
const mainValue = displayedValue.length > 0 ? ` - ${displayedValue}` : displayedValue;
|
||||
|
||||
|
@ -24,7 +24,8 @@ export const findLeafByPathAndReplace = (endpath, replaceWith) => {
|
||||
* and the current path is not undefined in the accumulator
|
||||
* then we assume it's a leaf and we can replace it.
|
||||
*/
|
||||
if (endpath === curr && acc[curr] !== undefined) {
|
||||
|
||||
if (ind === currentArr.length - 1 && endpath === curr && acc[curr] !== undefined) {
|
||||
set(acc, curr, replaceWith);
|
||||
|
||||
return acc;
|
||||
|
@ -122,4 +122,34 @@ describe('findLeafByPathAndReplace', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should only replace the leaf if it is the last item in the array of paths', () => {
|
||||
const obj = {
|
||||
a: {
|
||||
a: [
|
||||
{
|
||||
a: 'd',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const path = ['a', 'a', 'a'];
|
||||
|
||||
const [lastPath] = path.slice(-1);
|
||||
|
||||
const findLeaf = findLeafByPathAndReplace(lastPath, []);
|
||||
|
||||
path.reduce(findLeaf, obj);
|
||||
|
||||
expect(obj).toMatchObject({
|
||||
a: {
|
||||
a: [
|
||||
{
|
||||
a: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,14 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
method: 'POST',
|
||||
path: '/users/batch-delete',
|
||||
handler: 'user.deleteMany',
|
||||
config: {
|
||||
policies: [{ name: 'admin::hasPermissions', config: { actions: ['admin::users.delete'] } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/roles/:id/permissions',
|
||||
|
Loading…
x
Reference in New Issue
Block a user