Merge branch 'features/deits' into deits/fix-telemetry

This commit is contained in:
Ben Irvin 2022-12-28 09:41:02 +01:00 committed by GitHub
commit f4e94e77bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 10 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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: [],
},
],
},
});
});
});

View File

@ -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',