{"action":"created","comment":{"url":"https://api.github.com/repos/exhi/hoist-react/pulls/comments/222485159","pull_request_review_id":161382374,"id":222485159,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjQ4NTE1OQ==","diff_hunk":"@@ -71,14 +85,56 @@ export class RecordAction {\n         this.hidden = hidden;\n         this.prepareFn = prepareFn;\n         this.recordsRequired = recordsRequired;\n+        this.confirm = confirm;\n+    }\n+\n+    meetsRecordRequirement(count) {\n+        const required = this.recordsRequired;\n+        return isNil(required) ||\n+            (isBoolean(required) && (!required || required && count > 0)) ||\n+            (isNumber(required) && count === required);\n+    }\n+\n+    async executeAsync({record, selModel, metadata}) {\n+        const {confirm} = this;\n+        let promise;\n+        if (confirm) {\n+            const {text, intent} = this;\n+            const cfg = {\n+                title: !isEmpty(text) ? `${text}?` : 'Proceed?',\n+                confirmText: !isEmpty(text) ? text : 'Proceed',\n+                confirmIntent: intent\n+            };\n+\n+            if (isObject(confirm)) {\n+                Object.assign(cfg, confirm);\n+            } else if (isString(confirm)) {\n+                cfg.message = confirm;\n+            } else if (!isEmpty(text)) {\n+                cfg.message = `Are you sure you want to ${text.toLowerCase()} the record?`;\n+            } else {\n+                cfg.message = 'Are you sure you want to proceed?';\n+            }\n+\n+            promise = XH.confirm(cfg);\n+        } else {\n+            promise = resolve(true);\n+        }\n+\n+        const confirmed = await promise;\n+        if (!confirmed) return;\n+\n+        this.actionFn({action: this, record, selModel, metadata});\n     }\n }\n \n /**\n  * @callback ActionCb - called when the action's UI element is clicked or otherwise triggered.","path":"data/RecordAction.js","position":85,"original_position":85,"commit_id":"926ff7e32603c4e16a60b8d64a785c7ef0064319","original_commit_id":"926ff7e32603c4e16a60b8d64a785c7ef0064319","user":{"login":"lbwexler","id":2307561,"node_id":"MDQ6VXNlcjIzMDc1NjE=","avatar_url":"https://avatars2.githubusercontent.com/u/2307561?v=4","gravatar_id":"","url":"https://api.github.com/users/lbwexler","html_url":"https://github.com/lbwexler","followers_url":"https://api.github.com/users/lbwexler/followers","following_url":"https://api.github.com/users/lbwexler/following{/other_user}","gists_url":"https://api.github.com/users/lbwexler/gists{/gist_id}","starred_url":"https://api.github.com/users/lbwexler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbwexler/subscriptions","organizations_url":"https://api.github.com/users/lbwexler/orgs","repos_url":"https://api.github.com/users/lbwexler/repos","events_url":"https://api.github.com/users/lbwexler/events{/privacy}","received_events_url":"https://api.github.com/users/lbwexler/received_events","type":"User","site_admin":false},"body":"would now be the time to consider simplifying this by just having a single bundle of records rather than 'record' and 'selection'.  Do we ever need to know what the primary record clicked on is?  If we did, could that be buried in the 'p.metadata'.?   Would any action operate on both the primary record and the selection?  Mostly thinking outloud here","created_at":"2018-10-03T22:15:09Z","updated_at":"2018-10-03T22:37:01Z","html_url":"https://github.com/exhi/hoist-react/pull/684#discussion_r222485159","pull_request_url":"https://api.github.com/repos/exhi/hoist-react/pulls/684","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/comments/222485159"},"html":{"href":"https://github.com/exhi/hoist-react/pull/684#discussion_r222485159"},"pull_request":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/684"}}},"pull_request":{"url":"https://api.github.com/repos/exhi/hoist-react/pulls/684","id":220091636,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwMDkxNjM2","html_url":"https://github.com/exhi/hoist-react/pull/684","diff_url":"https://github.com/exhi/hoist-react/pull/684.diff","patch_url":"https://github.com/exhi/hoist-react/pull/684.patch","issue_url":"https://api.github.com/repos/exhi/hoist-react/issues/684","number":684,"state":"open","locked":false,"title":"Record action refactor","user":{"login":"haynesjm42","id":9619538,"node_id":"MDQ6VXNlcjk2MTk1Mzg=","avatar_url":"https://avatars1.githubusercontent.com/u/9619538?v=4","gravatar_id":"","url":"https://api.github.com/users/haynesjm42","html_url":"https://github.com/haynesjm42","followers_url":"https://api.github.com/users/haynesjm42/followers","following_url":"https://api.github.com/users/haynesjm42/following{/other_user}","gists_url":"https://api.github.com/users/haynesjm42/gists{/gist_id}","starred_url":"https://api.github.com/users/haynesjm42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haynesjm42/subscriptions","organizations_url":"https://api.github.com/users/haynesjm42/orgs","repos_url":"https://api.github.com/users/haynesjm42/repos","events_url":"https://api.github.com/users/haynesjm42/events{/privacy}","received_events_url":"https://api.github.com/users/haynesjm42/received_events","type":"User","site_admin":false},"body":"Refactoring of RecordAction and the RestGrid APIs for configuring the \"actions\" which are enabled. Would like to get some eye son it before continuing with cleaning up the docs/etc. to make sure these changes seem worthwhile.\r\n\r\nOverview of changes:\r\n* RecordAction `actionFn` and `prepareFn` now take a single object as their param, instead of separate params\r\n* RecordActions can not be configured with confirmation prompts which must be accepted before calling `actionFn`\r\n* RecordAction \"containers\" (GridModel, RestGridModel, RecordActionBar, etc) now maintain metadata which will be passed through to the RecordAction callbacks. This allows the `actionFn` and `prepareFn` access to the data they need, which would previously have been the `this` where the action was defined. This enables building a library of reusable action definitions similar to columns.\r\n* RecordActionBar now has additional props for controlling the rendering of the buttons (now RecordActionButton), effectively a wrapper around ButtonGroup\r\n* RestGridModel now takes `toolbarActions`, `contextMenuActions`, and `formToolbarActions` instead of the old `actionEnabled` flags. `actionWarning` has been removed in favor of building the confirm prompts into the RecordActions.\r\n* RestGridToolbar and RestGridForm now use a RecordActionBar for the action buttons\r\n* RestForm now supports a read-only \"view\" mode. Previously there was logic which would remove the Save button if the form was open but the add or edit actions were disabled, thought this made more sense and didn't have a way of maintaining the old behavior.\r\n\r\nThe aspect of these changes I am most unsure about is the mechanism I am using to pass the metadata through to the actions. What I am doing works pretty well, but I can't help but feel that it is a little hacky and I worry about the chains of passing the metadata through to the actions breaking. I haven't been able to think up an alternate solution so far...\r\n\r\nThere is one change in behavior with these changes, regarding the action confirmations. In the Admin app Preferences and Config tabs, there were confirm prompts for adding/saving warning about breaking running apps. These used to occur when clicking the Save button in the RestForm, but will now occur when clicking the Add or Edit buttons (when the action is triggered). I think this is fine, but if we want to restore the old functionality will need to figure out an api for configuring that prompt, RestForm will probably need a reference to the RecordAction which opened it or something.\r\n\r\nSee https://github.com/exhi/toolbox/tree/recordActionRefactor for associated toolbox changes","created_at":"2018-10-03T15:58:44Z","updated_at":"2018-10-03T22:37:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d512a892cea4182054f2406f02ca3e14355b7087","assignee":null,"assignees":[],"requested_reviewers":[{"login":"amcclain","id":225806,"node_id":"MDQ6VXNlcjIyNTgwNg==","avatar_url":"https://avatars3.githubusercontent.com/u/225806?v=4","gravatar_id":"","url":"https://api.github.com/users/amcclain","html_url":"https://github.com/amcclain","followers_url":"https://api.github.com/users/amcclain/followers","following_url":"https://api.github.com/users/amcclain/following{/other_user}","gists_url":"https://api.github.com/users/amcclain/gists{/gist_id}","starred_url":"https://api.github.com/users/amcclain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcclain/subscriptions","organizations_url":"https://api.github.com/users/amcclain/orgs","repos_url":"https://api.github.com/users/amcclain/repos","events_url":"https://api.github.com/users/amcclain/events{/privacy}","received_events_url":"https://api.github.com/users/amcclain/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":970308892,"node_id":"MDU6TGFiZWw5NzAzMDg4OTI=","url":"https://api.github.com/repos/exhi/hoist-react/labels/wip","name":"wip","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/exhi/hoist-react/pulls/684/commits","review_comments_url":"https://api.github.com/repos/exhi/hoist-react/pulls/684/comments","review_comment_url":"https://api.github.com/repos/exhi/hoist-react/pulls/comments{/number}","comments_url":"https://api.github.com/repos/exhi/hoist-react/issues/684/comments","statuses_url":"https://api.github.com/repos/exhi/hoist-react/statuses/926ff7e32603c4e16a60b8d64a785c7ef0064319","head":{"label":"exhi:recordActionRefactor","ref":"recordActionRefactor","sha":"926ff7e32603c4e16a60b8d64a785c7ef0064319","user":{"login":"exhi","id":850311,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1MDMxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/850311?v=4","gravatar_id":"","url":"https://api.github.com/users/exhi","html_url":"https://github.com/exhi","followers_url":"https://api.github.com/users/exhi/followers","following_url":"https://api.github.com/users/exhi/following{/other_user}","gists_url":"https://api.github.com/users/exhi/gists{/gist_id}","starred_url":"https://api.github.com/users/exhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exhi/subscriptions","organizations_url":"https://api.github.com/users/exhi/orgs","repos_url":"https://api.github.com/users/exhi/repos","events_url":"https://api.github.com/users/exhi/events{/privacy}","received_events_url":"https://api.github.com/users/exhi/received_events","type":"Organization","site_admin":false},"repo":{"id":117733567,"node_id":"MDEwOlJlcG9zaXRvcnkxMTc3MzM1Njc=","name":"hoist-react","full_name":"exhi/hoist-react","private":false,"owner":{"login":"exhi","id":850311,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1MDMxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/850311?v=4","gravatar_id":"","url":"https://api.github.com/users/exhi","html_url":"https://github.com/exhi","followers_url":"https://api.github.com/users/exhi/followers","following_url":"https://api.github.com/users/exhi/following{/other_user}","gists_url":"https://api.github.com/users/exhi/gists{/gist_id}","starred_url":"https://api.github.com/users/exhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exhi/subscriptions","organizations_url":"https://api.github.com/users/exhi/orgs","repos_url":"https://api.github.com/users/exhi/repos","events_url":"https://api.github.com/users/exhi/events{/privacy}","received_events_url":"https://api.github.com/users/exhi/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/exhi/hoist-react","description":"🏗️ ⚛️ Hoist toolkit for building React applications.","fork":false,"url":"https://api.github.com/repos/exhi/hoist-react","forks_url":"https://api.github.com/repos/exhi/hoist-react/forks","keys_url":"https://api.github.com/repos/exhi/hoist-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exhi/hoist-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exhi/hoist-react/teams","hooks_url":"https://api.github.com/repos/exhi/hoist-react/hooks","issue_events_url":"https://api.github.com/repos/exhi/hoist-react/issues/events{/number}","events_url":"https://api.github.com/repos/exhi/hoist-react/events","assignees_url":"https://api.github.com/repos/exhi/hoist-react/assignees{/user}","branches_url":"https://api.github.com/repos/exhi/hoist-react/branches{/branch}","tags_url":"https://api.github.com/repos/exhi/hoist-react/tags","blobs_url":"https://api.github.com/repos/exhi/hoist-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exhi/hoist-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exhi/hoist-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/exhi/hoist-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exhi/hoist-react/statuses/{sha}","languages_url":"https://api.github.com/repos/exhi/hoist-react/languages","stargazers_url":"https://api.github.com/repos/exhi/hoist-react/stargazers","contributors_url":"https://api.github.com/repos/exhi/hoist-react/contributors","subscribers_url":"https://api.github.com/repos/exhi/hoist-react/subscribers","subscription_url":"https://api.github.com/repos/exhi/hoist-react/subscription","commits_url":"https://api.github.com/repos/exhi/hoist-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/exhi/hoist-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/exhi/hoist-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/exhi/hoist-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/exhi/hoist-react/contents/{+path}","compare_url":"https://api.github.com/repos/exhi/hoist-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exhi/hoist-react/merges","archive_url":"https://api.github.com/repos/exhi/hoist-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exhi/hoist-react/downloads","issues_url":"https://api.github.com/repos/exhi/hoist-react/issues{/number}","pulls_url":"https://api.github.com/repos/exhi/hoist-react/pulls{/number}","milestones_url":"https://api.github.com/repos/exhi/hoist-react/milestones{/number}","notifications_url":"https://api.github.com/repos/exhi/hoist-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exhi/hoist-react/labels{/name}","releases_url":"https://api.github.com/repos/exhi/hoist-react/releases{/id}","deployments_url":"https://api.github.com/repos/exhi/hoist-react/deployments","created_at":"2018-01-16T19:50:49Z","updated_at":"2018-10-03T20:18:46Z","pushed_at":"2018-10-03T22:20:43Z","git_url":"git://github.com/exhi/hoist-react.git","ssh_url":"git@github.com:exhi/hoist-react.git","clone_url":"https://github.com/exhi/hoist-react.git","svn_url":"https://github.com/exhi/hoist-react","homepage":"https://xh.io","size":2312,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":40,"watchers":3,"default_branch":"develop"}},"base":{"label":"exhi:develop","ref":"develop","sha":"90802df1ceae804e428b0a92b287d7053805617b","user":{"login":"exhi","id":850311,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1MDMxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/850311?v=4","gravatar_id":"","url":"https://api.github.com/users/exhi","html_url":"https://github.com/exhi","followers_url":"https://api.github.com/users/exhi/followers","following_url":"https://api.github.com/users/exhi/following{/other_user}","gists_url":"https://api.github.com/users/exhi/gists{/gist_id}","starred_url":"https://api.github.com/users/exhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exhi/subscriptions","organizations_url":"https://api.github.com/users/exhi/orgs","repos_url":"https://api.github.com/users/exhi/repos","events_url":"https://api.github.com/users/exhi/events{/privacy}","received_events_url":"https://api.github.com/users/exhi/received_events","type":"Organization","site_admin":false},"repo":{"id":117733567,"node_id":"MDEwOlJlcG9zaXRvcnkxMTc3MzM1Njc=","name":"hoist-react","full_name":"exhi/hoist-react","private":false,"owner":{"login":"exhi","id":850311,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1MDMxMQ==","avatar_url":"https://avatars0.githubusercontent.com/u/850311?v=4","gravatar_id":"","url":"https://api.github.com/users/exhi","html_url":"https://github.com/exhi","followers_url":"https://api.github.com/users/exhi/followers","following_url":"https://api.github.com/users/exhi/following{/other_user}","gists_url":"https://api.github.com/users/exhi/gists{/gist_id}","starred_url":"https://api.github.com/users/exhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exhi/subscriptions","organizations_url":"https://api.github.com/users/exhi/orgs","repos_url":"https://api.github.com/users/exhi/repos","events_url":"https://api.github.com/users/exhi/events{/privacy}","received_events_url":"https://api.github.com/users/exhi/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/exhi/hoist-react","description":"🏗️ ⚛️ Hoist toolkit for building React applications.","fork":false,"url":"https://api.github.com/repos/exhi/hoist-react","forks_url":"https://api.github.com/repos/exhi/hoist-react/forks","keys_url":"https://api.github.com/repos/exhi/hoist-react/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exhi/hoist-react/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exhi/hoist-react/teams","hooks_url":"https://api.github.com/repos/exhi/hoist-react/hooks","issue_events_url":"https://api.github.com/repos/exhi/hoist-react/issues/events{/number}","events_url":"https://api.github.com/repos/exhi/hoist-react/events","assignees_url":"https://api.github.com/repos/exhi/hoist-react/assignees{/user}","branches_url":"https://api.github.com/repos/exhi/hoist-react/branches{/branch}","tags_url":"https://api.github.com/repos/exhi/hoist-react/tags","blobs_url":"https://api.github.com/repos/exhi/hoist-react/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exhi/hoist-react/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exhi/hoist-react/git/refs{/sha}","trees_url":"https://api.github.com/repos/exhi/hoist-react/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exhi/hoist-react/statuses/{sha}","languages_url":"https://api.github.com/repos/exhi/hoist-react/languages","stargazers_url":"https://api.github.com/repos/exhi/hoist-react/stargazers","contributors_url":"https://api.github.com/repos/exhi/hoist-react/contributors","subscribers_url":"https://api.github.com/repos/exhi/hoist-react/subscribers","subscription_url":"https://api.github.com/repos/exhi/hoist-react/subscription","commits_url":"https://api.github.com/repos/exhi/hoist-react/commits{/sha}","git_commits_url":"https://api.github.com/repos/exhi/hoist-react/git/commits{/sha}","comments_url":"https://api.github.com/repos/exhi/hoist-react/comments{/number}","issue_comment_url":"https://api.github.com/repos/exhi/hoist-react/issues/comments{/number}","contents_url":"https://api.github.com/repos/exhi/hoist-react/contents/{+path}","compare_url":"https://api.github.com/repos/exhi/hoist-react/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exhi/hoist-react/merges","archive_url":"https://api.github.com/repos/exhi/hoist-react/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exhi/hoist-react/downloads","issues_url":"https://api.github.com/repos/exhi/hoist-react/issues{/number}","pulls_url":"https://api.github.com/repos/exhi/hoist-react/pulls{/number}","milestones_url":"https://api.github.com/repos/exhi/hoist-react/milestones{/number}","notifications_url":"https://api.github.com/repos/exhi/hoist-react/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exhi/hoist-react/labels{/name}","releases_url":"https://api.github.com/repos/exhi/hoist-react/releases{/id}","deployments_url":"https://api.github.com/repos/exhi/hoist-react/deployments","created_at":"2018-01-16T19:50:49Z","updated_at":"2018-10-03T20:18:46Z","pushed_at":"2018-10-03T22:20:43Z","git_url":"git://github.com/exhi/hoist-react.git","ssh_url":"git@github.com:exhi/hoist-react.git","clone_url":"https://github.com/exhi/hoist-react.git","svn_url":"https://github.com/exhi/hoist-react","homepage":"https://xh.io","size":2312,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":40,"watchers":3,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/684"},"html":{"href":"https://github.com/exhi/hoist-react/pull/684"},"issue":{"href":"https://api.github.com/repos/exhi/hoist-react/issues/684"},"comments":{"href":"https://api.github.com/repos/exhi/hoist-react/issues/684/comments"},"review_comments":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/684/comments"},"review_comment":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/exhi/hoist-react/pulls/684/commits"},"statuses":{"href":"https://api.github.com/repos/exhi/hoist-react/statuses/926ff7e32603c4e16a60b8d64a785c7ef0064319"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"lbwexler"}}