diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js index ba4e8bcbab..3e20c5d154 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/DataManagerProvider/index.js @@ -105,6 +105,7 @@ const DataManagerProvider = ({ children }) => { contentTypes, createSchema, initialData, + isInContentTypeView, modifiedData, setModifiedData, }} diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js index 7d5d9b1ae8..037a522092 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/FormModal/index.js @@ -244,7 +244,8 @@ const FormModal = () => { > @@ -296,7 +297,7 @@ const FormModal = () => {
)} diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ListPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ListPage/index.js index 273e2e0741..4cadda30d8 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ListPage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ListPage/index.js @@ -1,5 +1,5 @@ import React, { useEffect, useRef } from 'react'; -import { useLocation } from 'react-router-dom'; +import { useHistory, useLocation } from 'react-router-dom'; import { get } from 'lodash'; import { ViewContainer } from 'strapi-helper-plugin'; import useDataManager from '../../hooks/useDataManager'; @@ -7,7 +7,13 @@ import LeftMenu from '../LeftMenu'; const ListPage = () => { const { pathname } = useLocation(); - const { modifiedData, setModifiedData } = useDataManager(); + const { + initialData, + modifiedData, + isInContentTypeView, + setModifiedData, + } = useDataManager(); + const { push } = useHistory(); const setModifiedDataRef = useRef(); setModifiedDataRef.current = setModifiedData; @@ -16,13 +22,25 @@ const ListPage = () => { }, [pathname]); const attributes = get(modifiedData, ['schema', 'attributes'], {}); + + const handleClick = () => { + const currentDataName = get(initialData, ['schema', 'name'], ''); + const forTarget = isInContentTypeView ? 'contentType' : 'component'; + const search = `modalType=chooseAttribute&forTarget=${forTarget}&targetr=${currentDataName}`; + push({ search }); + }; + console.log({ allSchema: modifiedData }); + return (
+
    {Object.keys(attributes).map(attr => (
  • {attr}