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

[sitecore-jss] Update models: Add url and id property to item type #1219

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

pzi
Copy link
Contributor

@pzi pzi commented Oct 28, 2022

Description / Motivation

Adding two extra fields (id & url) to the Item interface in models to be able to properly type incoming data.

The data that is coming from Sitecore seems to have these extra 2 fields on it, see example:

  paymentFrequencies: [
      {
        id: '7b7ff13f-f7af-4dc7-8612-baf46a61659a',
        url: '/data/reference-data/payment-frequencies/fortnightly',
        name: 'Fortnightly',
        displayName: 'Fortnightly',
        fields: {
          label: {
            value: 'due on {date}',
          },
          value: {
            value: 'Fortnightly',
          },
          name: {
            value: 'Fortnightly',
          },
        },
      },
      {
        id: '63e0d50e-b123-4783-8817-b42ebbdc4d0e',
        url: '/data/reference-data/payment-frequencies/four-weekly',
        name: 'Four weekly',
        displayName: 'Four weekly',
        fields: {
          label: {
            value: 'due on {date}',
          },
          value: {
            value: 'Four weekly',
          },
          name: {
            value: '4Weekly',
          },
        },
      },
]

Having these 2 extra fields allows to properly type the rendering props:

export interface ComponentProps {
  fields: {
    paymentFrequencies: Item[];
  };
  rendering: ComponentRendering;
}

Testing Details

No effects on other data as the fields are marked optional.

Types of changes

  • New feature (non-breaking change which adds functionality)

@pzi
Copy link
Contributor Author

pzi commented Nov 2, 2022

@ambrauer would you be able to provide some feedback on this and #1220 please?

@pzi pzi changed the title Update models: Add url and id property to item type [sitecore-jss] Update models: Add url and id property to item type Nov 2, 2022
@ambrauer
Copy link
Contributor

ambrauer commented Nov 2, 2022

@ambrauer would you be able to provide some feedback on this and #1220 please?

@pzi This PR looks great, thanks for the contribution! The other PR is being addressed with #1226 which expands on this a bit.

@ambrauer ambrauer merged commit ece5908 into Sitecore:dev Nov 2, 2022
@pzi
Copy link
Contributor Author

pzi commented Nov 3, 2022

Awesome, thanks @ambrauer. I don't suppose this will make it into latest v20? We currently are not in a position to go v21 just yet.

@pzi pzi deleted the patch-1 branch November 3, 2022 01:09
@ambrauer
Copy link
Contributor

ambrauer commented Nov 3, 2022

@pzi We don't have any plans for another v20 release. Your best bet would be to go through Sitecore Support (if this is preventing you from launching your site on v20, for example) in which case we would release this as a hotfix for v20.

@pzi
Copy link
Contributor Author

pzi commented Nov 17, 2022

Fair enough @ambrauer, will see how we go for a Sitecore support ticket. It's not stopping us from launching as we have type augmentation in place, but it'd just be nicer to have it all straight from the horses mouth, e.g. this package 👯

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