Enable public website sharing.

This commit is contained in:
Mike Cao 2020-08-15 01:17:15 -07:00
parent 48a524e09c
commit 560f1316c1
36 changed files with 294 additions and 61 deletions

View file

@ -49,7 +49,7 @@ export default function DeleteForm({ values, onSave, onClose }) {
Type <b>DELETE</b> in the box below to confirm.
</p>
<FormRow>
<Field name="confirmation" />
<Field name="confirmation" type="text" />
<FormError name="confirmation" />
</FormRow>
<FormButtons>

View file

@ -0,0 +1,30 @@
import React, { useRef } from 'react';
import Button from 'components/common/Button';
import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout';
import CopyButton from '../common/CopyButton';
export default function TrackingCodeForm({ values, onClose }) {
const ref = useRef();
const { name, share_id } = values;
return (
<FormLayout>
<p>
This is the public URL for <b>{values.name}</b>.
</p>
<FormRow>
<textarea
ref={ref}
rows={3}
cols={60}
defaultValue={`${document.location.origin}/share/${share_id}/${name}`}
readOnly
/>
</FormRow>
<FormButtons>
<CopyButton type="submit" variant="action" element={ref} />
<Button onClick={onClose}>Cancel</Button>
</FormButtons>
</FormLayout>
);
}

View file

@ -3,7 +3,7 @@ import Button from 'components/common/Button';
import FormLayout, { FormButtons, FormRow } from 'components/layout/FormLayout';
import CopyButton from '../common/CopyButton';
export default function WebsiteCodeForm({ values, onClose }) {
export default function TrackingCodeForm({ values, onClose }) {
const ref = useRef();
return (

View file

@ -8,10 +8,12 @@ import FormLayout, {
FormMessage,
FormRow,
} from 'components/layout/FormLayout';
import Checkbox from '../common/Checkbox';
const initialValues = {
name: '',
domain: '',
public: false,
};
const validate = ({ name, domain }) => {
@ -43,7 +45,7 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
return (
<FormLayout>
<Formik
initialValues={{ ...initialValues, ...values }}
initialValues={{ ...initialValues, ...values, make_public: !!values?.share_id }}
validate={validate}
onSubmit={handleSubmit}
>
@ -59,6 +61,12 @@ export default function WebsiteEditForm({ values, onSave, onClose }) {
<Field name="domain" type="text" />
<FormError name="domain" />
</FormRow>
<FormRow>
<label></label>
<Field name="make_public">
{({ field }) => <Checkbox {...field} label="Make public" />}
</Field>
</FormRow>
<FormButtons>
<Button type="submit" variant="action">
Save