mirror of
https://github.com/strapi/strapi.git
synced 2025-08-10 17:58:07 +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 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;
|
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
|
* and the current path is not undefined in the accumulator
|
||||||
* then we assume it's a leaf and we can replace it.
|
* 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);
|
set(acc, curr, replaceWith);
|
||||||
|
|
||||||
return acc;
|
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';
|
'use strict';
|
||||||
|
|
||||||
module.exports = [
|
module.exports = [
|
||||||
{
|
|
||||||
method: 'POST',
|
|
||||||
path: '/users/batch-delete',
|
|
||||||
handler: 'user.deleteMany',
|
|
||||||
config: {
|
|
||||||
policies: [{ name: 'admin::hasPermissions', config: { actions: ['admin::users.delete'] } }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/roles/:id/permissions',
|
path: '/roles/:id/permissions',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user