Skip to content

Commit

Permalink
Merge branch 'beta' into button-disabled-improve-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
magicznyleszek committed Jan 15, 2024
2 parents 13ff9d1 + 486cbe7 commit e8be5b2
Show file tree
Hide file tree
Showing 52 changed files with 945 additions and 459 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
REDIS_SESSION_URL: redis://localhost:6379
SERVICE_ACCOUNT_BACKEND_URL: redis://localhost:6379/4
CACHE_URL: redis://localhost:6379/3
ENKETO_REDIS_MAIN_URL: redis://localhost:6379/0
strategy:
matrix:
python-version: ['3.8', '3.10']
Expand Down
22 changes: 0 additions & 22 deletions jsapp/js/account/accountFieldsEditor.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ interface AccountFieldsEditorProps {
*/
values: AccountFieldsValues;
onChange: (fields: AccountFieldsValues) => void;
/**
* Handles the require authentication checkbox. If not provided, the checkbox
* will be displayed.
*/
isRequireAuthDisplayed?: boolean;
}

/**
Expand Down Expand Up @@ -87,23 +82,6 @@ export default function AccountFieldsEditor(props: AccountFieldsEditorProps) {

return (
<div>
<div className={styles.row}>
{/* Privacy */}
{props.isRequireAuthDisplayed !== false && (
<div className={styles.field}>
<label>{t('Privacy')}</label>

<Checkbox
checked={props.values.require_auth}
onChange={(isChecked: boolean) =>
onAnyFieldChange('require_auth', isChecked)
}
label={t('Require authentication to see forms and submit data')}
/>
</div>
)}
</div>

<div className={styles.row}>
{/* Full name */}
{isFieldToBeDisplayed('name') && (
Expand Down
17 changes: 17 additions & 0 deletions jsapp/js/account/accountSettings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@
font-size: 16px;
}
}

.form-modal__item--anonymous-submission-notice {
display: flex;
line-height: sizes.$x24;
background-color: colors.$kobo-light-amber;
margin-top: sizes.$x12;
padding: sizes.$x18;
border-radius: sizes.$x8;

.anonymous-submission-notice-copy {
padding-left: sizes.$x16;
padding-right: sizes.$x8;
> * {
display: inline;
}
}
}
}

.account-settings__actions {
Expand Down
30 changes: 30 additions & 0 deletions jsapp/js/account/accountSettingsRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import './accountSettings.scss';
import {notify, stringToColor} from 'js/utils';
import {dataInterface} from '../dataInterface';
import AccountFieldsEditor from './accountFieldsEditor.component';
import Icon from 'js/components/common/icon';
import envStore from 'js/envStore';
import {
getInitialAccountFieldsValues,
getProfilePatchData,
Expand All @@ -15,6 +17,7 @@ import type {
AccountFieldsValues,
AccountFieldsErrors,
} from './account.constants';
import {HELP_ARTICLE_ANON_SUBMISSIONS_URL} from 'js/constants';

bem.AccountSettings = makeBem(null, 'account-settings');
bem.AccountSettings__left = makeBem(bem.AccountSettings, 'left');
Expand Down Expand Up @@ -151,6 +154,33 @@ const AccountSettings = observer(() => {

{sessionStore.isInitialLoadComplete && form.isUserDataLoaded && (
<bem.AccountSettings__item m='fields'>
<bem.AccountSettings__item m='anonymous-submission-notice'>
<Icon name='information' color='amber' size='m' />
<div className='anonymous-submission-notice-copy'>
<strong>
{t(
'"Require authentication to see forms and submit data" has been moved.'
)}
</strong>
&nbsp;
<div>
{t(
'This privacy feature is now a per-project setting. New projects will require authentication by default.'
)}
</div>
&nbsp;
<a
href={
envStore.data.support_url +
HELP_ARTICLE_ANON_SUBMISSIONS_URL
}
target='_blank'
>
{t('Learn more about these changes here.')}
</a>
</div>
</bem.AccountSettings__item>

<AccountFieldsEditor
errors={form.fieldsWithErrors.extra_details}
values={form.fields}
Expand Down
35 changes: 35 additions & 0 deletions jsapp/js/components/anonymousSubmission.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, {useState} from 'react';
import ToggleSwitch from 'js/components/common/toggleSwitch';
import envStore from 'js/envStore';
import {HELP_ARTICLE_ANON_SUBMISSIONS_URL} from 'js/constants';
import Icon from 'js/components/common/icon';
import styles from './anonymousSubmission.module.scss';

interface AnonymousSubmissionProps {
checked: boolean;
onChange: (isChecked: boolean) => void;
}

export default function AnonymousSubmission(props: AnonymousSubmissionProps) {
return (
<div className={styles.root}>
<ToggleSwitch
checked={props.checked}
onChange={props.onChange}
label={t(
'Allow web submissions to this form without a username and password'
)}
/>
<a
href={envStore.data.support_url + HELP_ARTICLE_ANON_SUBMISSIONS_URL}
className='right-tooltip wrapped-tooltip'
target='_blank'
data-tip={t(
'Allow anyone to see this form and add submissions. Click the icon to learn more.'
)}
>
<Icon size='s' name='help' color='storm' />
</a>
</div>
);
}
13 changes: 13 additions & 0 deletions jsapp/js/components/anonymousSubmission.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@use 'scss/sizes';
@use '~kobo-common/src/styles/colors';

.root {
display: flex;
padding-bottom: sizes.$x12;
padding-top: sizes.$x8;
border-bottom: 1px solid colors.$kobo-gray-96;
}

a {
margin-left: sizes.$x8;
}
6 changes: 6 additions & 0 deletions jsapp/js/components/common/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ Additional class names:
transform: translate(0);
}

.wrapped-tooltip [data-tip]::after,
.wrapped-tooltip[data-tip]::after {
width: 300px;
white-space: normal;
}

// more actions in asset-row adjustment
.asset-row .popover-menu [data-tip]::after {
left: -60%;
Expand Down
Loading

0 comments on commit e8be5b2

Please sign in to comment.