houdini/client/js/settings/index/integrations/index.js
Bradley M. Kuhn fc77ee76d6 Relicense Javascript code in accordance with project's new license
The primary license of the project is changing to:
  AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

The Additional Permission is designed to permit publicly distributed
Javascript code to be relicensed under LGPL-3.0-or-later, but not server-side
Javascript code.  As such, we've relicensed here static Javscript files under
LGPL-3.0-or-later, and those that run as part of build and/or server side
under AGPL-3.0-or-later.

Note that in future, Javascript files may be updated to be stronger copyleft
license with the Additional Permission, particularly if they adapted to run
on server side and/or turned into templates.  Of course, we'd seek public
discussion with the contributor community about such changes.

This commit is one of the many steps to relicense the entire codebase.

Documentation granting permission for this relicensing (from all past
contributors who hold copyrights) is on file with Software Freedom
Conservancy, Inc.
2018-03-25 15:10:40 -04:00

60 lines
2.3 KiB
JavaScript

// License: LGPL-3.0-or-later
const h = require('snabbdom/h')
const R = require('ramda')
const flyd = require('flyd')
const request = require('../../../common/request')
const flyd_lift = require('flyd/module/lift')
const colors = require('../../../common/colors')
function init() {
var state = {
clickSync$: flyd.stream()
, mailchimpKeyResp$: request({method: 'get', path: `/nonprofits/${app.nonprofit_id}/nonprofit_keys`, query: {select: 'mailchimp_token'}}).load
}
state.mailchimpKey$ = flyd.map(R.prop('response'), flyd.filter(resp => resp.status === 200, state.mailchimpKeyResp$))
return state
}
function view(state) {
return h('section.integrations.settings-pane.nonprofit-settings', {
style: {display: 'none'}
}, [
h('header.pane-header', [h('h3', 'Integrations')])
, h('p', 'Connect your CommitChange account with other apps to take advantage of integration features.')
, integrationSection(state, state.mailchimpKey$(), 'MailChimp', mailchimpConnectedMessage, mailchimpNotConnectedMessage)
, h('br')
])
}
// A section fo each integration; pass in the API key for the integration, the
// name, and two functions for bodies: the first body function for when the API
// key is defined, the second body function for when the API key is undefined
const integrationSection = (state, key, name, bodyConnected, bodyNotConnected) => {
return h('div.pane-inner.integrations', [
h('h6', {
style: {color: key ? colors['$bluegrass'] : colors['$grey']}
}, [
key ? h('i.fa.fa-check') : h('i.fa.fa-question-circle')
, ' ' + name
])
, key ? bodyConnected(state) : bodyNotConnected(state)
])
}
const mailchimpNotConnectedMessage = state => {
return h('p', [
'Connect with MailChimp to automatically sync supporter emails to your MailChimp Email Lists.'
, h('br')
, h('a', {props: {href: `/nonprofits/${app.nonprofit_id}/nonprofit_keys/mailchimp_login`}}, 'Click here to connect your Mailchimp account.')
])
}
const mailchimpConnectedMessage = state => {
return h('p', [
'Congrats! You Mailchimp account has been connected successfully.'
, h('br')
, h('a', {props: {href: `/nonprofits/${app.nonprofit_id}/supporters?show-modal=mailchimpSettingsModal`}}, 'Click here to manage your email list sync settings.')
])
}
module.exports = {view, init}