Skip to content

Commit

Permalink
Remove action={$c.req.uri}
Browse files Browse the repository at this point in the history
From https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data#the_action_attribute

"When specified with no attributes, as below, the <form> data is sent to
the same page that the form is present on:"

"<form>"
  • Loading branch information
mwiencek committed Aug 13, 2022
1 parent 31c4164 commit 2ab8141
Show file tree
Hide file tree
Showing 36 changed files with 62 additions and 134 deletions.
4 changes: 1 addition & 3 deletions root/admin/LockedUsernameUnlock.js
Expand Up @@ -15,13 +15,11 @@ import Layout from '../layout/index.js';
import expand2text from '../static/scripts/common/i18n/expand2text.js';

type Props = {
+$c: CatalystContextT,
+form: SecureConfirmFormT,
+username: string,
};

const LockedUsernameUnlock = ({
$c,
form,
username,
}: Props): React.Element<typeof Layout> => (
Expand All @@ -35,7 +33,7 @@ const LockedUsernameUnlock = ({
{username: username},
)}
</p>
<form action={$c.req.uri} method="post" name="confirm">
<form method="post" name="confirm">
<FormCsrfToken form={form} />
<FormSubmit
label="Yes, I’m sure"
Expand Down
4 changes: 1 addition & 3 deletions root/admin/statistics-events/DeleteStatisticsEvent.js
Expand Up @@ -16,12 +16,10 @@ import expand2react from '../../static/scripts/common/i18n/expand2react.js';
import type {StatisticsEventT} from './types.js';

type PropsT = {
+$c: CatalystContextT,
+event: StatisticsEventT,
};

const DeleteStatisticsEvent = ({
$c,
event,
}: PropsT): React.Element<typeof Layout> => (
<Layout fullWidth title={l('Remove statistics event')}>
Expand All @@ -47,7 +45,7 @@ const DeleteStatisticsEvent = ({
<p>
{l('Are you sure you want to remove this statistics event?')}
</p>
<form action={$c.req.uri} method="post">
<form method="post">
<FormSubmit label={l('Remove statistics event')} />
</form>
</Layout>
Expand Down
74 changes: 35 additions & 39 deletions root/admin/statistics-events/StatisticsEventEditForm.js
Expand Up @@ -12,7 +12,6 @@ import * as React from 'react';
import FormCsrfToken from '../../components/FormCsrfToken.js';
import FormRowTextLong from '../../components/FormRowTextLong.js';
import FormSubmit from '../../components/FormSubmit.js';
import {CatalystContext} from '../../context.mjs';

import type {StatisticsEventFormT} from './types.js';

Expand All @@ -22,43 +21,40 @@ type PropsT = {

const StatisticsEventForm = ({
form,
}: PropsT): React.Element<'form'> => {
const $c = React.useContext(CatalystContext);
return (
<form action={$c.req.uri} method="post">
<FormCsrfToken form={form} />
<div className="half-width">
<fieldset>
<legend>{l('Statistics event details')}</legend>
<FormRowTextLong
field={form.field.date}
label={addColonText(l('Date'))}
required
uncontrolled
/>
<FormRowTextLong
field={form.field.title}
label={addColonText(l('Title'))}
required
uncontrolled
/>
<FormRowTextLong
field={form.field.description}
label={addColonText(l('Description'))}
uncontrolled
/>
<FormRowTextLong
field={form.field.link}
label={addColonText(l('Link'))}
uncontrolled
/>
</fieldset>
</div>
<div className="row no-label">
<FormSubmit label={l('Submit')} />
</div>
</form>
);
};
}: PropsT): React.Element<'form'> => (
<form method="post">
<FormCsrfToken form={form} />
<div className="half-width">
<fieldset>
<legend>{l('Statistics event details')}</legend>
<FormRowTextLong
field={form.field.date}
label={addColonText(l('Date'))}
required
uncontrolled
/>
<FormRowTextLong
field={form.field.title}
label={addColonText(l('Title'))}
required
uncontrolled
/>
<FormRowTextLong
field={form.field.description}
label={addColonText(l('Description'))}
uncontrolled
/>
<FormRowTextLong
field={form.field.link}
label={addColonText(l('Link'))}
uncontrolled
/>
</fieldset>
</div>
<div className="row no-label">
<FormSubmit label={l('Submit')} />
</div>
</form>
);

export default StatisticsEventForm;
4 changes: 1 addition & 3 deletions root/admin/wikidoc/CreateWikiDoc.js
Expand Up @@ -16,7 +16,6 @@ import FormSubmit from '../../components/FormSubmit.js';
import Layout from '../../layout/index.js';

type Props = {
+$c: CatalystContextT,
+form: FormT<{
+csrf_token: FieldT<string>,
+page: FieldT<string>,
Expand All @@ -25,13 +24,12 @@ type Props = {
};

const CreateWikiDoc = ({
$c,
form,
}: Props): React.Element<typeof Layout> => (
<Layout fullWidth title={l('Add Page')}>
<div id="content">
<h1>{l('Add Page')}</h1>
<form action={$c.req.uri} method="post">
<form method="post">
<FormCsrfToken form={form} />
<FormRowTextLong
field={form.field.page}
Expand Down
4 changes: 1 addition & 3 deletions root/admin/wikidoc/DeleteWikiDoc.js
Expand Up @@ -14,13 +14,11 @@ import FormSubmit from '../../components/FormSubmit.js';
import Layout from '../../layout/index.js';

type Props = {
+$c: CatalystContextT,
+form: SecureConfirmFormT,
+page: string,
};

const DeleteWikiDoc = ({
$c,
form,
page,
}: Props): React.Element<typeof Layout> => (
Expand All @@ -35,7 +33,7 @@ const DeleteWikiDoc = ({
page_uri: '/doc/' + encodeURIComponent(page),
})}
</p>
<form action={$c.req.uri} method="post" name="confirm">
<form method="post" name="confirm">
<FormCsrfToken form={form} />
<FormSubmit
label={l('Yes, I\'m sure')}
Expand Down
4 changes: 1 addition & 3 deletions root/admin/wikidoc/EditWikiDoc.js
Expand Up @@ -15,7 +15,6 @@ import FormSubmit from '../../components/FormSubmit.js';
import Layout from '../../layout/index.js';

type Props = {
+$c: CatalystContextT,
+currentVersion: number,
+form: FormT<{
+csrf_token: FieldT<string>,
Expand All @@ -25,15 +24,14 @@ type Props = {
};

const EditWikiDoc = ({
$c,
currentVersion,
form,
page,
}: Props): React.Element<typeof Layout> => (
<Layout fullWidth title={l('Update Page')}>
<div id="content">
<h1>{l('Update Page')}</h1>
<form action={$c.req.uri} method="post">
<form method="post">
<FormCsrfToken form={form} />
<div className="row">
<label>{l('Page:')}</label>
Expand Down
4 changes: 1 addition & 3 deletions root/annotation/EditAnnotation.js
Expand Up @@ -24,15 +24,13 @@ type EditAnnotationFormT = FormT<{
}>;

type EditAnnotationProps = {
+$c: CatalystContextT,
+entity: AnnotatedEntityT,
+form: EditAnnotationFormT,
+preview?: string,
+showPreview?: boolean,
};

const EditAnnotation = ({
$c,
entity,
form,
preview,
Expand Down Expand Up @@ -69,7 +67,7 @@ const EditAnnotation = ({
</>
) : null}

<form action={$c.req.uri} method="post">
<form method="post">
<FormRowTextArea
cols={80}
field={form.field.text}
Expand Down
4 changes: 1 addition & 3 deletions root/area/AreaMerge.js
Expand Up @@ -18,13 +18,11 @@ import AreaList from '../components/list/AreaList.js';
import Layout from '../layout/index.js';

type Props = {
+$c: CatalystContextT,
+form: MergeFormT,
+toMerge: $ReadOnlyArray<AreaT>,
};

const AreaMerge = ({
$c,
form,
toMerge,
}: Props): React.Element<typeof Layout> => (
Expand All @@ -35,7 +33,7 @@ const AreaMerge = ({
{l(`You are about to merge all these areas into a single one.
Please select the area all others should be merged into:`)}
</p>
<form action={$c.req.uri} method="post">
<form method="post">
<AreaList
areas={sortByEntityName(toMerge)}
mergeForm={form}
Expand Down
4 changes: 1 addition & 3 deletions root/artist/ArtistMerge.js
Expand Up @@ -19,13 +19,11 @@ import ArtistList from '../components/list/ArtistList.js';
import Layout from '../layout/index.js';

type Props = {
+$c: CatalystContextT,
+form: MergeFormT,
+toMerge: $ReadOnlyArray<ArtistT>,
};

const ArtistMerge = ({
$c,
form,
toMerge,
}: Props): React.Element<typeof Layout> => (
Expand All @@ -36,7 +34,7 @@ const ArtistMerge = ({
{l(`You are about to merge all these artists into a single one.
Please select the artist all others should be merged into:`)}
</p>
<form action={$c.req.uri} method="post">
<form method="post">
<ArtistList
artists={sortByEntityName(toMerge)}
mergeForm={form}
Expand Down
2 changes: 1 addition & 1 deletion root/collection/CollectionIndex.js
Expand Up @@ -200,7 +200,7 @@ React.Element<typeof CollectionLayout> => {
</div>
<h2>{formatPluralEntityTypeName(collectionEntityType)}</h2>
{entities.length > 0 ? (
<form action={$c.req.uri} method="post">
<form method="post">
<PaginatedResults pager={pager}>
{listPicker(props, canRemoveFromCollection)}
</PaginatedResults>
Expand Down
4 changes: 1 addition & 3 deletions root/collection/CollectionMerge.js
Expand Up @@ -28,7 +28,6 @@ import {
} from '../utility/tableColumns.js';

type Props = {
+$c: CatalystContextT,
+form: MergeFormT,
+privaciesDiffer?: boolean,
+toMerge: $ReadOnlyArray<CollectionT>,
Expand Down Expand Up @@ -99,7 +98,6 @@ const CollectionMergeTable = ({
};

const CollectionMerge = ({
$c,
form,
privaciesDiffer,
toMerge,
Expand Down Expand Up @@ -156,7 +154,7 @@ const CollectionMerge = ({
</p>
</div>
) : null}
<form action={$c.req.uri} method="post">
<form method="post">
<CollectionMergeTable collections={collections} form={form} />

{collaborators.length ? (
Expand Down
4 changes: 1 addition & 3 deletions root/collection/DeleteCollection.js
Expand Up @@ -15,12 +15,10 @@ import EntityLink from '../static/scripts/common/components/EntityLink.js';
import CollectionLayout from './CollectionLayout.js';

type Props = {
+$c: CatalystContextT,
+collection: CollectionT,
};

const DeleteCollection = ({
$c,
collection,
}: Props): React.Element<typeof CollectionLayout> => (
<CollectionLayout
Expand All @@ -34,7 +32,7 @@ const DeleteCollection = ({
{exp.l('Are you sure you want to remove the collection {collection}?',
{collection: <EntityLink entity={collection} />})}
</p>
<form action={$c.req.uri} method="post">
<form method="post">
<FormSubmit label={l('Remove collection')} />
</form>

Expand Down
1 change: 0 additions & 1 deletion root/components/TagEntitiesList.js
Expand Up @@ -135,7 +135,6 @@ const TagEntitiesList = ({
</h2>
{showVotesSelect ? (
<UserTagFilters
$c={$c}
showDownvoted={showDownvoted}
showVotesSelect
/>
Expand Down
3 changes: 0 additions & 3 deletions root/entity/alias/AddOrEditAlias.js
Expand Up @@ -18,7 +18,6 @@ import {ENTITIES} from '../../static/scripts/common/constants.js';
import type {AliasEditFormT} from './types.js';

type Props = {
+$c: CatalystContextT,
+aliasTypes: SelectOptionsT,
+entity: CoreEntityT,
+form: AliasEditFormT,
Expand All @@ -28,7 +27,6 @@ type Props = {
};

const AddOrEditAlias = ({
$c,
aliasTypes,
entity,
form,
Expand All @@ -51,7 +49,6 @@ const AddOrEditAlias = ({
>
<h2>{header}</h2>
<AliasEditForm
$c={$c}
aliasTypes={aliasTypes}
entity={entity}
form={form}
Expand Down
4 changes: 1 addition & 3 deletions root/entity/alias/DeleteAlias.js
Expand Up @@ -16,15 +16,13 @@ import EnterEditNote from '../../components/EnterEditNote.js';
import type {AliasDeleteFormT} from './types.js';

type Props = {
+$c: CatalystContextT,
+alias: AliasT,
+entity: CoreEntityT,
+form: AliasDeleteFormT,
+type: string,
};

const DeleteAlias = ({
$c,
alias,
entity,
form,
Expand Down Expand Up @@ -54,7 +52,7 @@ const DeleteAlias = ({
)}
</p>

<form action={$c.req.uri} method="post">
<form method="post">
<EnterEditNote field={form.field.edit_note} />
<EnterEdit form={form} />
</form>
Expand Down

0 comments on commit 2ab8141

Please sign in to comment.