From 2c170c3c2d849ccdfd348200c92a1b8e7f1fe8c4 Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Wed, 29 Jul 2020 22:41:09 -0700 Subject: [PATCH] Add frontend switch for whitelisted (#172) --- .../src/pages/profile/Profile.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/squeak-node-frontend/src/pages/profile/Profile.js b/frontend/squeak-node-frontend/src/pages/profile/Profile.js index 77f453fb..9e250bad 100644 --- a/frontend/squeak-node-frontend/src/pages/profile/Profile.js +++ b/frontend/squeak-node-frontend/src/pages/profile/Profile.js @@ -21,6 +21,7 @@ import { GetSqueakProfileRequest, SetSqueakProfileFollowingRequest, SetSqueakProfileSharingRequest, + SetSqueakProfileWhitelistedRequest, } from "../../proto/squeak_admin_pb" import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb" @@ -68,6 +69,17 @@ export default function ProfilePage() { getSqueakProfile(id); }); }; + const setWhitelisted = (id, whitelisted) => { + console.log("called setWhitelisted with profileId: " + id + ", whitelisted: " + whitelisted); + var setSqueakProfileWhitelistedRequest = new SetSqueakProfileWhitelistedRequest() + setSqueakProfileWhitelistedRequest.setProfileId(id); + setSqueakProfileWhitelistedRequest.setWhitelisted(whitelisted); + console.log(setSqueakProfileWhitelistedRequest); + client.setSqueakProfileWhitelisted(setSqueakProfileWhitelistedRequest, {}, (err, response) => { + console.log(response); + getSqueakProfile(id); + }); + }; useEffect(()=>{ @@ -86,6 +98,12 @@ export default function ProfilePage() { setSharing(id, event.target.checked); }; + const handleSettingsWhitelistedChange = (event) => { + console.log("Whitelisted changed for profile id: " + id); + console.log("Whitelisted changed to: " + event.target.checked); + setWhitelisted(id, event.target.checked); + }; + const handleSettingsChange = (event) => { console.log("Settings changed..."); setState({ ...state, [event.target.name]: event.target.checked }); @@ -124,7 +142,7 @@ export default function ProfilePage() { label="Sharing" /> } + control={} label="Whitelisted" />