diff --git a/invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity/new.js b/invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity/new.js index 802734443..bf73e1d47 100644 --- a/invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity/new.js +++ b/invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity/new.js @@ -14,7 +14,6 @@ import PropTypes from "prop-types"; import React, { Component } from "react"; import ReactDOM from "react-dom"; import { - CustomFields, FieldLabel, RadioField, SelectField, @@ -25,6 +24,7 @@ import { import { Button, Divider, Form, Grid, Header, Icon, Message } from "semantic-ui-react"; import { CommunityApi } from "../api"; import { communityErrorSerializer } from "../api/serializers"; +import Overridable, { OverridableContext, overrideStore } from "react-overridable"; const IdentifierField = ({ formConfig }) => { const { values } = useFormikContext(); @@ -150,163 +150,162 @@ class CommunityCreateForm extends Component { }; render() { - const { formConfig, canCreateRestricted } = this.props; + const { formConfig, canCreateRestricted, communityId } = this.props; const { hasCommunity, communities, error } = this.state; return ( - - {({ values, isSubmitting, handleSubmit }) => ( -
- - - - -
- {i18next.t("Subcommunity request")} -
- -
-
- - -
- - {i18next.t("Do you already have an existing community?")} - - {/* */} - - { - this.setState({ hasCommunity: true }); - }} - fieldPath="metadata.hasCommunity" - /> - { - this.setState({ hasCommunity: false }); - }} - fieldPath="metadata.hasCommunity" - /> - -
- {hasCommunity && ( - + +
+ {i18next.t("Subcommunity request")} +
+ +
+
+ + +
+ + {i18next.t("Do you already have an existing community?")} + + {/* */} + + { + this.setState({ hasCommunity: true }); + }} + fieldPath="metadata.hasCommunity" /> - } - fieldPath="metadata.community" - options={communities} - required - disabled={_isEmpty(communities)} - /> - )} - {!hasCommunity && ( - <> - { - e.key === "Enter" && e.preventDefault(); - }} + { + this.setState({ hasCommunity: false }); + }} + fieldPath="metadata.hasCommunity" + /> + +
+ {hasCommunity && ( + } + fieldPath="metadata.community" + options={communities} + required + disabled={_isEmpty(communities)} /> - - - )} - {!_isEmpty(customFields.ui) && ( - import(`@templates/custom_fields/${widget}.js`), - (widget) => import(`react-invenio-forms`), - ]} - fieldPathPrefix="custom_fields" - /> - )} - {canCreateRestricted && ( - <> -
{i18next.t("Community visibility")}
- {formConfig.access.visibility.map((item) => ( - - { - formikProps.form.setFieldValue( - "access.visibility", - item.value - ); - }} - /> - - - ))} - - )} -
-
- - - - - -
-
- )} -
+ )} + {!hasCommunity && ( + <> + { + e.key === "Enter" && e.preventDefault(); + }} + label={ + + } + /> + + + )} + {canCreateRestricted && ( + <> +
{i18next.t("Community visibility")}
+ {formConfig.access.visibility.map((item) => ( + + { + formikProps.form.setFieldValue( + "access.visibility", + item.value + ); + }} + /> + + + ))} + + )} + + + + + + + + + + )} + + ); } } @@ -319,17 +318,18 @@ CommunityCreateForm.propTypes = { const domContainer = document.getElementById("app"); const formConfig = JSON.parse(domContainer.dataset.formConfig); -const customFields = JSON.parse(domContainer.dataset.customFields); const canCreateRestricted = JSON.parse(domContainer.dataset.canCreateRestricted); const communityId = domContainer.dataset.communityId; +const overriddenComponents = overrideStore.getAll(); ReactDOM.render( - , + + + , domContainer ); export default CommunityCreateForm;