{"action":"created","comment":{"url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments/174376972","pull_request_review_id":103708575,"id":174376972,"diff_hunk":"@@ -0,0 +1,265 @@\n+/* jshint esversion: 6 */\n+\n+/*\n+ * This file is part of Cockpit.\n+ *\n+ * Copyright (C) 2018 Red Hat, Inc.\n+ *\n+ * Cockpit is free software; you can redistribute it and/or modify it\n+ * under the terms of the GNU Lesser General Public License as published by\n+ * the Free Software Foundation; either version 2.1 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * Cockpit is distributed in the hope that it will be useful, but\n+ * WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public License\n+ * along with Cockpit; If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+import cockpit from \"cockpit\";\n+import React from \"react\";\n+import firewall from \"./firewall-client.es6\";\n+import { Listing, ListingRow } from \"cockpit-components-listing.jsx\";\n+import { OnOffSwitch } from \"cockpit-components-onoff.jsx\";\n+import { show_modal_dialog } from \"cockpit-components-dialog.jsx\";\n+\n+import \"table.css\";\n+import \"./networking.css\";\n+\n+var _ = cockpit.gettext;\n+\n+require(\"page.css\");\n+\n+function EmptyState(props) {\n+    return (\n+        <div className=\"curtains-ct blank-slate-pf\">\n+            {props.icon && <div className=\"blank-slate-pf-icon\"><div className={props.icon}></div></div>}\n+            <h1>{props.title}</h1>\n+            {props.children}\n+        </div>\n+    );\n+}\n+\n+function ServiceRow(props) {\n+    if (!props.service.name)\n+        return <ListingRow key={props.service.id}\n+                           columns={[\"\", \"\", \"\"]} />\n+\n+    var tcp = props.service.ports.filter(p => p.protocol.toUpperCase() == 'TCP');\n+    var udp = props.service.ports.filter(p => p.protocol.toUpperCase() == 'UDP');\n+\n+    function onRemoveService(event) {\n+        if (event.button !== 0)\n+            return;\n+\n+        props.onRemoveService(props.service.id);\n+        event.stopPropagation();\n+    }\n+\n+    var columns = [\n+        { name: props.service.name, header: true },\n+        <div>\n+            { tcp.map(p => p.port).join(', ') }\n+        </div>,\n+        <div>\n+            { udp.map(p => p.port).join(', ') }\n+        </div>,\n+        <button className=\"btn btn-danger pficon pficon-delete\"\n+                onClick={onRemoveService}/>\n+    ];\n+\n+    var tabs = [\n+        { name: _(\"Details\"), renderer: () => <p>{props.service.description}</p> }\n+    ];\n+\n+    return <ListingRow key={props.service.id}\n+                       rowId={props.service.id}\n+                       columns={columns}\n+                       tabRenderers={tabs}/>;\n+}\n+\n+class AddServicesDialogBody extends React.Component {\n+    constructor() {\n+        super();\n+\n+        this.state = {\n+            selected: new Set()\n+        };\n+\n+        this.onToggleService = this.onToggleService.bind(this);\n+    }\n+\n+    componentDidMount() {\n+        firewall.getAvailableServices()\n+            .then(services => this.setState({ services: services }));\n+    }\n+\n+    onToggleService(event) {\n+        var service = event.target.id;\n+        var enabled = event.target.checked;\n+\n+        this.setState(oldState => {\n+            var selected = new Set(oldState.selected);","path":"pkg/networkmanager/firewall.jsx","position":105,"original_position":105,"commit_id":"b3f14bd53ba44414cb77ba344ac4df6de1f9a4a1","original_commit_id":"b3f14bd53ba44414cb77ba344ac4df6de1f9a4a1","user":{"login":"martinpitt","id":200109,"avatar_url":"https://avatars3.githubusercontent.com/u/200109?v=4","gravatar_id":"","url":"https://api.github.com/users/martinpitt","html_url":"https://github.com/martinpitt","followers_url":"https://api.github.com/users/martinpitt/followers","following_url":"https://api.github.com/users/martinpitt/following{/other_user}","gists_url":"https://api.github.com/users/martinpitt/gists{/gist_id}","starred_url":"https://api.github.com/users/martinpitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinpitt/subscriptions","organizations_url":"https://api.github.com/users/martinpitt/orgs","repos_url":"https://api.github.com/users/martinpitt/repos","events_url":"https://api.github.com/users/martinpitt/events{/privacy}","received_events_url":"https://api.github.com/users/martinpitt/received_events","type":"User","site_admin":false},"body":"Whee, functional `setState()` - I've learned something new today :+1: \r\n\r\nPlease use `let` in arrow functions for correct scoping.","created_at":"2018-03-14T08:04:11Z","updated_at":"2018-03-14T08:46:59Z","html_url":"https://github.com/cockpit-project/cockpit/pull/8032#discussion_r174376972","pull_request_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments/174376972"},"html":{"href":"https://github.com/cockpit-project/cockpit/pull/8032#discussion_r174376972"},"pull_request":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032"}}},"pull_request":{"url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032","id":150703290,"html_url":"https://github.com/cockpit-project/cockpit/pull/8032","diff_url":"https://github.com/cockpit-project/cockpit/pull/8032.diff","patch_url":"https://github.com/cockpit-project/cockpit/pull/8032.patch","issue_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/8032","number":8032,"state":"open","locked":false,"title":"Add firewall section to the networking page","user":{"login":"larskarlitski","id":1221707,"avatar_url":"https://avatars0.githubusercontent.com/u/1221707?v=4","gravatar_id":"","url":"https://api.github.com/users/larskarlitski","html_url":"https://github.com/larskarlitski","followers_url":"https://api.github.com/users/larskarlitski/followers","following_url":"https://api.github.com/users/larskarlitski/following{/other_user}","gists_url":"https://api.github.com/users/larskarlitski/gists{/gist_id}","starred_url":"https://api.github.com/users/larskarlitski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larskarlitski/subscriptions","organizations_url":"https://api.github.com/users/larskarlitski/orgs","repos_url":"https://api.github.com/users/larskarlitski/repos","events_url":"https://api.github.com/users/larskarlitski/events{/privacy}","received_events_url":"https://api.github.com/users/larskarlitski/received_events","type":"User","site_admin":false},"body":"First look at a what a firewall module might look like.\r\n\r\nIt operates on firewalld's default zone and there are no plans to expose zones, as they don't seem to be used very often on servers.\r\n\r\nThe delete buttons don't work yet, but the UI updates itself when adding and removing services from the default zone with one of:\r\n```\r\nsudo firewallctl zone '' remove service ssh\r\nsudo firewallctl zone '' add service ssh\r\n``` \r\n\r\n![firewall](https://user-images.githubusercontent.com/1221707/32411073-f94cb802-c1d1-11e7-80aa-d9d0226b5243.png)\r\n\r\nThis will implement the minimal version of the design and iterate in later pull requests.\r\n\r\n- [x] show the firewall section on the default page when firewalld is installed\r\n- [x] show the list of services that are currently active\r\n- [x] allow to remove a service\r\n- [x] allow to add one of firewalld's predefined services\r\n- [ ] tests\r\n- [ ] add doc/guide page\r\n- [ ] feature video for release notes","created_at":"2017-11-05T01:40:06Z","updated_at":"2018-03-14T08:46:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf17439da011eec18a48a9e81caf0ee8bc086446","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032/commits","review_comments_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032/comments","review_comment_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/8032/comments","statuses_url":"https://api.github.com/repos/cockpit-project/cockpit/statuses/b3f14bd53ba44414cb77ba344ac4df6de1f9a4a1","head":{"label":"larskarlitski:firewall","ref":"firewall","sha":"b3f14bd53ba44414cb77ba344ac4df6de1f9a4a1","user":{"login":"larskarlitski","id":1221707,"avatar_url":"https://avatars0.githubusercontent.com/u/1221707?v=4","gravatar_id":"","url":"https://api.github.com/users/larskarlitski","html_url":"https://github.com/larskarlitski","followers_url":"https://api.github.com/users/larskarlitski/followers","following_url":"https://api.github.com/users/larskarlitski/following{/other_user}","gists_url":"https://api.github.com/users/larskarlitski/gists{/gist_id}","starred_url":"https://api.github.com/users/larskarlitski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larskarlitski/subscriptions","organizations_url":"https://api.github.com/users/larskarlitski/orgs","repos_url":"https://api.github.com/users/larskarlitski/repos","events_url":"https://api.github.com/users/larskarlitski/events{/privacy}","received_events_url":"https://api.github.com/users/larskarlitski/received_events","type":"User","site_admin":false},"repo":{"id":52787188,"name":"cockpit","full_name":"larskarlitski/cockpit","owner":{"login":"larskarlitski","id":1221707,"avatar_url":"https://avatars0.githubusercontent.com/u/1221707?v=4","gravatar_id":"","url":"https://api.github.com/users/larskarlitski","html_url":"https://github.com/larskarlitski","followers_url":"https://api.github.com/users/larskarlitski/followers","following_url":"https://api.github.com/users/larskarlitski/following{/other_user}","gists_url":"https://api.github.com/users/larskarlitski/gists{/gist_id}","starred_url":"https://api.github.com/users/larskarlitski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larskarlitski/subscriptions","organizations_url":"https://api.github.com/users/larskarlitski/orgs","repos_url":"https://api.github.com/users/larskarlitski/repos","events_url":"https://api.github.com/users/larskarlitski/events{/privacy}","received_events_url":"https://api.github.com/users/larskarlitski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/larskarlitski/cockpit","description":"Cockpit, a user interface for Linux servers","fork":true,"url":"https://api.github.com/repos/larskarlitski/cockpit","forks_url":"https://api.github.com/repos/larskarlitski/cockpit/forks","keys_url":"https://api.github.com/repos/larskarlitski/cockpit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/larskarlitski/cockpit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/larskarlitski/cockpit/teams","hooks_url":"https://api.github.com/repos/larskarlitski/cockpit/hooks","issue_events_url":"https://api.github.com/repos/larskarlitski/cockpit/issues/events{/number}","events_url":"https://api.github.com/repos/larskarlitski/cockpit/events","assignees_url":"https://api.github.com/repos/larskarlitski/cockpit/assignees{/user}","branches_url":"https://api.github.com/repos/larskarlitski/cockpit/branches{/branch}","tags_url":"https://api.github.com/repos/larskarlitski/cockpit/tags","blobs_url":"https://api.github.com/repos/larskarlitski/cockpit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/larskarlitski/cockpit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/larskarlitski/cockpit/git/refs{/sha}","trees_url":"https://api.github.com/repos/larskarlitski/cockpit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/larskarlitski/cockpit/statuses/{sha}","languages_url":"https://api.github.com/repos/larskarlitski/cockpit/languages","stargazers_url":"https://api.github.com/repos/larskarlitski/cockpit/stargazers","contributors_url":"https://api.github.com/repos/larskarlitski/cockpit/contributors","subscribers_url":"https://api.github.com/repos/larskarlitski/cockpit/subscribers","subscription_url":"https://api.github.com/repos/larskarlitski/cockpit/subscription","commits_url":"https://api.github.com/repos/larskarlitski/cockpit/commits{/sha}","git_commits_url":"https://api.github.com/repos/larskarlitski/cockpit/git/commits{/sha}","comments_url":"https://api.github.com/repos/larskarlitski/cockpit/comments{/number}","issue_comment_url":"https://api.github.com/repos/larskarlitski/cockpit/issues/comments{/number}","contents_url":"https://api.github.com/repos/larskarlitski/cockpit/contents/{+path}","compare_url":"https://api.github.com/repos/larskarlitski/cockpit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/larskarlitski/cockpit/merges","archive_url":"https://api.github.com/repos/larskarlitski/cockpit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/larskarlitski/cockpit/downloads","issues_url":"https://api.github.com/repos/larskarlitski/cockpit/issues{/number}","pulls_url":"https://api.github.com/repos/larskarlitski/cockpit/pulls{/number}","milestones_url":"https://api.github.com/repos/larskarlitski/cockpit/milestones{/number}","notifications_url":"https://api.github.com/repos/larskarlitski/cockpit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/larskarlitski/cockpit/labels{/name}","releases_url":"https://api.github.com/repos/larskarlitski/cockpit/releases{/id}","deployments_url":"https://api.github.com/repos/larskarlitski/cockpit/deployments","created_at":"2016-02-29T11:47:08Z","updated_at":"2016-06-29T08:10:52Z","pushed_at":"2018-03-12T21:14:04Z","git_url":"git://github.com/larskarlitski/cockpit.git","ssh_url":"git@github.com:larskarlitski/cockpit.git","clone_url":"https://github.com/larskarlitski/cockpit.git","svn_url":"https://github.com/larskarlitski/cockpit","homepage":"http://www.cockpit-project.org/","size":44847,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockpit-project:master","ref":"master","sha":"fe326160e05c24c06931d2fc58924cf5357a38b8","user":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars2.githubusercontent.com/u/5765104?v=4","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"repo":{"id":14049216,"name":"cockpit","full_name":"cockpit-project/cockpit","owner":{"login":"cockpit-project","id":5765104,"avatar_url":"https://avatars2.githubusercontent.com/u/5765104?v=4","gravatar_id":"","url":"https://api.github.com/users/cockpit-project","html_url":"https://github.com/cockpit-project","followers_url":"https://api.github.com/users/cockpit-project/followers","following_url":"https://api.github.com/users/cockpit-project/following{/other_user}","gists_url":"https://api.github.com/users/cockpit-project/gists{/gist_id}","starred_url":"https://api.github.com/users/cockpit-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockpit-project/subscriptions","organizations_url":"https://api.github.com/users/cockpit-project/orgs","repos_url":"https://api.github.com/users/cockpit-project/repos","events_url":"https://api.github.com/users/cockpit-project/events{/privacy}","received_events_url":"https://api.github.com/users/cockpit-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockpit-project/cockpit","description":"There's code a goin' on","fork":false,"url":"https://api.github.com/repos/cockpit-project/cockpit","forks_url":"https://api.github.com/repos/cockpit-project/cockpit/forks","keys_url":"https://api.github.com/repos/cockpit-project/cockpit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockpit-project/cockpit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockpit-project/cockpit/teams","hooks_url":"https://api.github.com/repos/cockpit-project/cockpit/hooks","issue_events_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/events{/number}","events_url":"https://api.github.com/repos/cockpit-project/cockpit/events","assignees_url":"https://api.github.com/repos/cockpit-project/cockpit/assignees{/user}","branches_url":"https://api.github.com/repos/cockpit-project/cockpit/branches{/branch}","tags_url":"https://api.github.com/repos/cockpit-project/cockpit/tags","blobs_url":"https://api.github.com/repos/cockpit-project/cockpit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockpit-project/cockpit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockpit-project/cockpit/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockpit-project/cockpit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockpit-project/cockpit/statuses/{sha}","languages_url":"https://api.github.com/repos/cockpit-project/cockpit/languages","stargazers_url":"https://api.github.com/repos/cockpit-project/cockpit/stargazers","contributors_url":"https://api.github.com/repos/cockpit-project/cockpit/contributors","subscribers_url":"https://api.github.com/repos/cockpit-project/cockpit/subscribers","subscription_url":"https://api.github.com/repos/cockpit-project/cockpit/subscription","commits_url":"https://api.github.com/repos/cockpit-project/cockpit/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockpit-project/cockpit/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockpit-project/cockpit/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockpit-project/cockpit/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockpit-project/cockpit/contents/{+path}","compare_url":"https://api.github.com/repos/cockpit-project/cockpit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockpit-project/cockpit/merges","archive_url":"https://api.github.com/repos/cockpit-project/cockpit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockpit-project/cockpit/downloads","issues_url":"https://api.github.com/repos/cockpit-project/cockpit/issues{/number}","pulls_url":"https://api.github.com/repos/cockpit-project/cockpit/pulls{/number}","milestones_url":"https://api.github.com/repos/cockpit-project/cockpit/milestones{/number}","notifications_url":"https://api.github.com/repos/cockpit-project/cockpit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockpit-project/cockpit/labels{/name}","releases_url":"https://api.github.com/repos/cockpit-project/cockpit/releases{/id}","deployments_url":"https://api.github.com/repos/cockpit-project/cockpit/deployments","created_at":"2013-11-01T17:36:46Z","updated_at":"2018-03-14T08:23:07Z","pushed_at":"2018-03-14T03:22:05Z","git_url":"git://github.com/cockpit-project/cockpit.git","ssh_url":"git@github.com:cockpit-project/cockpit.git","clone_url":"https://github.com/cockpit-project/cockpit.git","svn_url":"https://github.com/cockpit-project/cockpit","homepage":"http://www.cockpit-project.org/","size":44985,"stargazers_count":3094,"watchers_count":3094,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":393,"mirror_url":null,"archived":false,"open_issues_count":559,"license":{"key":"lgpl-2.1","name":"GNU Lesser General Public License v2.1","spdx_id":"LGPL-2.1","url":"https://api.github.com/licenses/lgpl-2.1"},"forks":393,"open_issues":559,"watchers":3094,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032"},"html":{"href":"https://github.com/cockpit-project/cockpit/pull/8032"},"issue":{"href":"https://api.github.com/repos/cockpit-project/cockpit/issues/8032"},"comments":{"href":"https://api.github.com/repos/cockpit-project/cockpit/issues/8032/comments"},"review_comments":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032/comments"},"review_comment":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockpit-project/cockpit/pulls/8032/commits"},"statuses":{"href":"https://api.github.com/repos/cockpit-project/cockpit/statuses/b3f14bd53ba44414cb77ba344ac4df6de1f9a4a1"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"martinpitt"}}