From 02bd56b8bc4484996ed803e01913f94309d552b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Jun 2021 04:56:52 +0000 Subject: [PATCH 001/114] Bump normalize-url from 4.5.0 to 4.5.1 Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/sindresorhus/normalize-url/releases) - [Commits](https://github.com/sindresorhus/normalize-url/commits) --- updated-dependencies: - dependency-name: normalize-url dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 258705f6..9d1f0565 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6715,9 +6715,9 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== normalize-url@^4.1.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" - integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== + version "4.5.1" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a" + integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA== npm-bundled@^1.0.1: version "1.0.6" From a83b4c935e6e6cbe3c38e94c1b1f4a96d259cc64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 10:24:04 +0000 Subject: [PATCH 002/114] Bump dot-prop from 4.2.0 to 4.2.1 Bumps [dot-prop](https://github.com/sindresorhus/dot-prop) from 4.2.0 to 4.2.1. - [Release notes](https://github.com/sindresorhus/dot-prop/releases) - [Commits](https://github.com/sindresorhus/dot-prop/compare/v4.2.0...v4.2.1) --- updated-dependencies: - dependency-name: dot-prop dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e86c98df..71db327d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3711,9 +3711,9 @@ domain-browser@^1.1.1, domain-browser@^1.2.0: integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA== dot-prop@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" - integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== + version "4.2.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" + integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== dependencies: is-obj "^1.0.0" From dba81aae2df2393b500a737c9ae4cfb0434619d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Aug 2021 22:45:17 +0000 Subject: [PATCH 003/114] Bump path-parse from 1.0.6 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e86c98df..ed0eb049 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7771,9 +7771,9 @@ path-key@^3.1.0: integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== path-parse@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" - integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== path-platform@~0.11.15: version "0.11.15" From f21ba0667f2f0cc00ecec7c0d3039f385c876d2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 12:50:06 +0000 Subject: [PATCH 004/114] Bump browserslist from 4.6.6 to 4.19.1 Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.6.6 to 4.19.1. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](https://github.com/browserslist/browserslist/compare/4.6.6...4.19.1) --- updated-dependencies: - dependency-name: browserslist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 59 +------------------------------------------------------ 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/yarn.lock b/yarn.lock index 221323b5..09f8fb6d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3248,27 +3248,7 @@ browserify@^16.1.0, browserify@^16.2.3: vm-browserify "^1.0.0" xtend "^4.0.0" -browserslist@^4.1.0: - version "4.6.6" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.6.6.tgz#6e4bf467cde520bc9dbdf3747dafa03531cec453" - integrity sha512-D2Nk3W9JL9Fp/gIcWei8LrERCS+eXu9AM5cfXA8WEZ84lFks+ARnZ0q/R69m2SV3Wjma83QDDPxsNKXUwdIsyA== - dependencies: - caniuse-lite "^1.0.30000984" - electron-to-chromium "^1.3.191" - node-releases "^1.1.25" - -browserslist@^4.16.6: - version "4.16.6" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2" - integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ== - dependencies: - caniuse-lite "^1.0.30001219" - colorette "^1.2.2" - electron-to-chromium "^1.3.723" - escalade "^3.1.1" - node-releases "^1.1.71" - -browserslist@^4.17.5, browserslist@^4.19.1: +browserslist@^4.1.0, browserslist@^4.16.6, browserslist@^4.17.5, browserslist@^4.19.1: version "4.19.1" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.19.1.tgz#4ac0435b35ab655896c31d53018b6dd5e9e4c9a3" integrity sha512-u2tbbG5PdKRTUoctO3NBD8FQ5HdPh1ZXPHzp1rwaa5jTc+RV9/+RlWiAIKmjRPQF+xbGM9Kklj5bZQFa2s/38A== @@ -3488,16 +3468,6 @@ camelcase@^6.2.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30000984: - version "1.0.30000984" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000984.tgz#dc96c3c469e9bcfc6ad5bdd24c77ec918ea76fe0" - integrity sha512-n5tKOjMaZ1fksIpQbjERuqCyfgec/m9pferkFQbLmWtqLUdmt12hNhjSwsmPdqeiG2NkITOQhr1VYIwWSAceiA== - -caniuse-lite@^1.0.30001219: - version "1.0.30001239" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz#66e8669985bb2cb84ccb10f68c25ce6dd3e4d2b8" - integrity sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ== - caniuse-lite@^1.0.30001286: version "1.0.30001299" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001299.tgz#d753bf6444ed401eb503cbbe17aa3e1451b5a68c" @@ -3795,11 +3765,6 @@ colorette@2.0.16: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== -colorette@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94" - integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w== - colors@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" @@ -4627,16 +4592,6 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= -electron-to-chromium@^1.3.191: - version "1.3.191" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.191.tgz#c451b422cd8b2eab84dedabab5abcae1eaefb6f0" - integrity sha512-jasjtY5RUy/TOyiUYM2fb4BDaPZfm6CXRFeJDMfFsXYADGxUN49RBqtgB7EL2RmJXeIRUk9lM1U6A5yk2YJMPQ== - -electron-to-chromium@^1.3.723: - version "1.3.756" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.756.tgz#942cee59cd64d19f576d8d5804eef09cb423740c" - integrity sha512-WsmJym1TMeHVndjPjczTFbnRR/c4sbzg8fBFtuhlb2Sru3i/S1VGpzDSrv/It8ctMU2bj8G7g7/O3FzYMGw6eA== - electron-to-chromium@^1.4.17: version "1.4.45" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.45.tgz#cf1144091d6683cbd45a231954a745f02fb24598" @@ -7887,18 +7842,6 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^1.1.25: - version "1.1.25" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.25.tgz#0c2d7dbc7fed30fbe02a9ee3007b8c90bf0133d3" - integrity sha512-fI5BXuk83lKEoZDdH3gRhtsNgh05/wZacuXkgbiYkceE7+QIMXOg98n9ZV7mz27B+kFHnqHcUpscZZlGRSmTpQ== - dependencies: - semver "^5.3.0" - -node-releases@^1.1.71: - version "1.1.73" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20" - integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg== - node-releases@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" From aa7367ec9c64833d564fa9dd5fde449277dcd2b7 Mon Sep 17 00:00:00 2001 From: Marc Farra Date: Tue, 25 Jan 2022 23:35:03 +0200 Subject: [PATCH 005/114] API changes for privacy policy --- .../20220125220402_org-privacy-policy.js | 12 +++ app/lib/organization.js | 3 +- app/manage/index.js | 6 +- components/privacy-policy-form.js | 63 ++++++++++++++ compose.dev.yml | 2 +- lib/org-api.js | 17 +++- pages/org-edit-privacy-policy.js | 87 +++++++++++++++++++ pages/org-edit-team-profile.js | 2 +- pages/org-edit.js | 20 +++-- pages/profile.js | 2 +- 10 files changed, 201 insertions(+), 13 deletions(-) create mode 100644 app/db/migrations/20220125220402_org-privacy-policy.js create mode 100644 components/privacy-policy-form.js create mode 100644 pages/org-edit-privacy-policy.js diff --git a/app/db/migrations/20220125220402_org-privacy-policy.js b/app/db/migrations/20220125220402_org-privacy-policy.js new file mode 100644 index 00000000..7a788224 --- /dev/null +++ b/app/db/migrations/20220125220402_org-privacy-policy.js @@ -0,0 +1,12 @@ + +exports.up = async function (knex) { + await knex.schema.alterTable('organization', table => { + table.json('privacy_policy') + }) +} + +exports.down = async function (knex) { + await knex.schema.alterTable('organization', table => { + table.dropColumn('privacy_policy') + }) +} diff --git a/app/lib/organization.js b/app/lib/organization.js index 87f9354d..32ce5edd 100644 --- a/app/lib/organization.js +++ b/app/lib/organization.js @@ -10,6 +10,7 @@ const orgAttributes = [ 'description', 'privacy', 'teams_can_be_public', + 'privacy_policy', 'created_at', 'updated_at' ] @@ -113,8 +114,6 @@ async function destroy (id) { * @return {promise} */ async function update (id, data) { - if (!data.name) throw new Error('data.name property is required') - const conn = await db() return unpack(conn('organization').where('id', id).update(data).returning(orgAttributes)) } diff --git a/app/manage/index.js b/app/manage/index.js index 3e517e03..9929f1f8 100644 --- a/app/manage/index.js +++ b/app/manage/index.js @@ -207,11 +207,15 @@ function manageRouter (nextApp) { return nextApp.render(req, res, '/org-edit-profile', { id: req.params.id }) }) + router.get('/organizations/:id/edit-privacy-policy', can('organization:edit'), (req, res) => { + return nextApp.render(req, res, '/org-edit-privacy-policy', { id: req.params.id }) + }) + router.get('/organizations/:id/profile', can('organization:member'), (req, res) => { return nextApp.render(req, res, '/profile-form', { id: req.params.id, formType: 'org' }) }) - router.get('/organizations/:id/edit-team-profiles', can('organization:member'), (req, res) => { + router.get('/organizations/:id/edit-team-profiles', can('organization:edit'), (req, res) => { return nextApp.render(req, res, '/org-edit-team-profile', { id: req.params.id }) }) diff --git a/components/privacy-policy-form.js b/components/privacy-policy-form.js new file mode 100644 index 00000000..456577db --- /dev/null +++ b/components/privacy-policy-form.js @@ -0,0 +1,63 @@ +import React from 'react' +import { Formik, Field, Form } from 'formik' +import Button from '../components/button' + +function validateBody (value) { + if (!value) return 'Body of privacy policy is required' +} + +function validateConsentText (value) { + if (!value) return 'Consent Text of privacy policy is required' +} + +function renderError (text) { + return
{text}
+} + +function renderErrors (errors) { + const keys = Object.keys(errors) + return keys.map((key) => { + return renderError(errors[key]) + }) +} + +export default function PrivacyPolicyForm ({ initialValues, onSubmit }) { + return ( + { + return ( +
+
+ + +
+
+ + +
+
+ {(status && status.errors) && (renderErrors(status.errors))} +
+
+ ) + }} + /> + ) +} diff --git a/compose.dev.yml b/compose.dev.yml index 0fadcbef..f45e3118 100644 --- a/compose.dev.yml +++ b/compose.dev.yml @@ -10,4 +10,4 @@ services: - .:/usr/src/app - ./node_modules:/usr/src/app/node_modules command: - npm run dev + sh -c "npm run migrate && npm run dev" diff --git a/lib/org-api.js b/lib/org-api.js index a6870a9f..8dff75bd 100644 --- a/lib/org-api.js +++ b/lib/org-api.js @@ -32,7 +32,7 @@ export async function createOrg (data) { * */ export async function getMyOrgs () { - const res = await fetch('/api/my/organizations') + const res = await fetch(join(publicRuntimeConfig.APP_URL, '/api/my/organizations')) if (res.status === 200) { return res.json() @@ -111,6 +111,21 @@ export async function updateOrg (id, values) { }) } +/** + * updateOrgPrivacyPolicy + * @param {integer} id id of organization + * @param {data} values data to update + */ +export async function updateOrgPrivacyPolicy (id, privacyPolicy) { + return fetch(join(URL, `${id}`), { + method: 'PUT', + body: JSON.stringify({ 'privacy_policy': privacyPolicy }), + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }) +} + /** * destroyOrg * delete an org diff --git a/pages/org-edit-privacy-policy.js b/pages/org-edit-privacy-policy.js new file mode 100644 index 00000000..1b1986e1 --- /dev/null +++ b/pages/org-edit-privacy-policy.js @@ -0,0 +1,87 @@ +import React, { Component } from 'react' +import join from 'url-join' +import { pick, prop } from 'ramda' +import getConfig from 'next/config' +import Router from 'next/router' +import { getOrg, updateOrgPrivacyPolicy } from '../lib/org-api' +import PrivacyPolicyForm from '../components/privacy-policy-form' +const { publicRuntimeConfig } = getConfig() + +export default class OrgPrivacyPolicy extends Component { + static async getInitialProps ({ query }) { + if (query) { + return { + // Organization id + id: query.id + } + } + } + + constructor (props) { + super(props) + this.state = { + loading: true, + error: undefined + } + + this.getProfileForm = this.getProfileForm.bind(this) + } + + async componentDidMount () { + this.getProfileForm() + } + + async getProfileForm () { + const { id } = this.props + try { + let org = await getOrg(id) + let privacyPolicy = prop('privacy_policy', org) + this.setState({ + orgId: id, + privacyPolicy, + loading: false + }) + } catch (e) { + console.error(e) + this.setState({ + error: e, + orgId: null, + profileForm: [], + loading: false + }) + } + } + + render () { + const { privacyPolicy, orgId } = this.state + if (!orgId) return null + + const defaultValues = { + body: 'OSM Teams has the ability to collect additional information on registered users of OpenStreetMap. Exactly which types of information is collected is determined by Organization and/or Team moderators. OSM Teams will never sell or share user information directly from the database. The use of any information submitted by a member of a team or organization is at the full discretion of the team or organization moderator.', + consentText: 'I understand the associated risks of using and entering my information on OSM Teams.' + } + + let initialValues = (privacyPolicy || defaultValues) + + return
+
+
+

Edit Privacy Policy

+
+ { + try { + await updateOrgPrivacyPolicy(orgId, values) + actions.setSubmitting(false) + Router.push(join(publicRuntimeConfig.APP_URL, `/organizations/${orgId}/edit`)) + } catch (e) { + console.error(e) + actions.setSubmitting(false) + actions.setStatus(e.message) + } + }} + /> +
+
+ } +} diff --git a/pages/org-edit-team-profile.js b/pages/org-edit-team-profile.js index c2eaab93..2b5e2c35 100644 --- a/pages/org-edit-team-profile.js +++ b/pages/org-edit-team-profile.js @@ -214,5 +214,5 @@ export default class OrgEditTeamProfile extends Component { ) - }Team + } } diff --git a/pages/org-edit.js b/pages/org-edit.js index 2338da49..308c6565 100644 --- a/pages/org-edit.js +++ b/pages/org-edit.js @@ -128,12 +128,6 @@ export default class OrgEdit extends Component {

Edit Org

-
- - - - -
+
+
+

Org Attributes

+
+
+ + + + + + + +
+

Danger Zone 🎸

Delete this org, org information and all memberships associated to this team

diff --git a/pages/profile.js b/pages/profile.js index 0f81bdaf..0047b473 100644 --- a/pages/profile.js +++ b/pages/profile.js @@ -127,7 +127,7 @@ export default class Profile extends Component { return (
-

Profile

+

Teams & Organizations

From 8e78c4cee7ff31ce0b8daeafca7c6716bfab801a Mon Sep 17 00:00:00 2001 From: Marc Farra Date: Wed, 26 Jan 2022 00:11:19 +0200 Subject: [PATCH 006/114] Disable submits with consent box --- components/button.js | 13 +++++++++--- components/profile-form.js | 35 +++++++++++++++++++++++++++++--- pages/org-edit-privacy-policy.js | 2 +- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/components/button.js b/components/button.js index 77472078..05426021 100644 --- a/components/button.js +++ b/components/button.js @@ -57,6 +57,10 @@ const style = css` backgroundColor: #777777; border: 2px solid #555; color: ${theme.colors.baseColor}; + transition: none; + opacity: 0.68; + box-shadow: 0 0; + cursor: not-allowed; } .button.danger { @@ -72,13 +76,16 @@ const style = css` ` export default function Button ({ name, id, value, variant, type, disabled, href, onClick, children, size }) { + let classes = [`button`, variant, size] + if (disabled) classes.push('disabled') + let classNames = classes.join(' ') if (type === 'submit') { - return + return } if (href) { let fullUrl (href.startsWith('http')) ? (fullUrl = href) : (fullUrl = join(publicRuntimeConfig.APP_URL, href)) - return {children} + return {children} } - return
{children}
+ return
{children}
} diff --git a/components/profile-form.js b/components/profile-form.js index 6feae82b..e2283810 100644 --- a/components/profile-form.js +++ b/components/profile-form.js @@ -3,6 +3,7 @@ import Router from 'next/router' import descriptionPopup from './description-popup' import { Formik, Field, Form } from 'formik' import { getOrgMemberAttributes, getTeamMemberAttributes, getMyProfile, setMyProfile } from '../lib/profiles-api' +import { getOrg } from '../lib/org-api' import { getTeam } from '../lib/teams-api' import Button from '../components/button' import { prop } from 'ramda' @@ -21,24 +22,37 @@ export default class ProfileForm extends Component { memberAttributes: [], orgAttributes: [], profileValues: {}, + consentChecked: true, loading: true, error: undefined } + + this.setConsentChecked = this.setConsentChecked.bind(this) } async componentDidMount () { this.getProfileForm() } + setConsentChecked (checked) { + this.setState({ + consentChecked: checked + }) + } + async getProfileForm () { const { id } = this.props try { let memberAttributes = [] let orgAttributes = [] + let org = {} + let consentChecked = true const returnUrl = `/teams/${this.props.id}` const team = await getTeam(id) if (team.org) { + org = await getOrg(team.org.organization_id) orgAttributes = await getOrgMemberAttributes(team.org.organization_id) + consentChecked = !(org && org.privacy_policy) } memberAttributes = await getTeamMemberAttributes(id) let profileValues = (await getMyProfile()).tags @@ -46,6 +60,8 @@ export default class ProfileForm extends Component { id, returnUrl, memberAttributes, + consentChecked, + org, orgAttributes, profileValues, loading: false @@ -60,7 +76,7 @@ export default class ProfileForm extends Component { } render () { - let { memberAttributes, orgAttributes, profileValues, returnUrl } = this.state + let { memberAttributes, orgAttributes, org, profileValues, returnUrl, consentChecked } = this.state profileValues = profileValues || {} return ( @@ -126,9 +142,22 @@ export default class ProfileForm extends Component { }) : 'No profile form to fill yet' } + { org && org.privacy_policy + ?
+

Privacy Policy

+ + {org.privacy_policy.body} + +
+ this.setConsentChecked(e.target.checked)} /> + {org.privacy_policy.consentText} +
+
+ :
+ } {status && status.msg &&
{status.msg}
} -
-
diff --git a/pages/org-edit-privacy-policy.js b/pages/org-edit-privacy-policy.js index 1b1986e1..25b5a199 100644 --- a/pages/org-edit-privacy-policy.js +++ b/pages/org-edit-privacy-policy.js @@ -1,6 +1,6 @@ import React, { Component } from 'react' import join from 'url-join' -import { pick, prop } from 'ramda' +import { prop } from 'ramda' import getConfig from 'next/config' import Router from 'next/router' import { getOrg, updateOrgPrivacyPolicy } from '../lib/org-api' From 63dcfaa7a9efeaf0cdb7e6104d521128d7072d2d Mon Sep 17 00:00:00 2001 From: Marc Farra Date: Wed, 26 Jan 2022 20:17:58 +0200 Subject: [PATCH 007/114] Styling --- components/profile-form.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/components/profile-form.js b/components/profile-form.js index e2283810..7fb55e2b 100644 --- a/components/profile-form.js +++ b/components/profile-form.js @@ -59,6 +59,7 @@ export default class ProfileForm extends Component { this.setState({ id, returnUrl, + team, memberAttributes, consentChecked, org, @@ -76,12 +77,15 @@ export default class ProfileForm extends Component { } render () { - let { memberAttributes, orgAttributes, org, profileValues, returnUrl, consentChecked } = this.state + let { memberAttributes, orgAttributes, org, profileValues, returnUrl, consentChecked, team} = this.state profileValues = profileValues || {} + const teamName = prop('name', team) || 'team' + const orgName = prop('name', org) || 'org' + return (
-

Add Your Profile

+

Add Your Details!

{orgAttributes.length > 0 ? <> -

Org Profile

+

Details for {orgName}

{orgAttributes.map(attribute => { return