Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP ui: externalize form builder #2859

Closed

Conversation

miguelgrc
Copy link
Contributor

@miguelgrc miguelgrc commented Oct 20, 2023

DO NOT MERGE

Part of #2844

Removes all the form builder code and does some refactoring to be able to import the components from https://github.com/miguelgrc/cap-moses. To test locally, go to ui/cap-react/package.json and change the uri for the cap-moses dependency to the location of the cap-moses project in your machine, and link it like this:

# from cap-moses: 
yarn link

# from cap:
yarn link cap-moses
yarn install

@miguelgrc miguelgrc force-pushed the externalize-editor branch 2 times, most recently from 878b0e3 to b69760f Compare November 14, 2023 17:33
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
@@ -76,7 +76,9 @@ const Files = ({
return choices[value];
};

return renderList.map(item => getContentFromProps(item));
return renderList.map(item => (
<div key={item}>{getContentFromProps(item)}</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add key inside getContentFromProps. also lets not use object as key (e.g. item)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using item as key should be fine in this case, as it's just a string (one of files|repositories|title)

@@ -14,7 +14,7 @@ const JSONSchemaPreviewer = ({
}) => {
return (
schema && (
<Form
<FormuleForm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not import(export from formule) as Form? do we need the Formule part?

{isAdmin && <Route path={CMS} component={AdminPage} />}
<Route path={HOME} component={requireAuth(IndexPage)} />
</Switch>
<FormuleContext
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this to wrap the whole app?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the reason is that we need to have access to the Formule context both from the admin pages and from the draft page, and having two FormuleContexts might be problematic. I think there was another important reason but I can't remember it now.

ui/cap-react/src/antd/admin/components/Header.js Outdated Show resolved Hide resolved
@@ -27,16 +26,14 @@ import { configSchema } from "../utils/schemaSettings";
import CodeViewer from "../../utils/CodeViewer";
import { json } from "@codemirror/lang-json";
import CodeDiffViewer from "../../utils/CodeDiffViewer";
import { FormuleForm } from "react-formule";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should export as Form from the formule package (makes more sense). we can import as as FormuleForm here if we want

import { schema, uiSchema } from "../utils";
import { DeleteOutlined } from "@ant-design/icons";
import { FormuleForm } from "react-formule";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

import { canEdit } from "../../utils/permissions";
import { debounce } from "lodash-es";
import { FormuleForm } from "react-formule";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

},
},
},
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add customFiteldTypes for CERNUsers, schemaPathSuggester components?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it as they're not used in the form editor. schemaPathSuggester is only used for notifications and, actually, CERNUsers is not used anywhere, do we need it?

import { ReactComponent as AtlasIcon } from "../img/atlas.svg";
import { ReactComponent as CmsIcon } from "../img/cms.svg";
import { ReactComponent as LHCbLogo } from "../img/lhcb-logo.svg";
import AliceIcon from "../img/alice.svg?react";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax has changed with the latest versions of vite-plugin-svgr

@pamfilos
Copy link
Collaborator

please rebase also

Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
Signed-off-by: Miguel Garcia Garcia <miguel.garcia.garcia@cern.ch>
@miguelgrc
Copy link
Contributor Author

Superseded by ##2878 which incorporates all these changes in a squashed commit

@miguelgrc miguelgrc closed this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants