{"action":"created","comment":{"url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/comments/152566269","pull_request_review_id":78446069,"id":152566269,"diff_hunk":"@@ -74,8 +74,41 @@ export function fillDefaults(baseModelDefinition) {\n     modelDefinition.ui.instanceLabel = ({ _objectLabel }) => _objectLabel;\n   }\n \n+  if (!permissions || !permissions.crudOperations) { // TODO remove after we create a proper model validator\n+    console.error('permissions.crudOperations must be defined in a crud schema!' + '\\nExample: ' + JSON.stringify({\n+      model: {},\n+      api: {},\n+      ui: {},\n+      permissions: {\n+        crudOperations: {\n+          create: true,\n+          edit: true,\n+          delete: false,\n+          view: true\n+        }\n+      }\n+    }), null, 2);\n+    throw new Error('permissions.crudOperations must be defined in a crud model!');\n+  }\n+\n+  const ops = modelDefinition.permissions.crudOperations;\n+\n+  ['create', 'edit', 'delete', 'view'].forEach(operation => {\n+    if (!ops.hasOwnProperty(operation)) {\n+      ops[operation] = false\n+    }\n+  }\n+  );\n+\n+  const canShowUi = {","path":"src/crudeditor-lib/lib.js","position":39,"original_position":39,"commit_id":"9d48e082dc4565b04ced3e7213e99b83271c4ecb","original_commit_id":"9d48e082dc4565b04ced3e7213e99b83271c4ecb","user":{"login":"estambakio-sc","id":31243790,"avatar_url":"https://avatars0.githubusercontent.com/u/31243790?v=4","gravatar_id":"","url":"https://api.github.com/users/estambakio-sc","html_url":"https://github.com/estambakio-sc","followers_url":"https://api.github.com/users/estambakio-sc/followers","following_url":"https://api.github.com/users/estambakio-sc/following{/other_user}","gists_url":"https://api.github.com/users/estambakio-sc/gists{/gist_id}","starred_url":"https://api.github.com/users/estambakio-sc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estambakio-sc/subscriptions","organizations_url":"https://api.github.com/users/estambakio-sc/orgs","repos_url":"https://api.github.com/users/estambakio-sc/repos","events_url":"https://api.github.com/users/estambakio-sc/events{/privacy}","received_events_url":"https://api.github.com/users/estambakio-sc/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2017-11-22T13:38:47Z","updated_at":"2017-11-22T13:38:47Z","html_url":"https://github.com/OpusCapita/react-crudeditor/pull/50#discussion_r152566269","pull_request_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/comments/152566269"},"html":{"href":"https://github.com/OpusCapita/react-crudeditor/pull/50#discussion_r152566269"},"pull_request":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50"}},"in_reply_to_id":152548944},"pull_request":{"url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50","id":154123141,"html_url":"https://github.com/OpusCapita/react-crudeditor/pull/50","diff_url":"https://github.com/OpusCapita/react-crudeditor/pull/50.diff","patch_url":"https://github.com/OpusCapita/react-crudeditor/pull/50.patch","issue_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/50","number":50,"state":"open","locked":false,"title":"Implemented basic permissions system for crud's schema","user":{"login":"estambakio-sc","id":31243790,"avatar_url":"https://avatars0.githubusercontent.com/u/31243790?v=4","gravatar_id":"","url":"https://api.github.com/users/estambakio-sc","html_url":"https://github.com/estambakio-sc","followers_url":"https://api.github.com/users/estambakio-sc/followers","following_url":"https://api.github.com/users/estambakio-sc/following{/other_user}","gists_url":"https://api.github.com/users/estambakio-sc/gists{/gist_id}","starred_url":"https://api.github.com/users/estambakio-sc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estambakio-sc/subscriptions","organizations_url":"https://api.github.com/users/estambakio-sc/orgs","repos_url":"https://api.github.com/users/estambakio-sc/repos","events_url":"https://api.github.com/users/estambakio-sc/events{/privacy}","received_events_url":"https://api.github.com/users/estambakio-sc/received_events","type":"User","site_admin":false},"body":"Now consumer has to define `permissions` object in crud's schema along with `model`, `api` and `ui`.\r\n\r\nRelated issue: #48\r\n\r\nExample: \r\n```\r\npermissions: {\r\n    crudOperations: {\r\n      create: true,\r\n      edit: true,\r\n      delete: false,\r\n      view: true\r\n    }\r\n  }\r\n```\r\nIf `edit` is `true`, there will be `Edit` button on the Search Listing instead of both `Edit` and `Show`.\r\n\r\nThe same rule applies to all `Delete`-related elements, chopped out if `delete` is `false`.\r\n\r\n`view` should be `true` in order to show Search view or Show view (in case the `edit` is disabled). ","created_at":"2017-11-22T11:03:50Z","updated_at":"2017-11-22T13:38:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6be82063f54ee56b31fdb59ccb709ebb3586841c","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50/commits","review_comments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50/comments","review_comment_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/50/comments","statuses_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/statuses/9d48e082dc4565b04ced3e7213e99b83271c4ecb","head":{"label":"OpusCapita:permissions/48","ref":"permissions/48","sha":"9d48e082dc4565b04ced3e7213e99b83271c4ecb","user":{"login":"OpusCapita","id":23256480,"avatar_url":"https://avatars1.githubusercontent.com/u/23256480?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusCapita","html_url":"https://github.com/OpusCapita","followers_url":"https://api.github.com/users/OpusCapita/followers","following_url":"https://api.github.com/users/OpusCapita/following{/other_user}","gists_url":"https://api.github.com/users/OpusCapita/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusCapita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusCapita/subscriptions","organizations_url":"https://api.github.com/users/OpusCapita/orgs","repos_url":"https://api.github.com/users/OpusCapita/repos","events_url":"https://api.github.com/users/OpusCapita/events{/privacy}","received_events_url":"https://api.github.com/users/OpusCapita/received_events","type":"Organization","site_admin":false},"repo":{"id":94513446,"name":"react-crudeditor","full_name":"OpusCapita/react-crudeditor","owner":{"login":"OpusCapita","id":23256480,"avatar_url":"https://avatars1.githubusercontent.com/u/23256480?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusCapita","html_url":"https://github.com/OpusCapita","followers_url":"https://api.github.com/users/OpusCapita/followers","following_url":"https://api.github.com/users/OpusCapita/following{/other_user}","gists_url":"https://api.github.com/users/OpusCapita/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusCapita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusCapita/subscriptions","organizations_url":"https://api.github.com/users/OpusCapita/orgs","repos_url":"https://api.github.com/users/OpusCapita/repos","events_url":"https://api.github.com/users/OpusCapita/events{/privacy}","received_events_url":"https://api.github.com/users/OpusCapita/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpusCapita/react-crudeditor","description":"OpusCapita React CRUD Editor","fork":false,"url":"https://api.github.com/repos/OpusCapita/react-crudeditor","forks_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/forks","keys_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/teams","hooks_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/hooks","issue_events_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/events{/number}","events_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/events","assignees_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/assignees{/user}","branches_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/branches{/branch}","tags_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/tags","blobs_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/statuses/{sha}","languages_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/languages","stargazers_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/stargazers","contributors_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/contributors","subscribers_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/subscribers","subscription_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/subscription","commits_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/contents/{+path}","compare_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/merges","archive_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/downloads","issues_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues{/number}","pulls_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls{/number}","milestones_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/milestones{/number}","notifications_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/labels{/name}","releases_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/releases{/id}","deployments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/deployments","created_at":"2017-06-16T06:38:51Z","updated_at":"2017-11-16T19:04:10Z","pushed_at":"2017-11-22T13:17:18Z","git_url":"git://github.com/OpusCapita/react-crudeditor.git","ssh_url":"git@github.com:OpusCapita/react-crudeditor.git","clone_url":"https://github.com/OpusCapita/react-crudeditor.git","svn_url":"https://github.com/OpusCapita/react-crudeditor","homepage":"","size":28580,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":3,"default_branch":"master"}},"base":{"label":"OpusCapita:master","ref":"master","sha":"648a4cbd779f4539948e909c77c1f60901979295","user":{"login":"OpusCapita","id":23256480,"avatar_url":"https://avatars1.githubusercontent.com/u/23256480?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusCapita","html_url":"https://github.com/OpusCapita","followers_url":"https://api.github.com/users/OpusCapita/followers","following_url":"https://api.github.com/users/OpusCapita/following{/other_user}","gists_url":"https://api.github.com/users/OpusCapita/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusCapita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusCapita/subscriptions","organizations_url":"https://api.github.com/users/OpusCapita/orgs","repos_url":"https://api.github.com/users/OpusCapita/repos","events_url":"https://api.github.com/users/OpusCapita/events{/privacy}","received_events_url":"https://api.github.com/users/OpusCapita/received_events","type":"Organization","site_admin":false},"repo":{"id":94513446,"name":"react-crudeditor","full_name":"OpusCapita/react-crudeditor","owner":{"login":"OpusCapita","id":23256480,"avatar_url":"https://avatars1.githubusercontent.com/u/23256480?v=4","gravatar_id":"","url":"https://api.github.com/users/OpusCapita","html_url":"https://github.com/OpusCapita","followers_url":"https://api.github.com/users/OpusCapita/followers","following_url":"https://api.github.com/users/OpusCapita/following{/other_user}","gists_url":"https://api.github.com/users/OpusCapita/gists{/gist_id}","starred_url":"https://api.github.com/users/OpusCapita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpusCapita/subscriptions","organizations_url":"https://api.github.com/users/OpusCapita/orgs","repos_url":"https://api.github.com/users/OpusCapita/repos","events_url":"https://api.github.com/users/OpusCapita/events{/privacy}","received_events_url":"https://api.github.com/users/OpusCapita/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpusCapita/react-crudeditor","description":"OpusCapita React CRUD Editor","fork":false,"url":"https://api.github.com/repos/OpusCapita/react-crudeditor","forks_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/forks","keys_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/teams","hooks_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/hooks","issue_events_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/events{/number}","events_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/events","assignees_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/assignees{/user}","branches_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/branches{/branch}","tags_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/tags","blobs_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/statuses/{sha}","languages_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/languages","stargazers_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/stargazers","contributors_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/contributors","subscribers_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/subscribers","subscription_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/subscription","commits_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/contents/{+path}","compare_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/merges","archive_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/downloads","issues_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues{/number}","pulls_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls{/number}","milestones_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/milestones{/number}","notifications_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/labels{/name}","releases_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/releases{/id}","deployments_url":"https://api.github.com/repos/OpusCapita/react-crudeditor/deployments","created_at":"2017-06-16T06:38:51Z","updated_at":"2017-11-16T19:04:10Z","pushed_at":"2017-11-22T13:17:18Z","git_url":"git://github.com/OpusCapita/react-crudeditor.git","ssh_url":"git@github.com:OpusCapita/react-crudeditor.git","clone_url":"https://github.com/OpusCapita/react-crudeditor.git","svn_url":"https://github.com/OpusCapita/react-crudeditor","homepage":"","size":28580,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50"},"html":{"href":"https://github.com/OpusCapita/react-crudeditor/pull/50"},"issue":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/50"},"comments":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/OpusCapita/react-crudeditor/statuses/9d48e082dc4565b04ced3e7213e99b83271c4ecb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"estambakio-sc"}}