@contentful/field-editor-shared 3.0.2 → 3.0.3-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -166,8 +166,14 @@ function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCode, defa
166
166
  }
167
167
  return titleOrDefault(title, defaultTitle);
168
168
  }
169
+ function getLocaleStatusObject(sys) {
170
+ if ('localeStatus' in sys) {
171
+ return sys.localeStatus;
172
+ }
173
+ return sys.fieldStatus?.['*'];
174
+ }
169
175
  function getEntityStatus(sys, localeCodes) {
170
- if (!sys || sys.type !== 'Entry' && sys.type !== 'Asset') {
176
+ if (!sys) {
171
177
  throw new TypeError('Invalid entity metadata object');
172
178
  }
173
179
  if (sys.deletedVersion) {
@@ -176,19 +182,20 @@ function getEntityStatus(sys, localeCodes) {
176
182
  if (sys.archivedVersion) {
177
183
  return 'archived';
178
184
  }
179
- if (sys.fieldStatus && localeCodes) {
185
+ const localeStatus = getLocaleStatusObject(sys);
186
+ if (localeStatus && localeCodes) {
180
187
  let status = 'draft';
181
188
  const locales = Array.isArray(localeCodes) ? localeCodes : [
182
189
  localeCodes
183
190
  ];
184
- for (const [localeCode, fieldStatus] of Object.entries(sys.fieldStatus['*'])){
191
+ for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
185
192
  if (!locales || locales.includes(localeCode)) {
186
- if (fieldStatus === 'changed') {
187
- status = fieldStatus;
193
+ if (localeStatusValue === 'changed') {
194
+ status = localeStatusValue;
188
195
  break;
189
196
  }
190
- if (fieldStatus === 'published') {
191
- status = fieldStatus;
197
+ if (localeStatusValue === 'published') {
198
+ status = localeStatusValue;
192
199
  }
193
200
  }
194
201
  }
@@ -116,8 +116,14 @@ export function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCod
116
116
  }
117
117
  return titleOrDefault(title, defaultTitle);
118
118
  }
119
+ function getLocaleStatusObject(sys) {
120
+ if ('localeStatus' in sys) {
121
+ return sys.localeStatus;
122
+ }
123
+ return sys.fieldStatus?.['*'];
124
+ }
119
125
  export function getEntityStatus(sys, localeCodes) {
120
- if (!sys || sys.type !== 'Entry' && sys.type !== 'Asset') {
126
+ if (!sys) {
121
127
  throw new TypeError('Invalid entity metadata object');
122
128
  }
123
129
  if (sys.deletedVersion) {
@@ -126,19 +132,20 @@ export function getEntityStatus(sys, localeCodes) {
126
132
  if (sys.archivedVersion) {
127
133
  return 'archived';
128
134
  }
129
- if (sys.fieldStatus && localeCodes) {
135
+ const localeStatus = getLocaleStatusObject(sys);
136
+ if (localeStatus && localeCodes) {
130
137
  let status = 'draft';
131
138
  const locales = Array.isArray(localeCodes) ? localeCodes : [
132
139
  localeCodes
133
140
  ];
134
- for (const [localeCode, fieldStatus] of Object.entries(sys.fieldStatus['*'])){
141
+ for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
135
142
  if (!locales || locales.includes(localeCode)) {
136
- if (fieldStatus === 'changed') {
137
- status = fieldStatus;
143
+ if (localeStatusValue === 'changed') {
144
+ status = localeStatusValue;
138
145
  break;
139
146
  }
140
- if (fieldStatus === 'published') {
141
- status = fieldStatus;
147
+ if (localeStatusValue === 'published') {
148
+ status = localeStatusValue;
142
149
  }
143
150
  }
144
151
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { LocaleProps, EntryProps, AssetProps, ScheduledActionProps } from 'contentful-management';
3
3
  import { LocalePublishStatusMap } from '../hooks/useLocalePublishStatus';
4
4
  type LocalePublishingPopoverProps = {
5
- entity: EntryProps | AssetProps;
5
+ entity: Pick<EntryProps | AssetProps, 'sys'>;
6
6
  jobs: ScheduledActionProps[];
7
7
  isScheduled: boolean;
8
8
  activeLocales?: Pick<LocaleProps, 'code'>[];
@@ -56,8 +56,8 @@ export declare function getEntryTitle({ entry, contentType, localeCode, defaultL
56
56
  defaultLocaleCode: string;
57
57
  defaultTitle: string;
58
58
  }): string;
59
- type FieldStatus = 'draft' | 'published' | 'changed';
60
59
  export type EntitySys = Entry['sys'] | Asset['sys'];
60
+ type FieldStatus = 'draft' | 'published' | 'changed';
61
61
  /**
62
62
  * Returns the status of the entry/asset
63
63
  * If a locale code(s) is provided it will pick up the most advanced state for these locale(s)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-shared",
3
- "version": "3.0.2",
3
+ "version": "3.0.3-canary.5+94ef1729",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "registry": "https://npm.pkg.github.com/"
75
75
  },
76
- "gitHead": "239652e45817d91debf8b4caa8648031689967e2"
76
+ "gitHead": "94ef172917e9ba087156ad6a8765507905fecaaf"
77
77
  }