Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression when parent list of a Content field had a where clau… #1673

Merged
merged 2 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/dry-clouds-sit/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"releases": [
{ "name": "@keystone-alpha/field-content", "type": "patch" },
{ "name": "@keystone-alpha/fields", "type": "patch" }
],
"dependents": []
}
1 change: 1 addition & 0 deletions .changeset/dry-clouds-sit/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression when parent list of a Content field had a `where` clause as its access control.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ We also build commonjs builds to run in node (for testing with jest or etc.) and
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->

<!-- prettier-ignore -->

<table>
<tr>
<td align="center"><a href="http://www.thinkmill.com.au"><img src="https://avatars3.githubusercontent.com/u/872310?v=4" width="100px;" alt="Jed Watson"/><br /><sub><b>Jed Watson</b></sub></a><br /><a href="https://github.com/keystonejs/keystone-5/commits?author=JedWatson" title="Code">💻</a></td>
Expand Down
2 changes: 1 addition & 1 deletion demo-projects/todo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"@keystone-alpha/app-static": "^1.1.1",
"cross-env": "^5.2.0"
}
}
}
11 changes: 10 additions & 1 deletion packages/field-content/src/Implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,16 @@ export class Content extends Relationship.implementation {
};
},
},
access: listConfig.listAccess,
access: Object.entries(listConfig.listAccess).reduce(
(acc, [schemaName, access]) => ({
...acc,
[schemaName]: Object.entries(access).reduce(
(acc, [op, rule]) => ({ ...acc, [op]: !!rule }), // Reduce the entries to truthy values
{}
),
}),
{}
),
});
}

Expand Down
11 changes: 10 additions & 1 deletion packages/fields/src/types/CloudinaryImage/ImageBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ export class ImageBlock extends Block {
'A reference back to the Slate.js Serialised Document this image is embedded within',
},
},
access: listConfig.listAccess,
access: Object.entries(listConfig.listAccess).reduce(
(acc, [schemaName, access]) => ({
...acc,
[schemaName]: Object.entries(access).reduce(
(acc, [op, rule]) => ({ ...acc, [op]: !!rule }), // Reduce the entries to truthy values
{}
),
}),
{}
),
});
}

Expand Down
11 changes: 10 additions & 1 deletion packages/fields/src/types/OEmbed/OEmbedBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ export class OEmbedBlock extends Block {
'A reference back to the Slate.js Serialised Document this embed is contained within',
},
},
access: listConfig.listAccess,
access: Object.entries(listConfig.listAccess).reduce(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Util function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now used 3 times?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 times!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe, but also I don't have time right now :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real refactor should come one level higher with the way we create these Aux lists for blocks, but that's future Tim's problem.

(acc, [schemaName, access]) => ({
...acc,
[schemaName]: Object.entries(access).reduce(
(acc, [op, rule]) => ({ ...acc, [op]: !!rule }), // Reduce the entries to truthy values
{}
),
}),
{}
),
});
}

Expand Down
11 changes: 10 additions & 1 deletion packages/fields/src/types/Unsplash/UnsplashBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ export class UnsplashBlock extends Block {
'A reference back to the Slate.js Serialised Document this unsplash image is contained within',
},
},
access: listConfig.listAccess,
access: Object.entries(listConfig.listAccess).reduce(
(acc, [schemaName, access]) => ({
...acc,
[schemaName]: Object.entries(access).reduce(
(acc, [op, rule]) => ({ ...acc, [op]: !!rule }), // Reduce the entries to truthy values
{}
),
}),
{}
),
});
}

Expand Down