* fix eslint issues in article-form's jsx files * Use e.key instead of deprecated e.keyCode * Put back whitespace but in html format * use re-usable SetupImageButton comp, use window.confirm, put back console.log temporarily * import deep * fix CoverImage className prop issue * update jest snap files * remove no-restricted-globals from eslint-disable-next-line
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const orgOptions = (organizations, organizationId) => {
|
|
const orgs = organizations.map(organization => {
|
|
if (organizationId === organization.id) {
|
|
return (
|
|
<option value={organization.id} selected>
|
|
{organization.name}
|
|
</option>
|
|
);
|
|
}
|
|
return <option value={organization.id}>{organization.name}</option>;
|
|
});
|
|
const nullOrgOption =
|
|
organizationId === null ? (
|
|
<option value="" selected>
|
|
None
|
|
</option>
|
|
) : (
|
|
<option value="">None</option>
|
|
);
|
|
orgs.unshift(nullOrgOption); // make first option as "None"
|
|
return orgs;
|
|
};
|
|
|
|
const OrgSettings = ({ organizations, organizationId, onToggle }) => (
|
|
<div className="articleform__orgsettings">
|
|
Publish under an organization:
|
|
<select
|
|
name="article[organization_id]"
|
|
id="article_publish_under_org"
|
|
onBlur={onToggle}
|
|
>
|
|
{orgOptions(organizations, organizationId)}
|
|
</select>
|
|
</div>
|
|
);
|
|
|
|
OrgSettings.propTypes = {
|
|
onToggle: PropTypes.func.isRequired,
|
|
organizationId: PropTypes.string.isRequired,
|
|
organizations: PropTypes.arrayOf(
|
|
PropTypes.shape({
|
|
id: PropTypes.string,
|
|
name: PropTypes.string,
|
|
}),
|
|
).isRequired,
|
|
};
|
|
|
|
export default OrgSettings;
|