@contentful/field-editor-shared 3.0.2 → 3.1.0
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,6 +166,12 @@ 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
176
|
if (!sys || sys.type !== 'Entry' && sys.type !== 'Asset') {
|
|
171
177
|
throw new TypeError('Invalid entity metadata object');
|
|
@@ -176,19 +182,20 @@ function getEntityStatus(sys, localeCodes) {
|
|
|
176
182
|
if (sys.archivedVersion) {
|
|
177
183
|
return 'archived';
|
|
178
184
|
}
|
|
179
|
-
|
|
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,
|
|
191
|
+
for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
|
|
185
192
|
if (!locales || locales.includes(localeCode)) {
|
|
186
|
-
if (
|
|
187
|
-
status =
|
|
193
|
+
if (localeStatusValue === 'changed') {
|
|
194
|
+
status = localeStatusValue;
|
|
188
195
|
break;
|
|
189
196
|
}
|
|
190
|
-
if (
|
|
191
|
-
status =
|
|
197
|
+
if (localeStatusValue === 'published') {
|
|
198
|
+
status = localeStatusValue;
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
}
|
|
@@ -116,6 +116,12 @@ 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
126
|
if (!sys || sys.type !== 'Entry' && sys.type !== 'Asset') {
|
|
121
127
|
throw new TypeError('Invalid entity metadata object');
|
|
@@ -126,19 +132,20 @@ export function getEntityStatus(sys, localeCodes) {
|
|
|
126
132
|
if (sys.archivedVersion) {
|
|
127
133
|
return 'archived';
|
|
128
134
|
}
|
|
129
|
-
|
|
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,
|
|
141
|
+
for (const [localeCode, localeStatusValue] of Object.entries(localeStatus)){
|
|
135
142
|
if (!locales || locales.includes(localeCode)) {
|
|
136
|
-
if (
|
|
137
|
-
status =
|
|
143
|
+
if (localeStatusValue === 'changed') {
|
|
144
|
+
status = localeStatusValue;
|
|
138
145
|
break;
|
|
139
146
|
}
|
|
140
|
-
if (
|
|
141
|
-
status =
|
|
147
|
+
if (localeStatusValue === 'published') {
|
|
148
|
+
status = localeStatusValue;
|
|
142
149
|
}
|
|
143
150
|
}
|
|
144
151
|
}
|
|
@@ -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
|
|
3
|
+
"version": "3.1.0",
|
|
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": "
|
|
76
|
+
"gitHead": "6df6424638effc6fb12906499a369f4a0019866f"
|
|
77
77
|
}
|