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

How to display a custom app within an entrty? Widgetnamespace = 'app' #1415

Open
NateWichman opened this issue May 12, 2023 · 5 comments
Open
Labels
stale Used to mark when there was no activity for a set period of time

Comments

@NateWichman
Copy link

I have an app that overrides an entry. I am trying to display all the fields. One of the fields is a another custom JSON app. That app comes up blank when I pass in it's widgetId (the widgetnamespace is 'app'). Is there any way around this?

import { useEffect, useMemo } from "react"
import { EditorAppSDK, FieldAppSDK } from "@contentful/app-sdk"
import {
  Field as BaseField,
  FieldWrapper,
} from "@contentful/default-field-editors"
import { Heading, Subheading } from "@contentful/f36-components"
import { /* useCMA, */ useSDK } from "@contentful/react-apps-toolkit"

import styles from "./EntryEditor.module.css"

const Entry = () => {
  const sdk = useSDK<EditorAppSDK>()

  const getFieldAPI = (fieldId: string, sdk: EditorAppSDK) =>
    sdk.entry.fields[fieldId].getForLocale(sdk.locales.default)

  const getFieldExtensionSdk = (fieldId: string, sdk: EditorAppSDK) =>
    Object.assign({ field: getFieldAPI(fieldId, sdk) }, sdk)

  const fields = useMemo(
    () =>
      Object.values(sdk.entry.fields).map((field) => {
        const control = sdk.editor.editorInterface.controls!.find(
          (control) => control.fieldId === field.id
        )
        return {
          field,
          sdk: getFieldExtensionSdk(field.id, sdk),
          control,
        }
      }),
    [sdk.entry.fields]
  )

  return (
    <div>

      {fields.map((f) => (
        <FieldWrapper
          key={f.field.id}
          sdk={f.sdk as FieldAppSDK}
          name={f.field.id}
        >
          <div>{f.control?.widgetId}</div>

          <BaseField
            sdk={f.sdk as FieldAppSDK}
            isInitiallyDisabled={false}
            widgetId={f.control?.widgetId}
          />
        </FieldWrapper>
      ))}
    </div>
  )
}

export default Entry

@github-actions
Copy link

Marking issue as stale since there was no activity for 30 days

@github-actions github-actions bot added the stale Used to mark when there was no activity for a set period of time label Jun 12, 2023
@prashantpalikhe
Copy link

Would also like to have a solution to this issue.

@github-actions github-actions bot removed the stale Used to mark when there was no activity for a set period of time label Jun 27, 2023
@github-actions
Copy link

Marking issue as stale since there was no activity for 30 days

@github-actions github-actions bot added the stale Used to mark when there was no activity for a set period of time label Jul 28, 2023
@NorthMcCormick
Copy link

I have been looking for a solution to this as well, but I have come up empty handed. I believe this should be addressed as either a limitation of the system or if it is not, we would like an example of how to render the custom fields from other apps.

@github-actions github-actions bot removed the stale Used to mark when there was no activity for a set period of time label Sep 12, 2023
@github-actions
Copy link

Marking issue as stale since there was no activity for 30 days

@github-actions github-actions bot added the stale Used to mark when there was no activity for a set period of time label Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Used to mark when there was no activity for a set period of time
Projects
None yet
Development

No branches or pull requests

3 participants