|
1 | 1 | /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
| 2 | +import { getVersionFromId } from '@sanity/client/csm' |
2 | 3 | import { vercelStegaSplit } from '@vercel/stega'
|
3 | 4 | import groq from 'groq'
|
4 | 5 | import { q } from 'groqd'
|
@@ -189,10 +190,15 @@ const { query: tableQuery, schema: tableSchema } = q('*')
|
189 | 190 | .filter("_type == 'page'")
|
190 | 191 | .grab({
|
191 | 192 | _id: q.string(),
|
| 193 | + _originalId: q.string().optional(), |
192 | 194 | _createdAt: q.string().optional(),
|
193 | 195 | _updatedAt: q.string().optional(),
|
194 | 196 | title: q.string().optional(),
|
195 | 197 | status: q.select({
|
| 198 | + '_originalId in path("versions.**")': [ |
| 199 | + '"in release"', |
| 200 | + q.literal('in release'), |
| 201 | + ], |
196 | 202 | '_originalId in path("drafts.**")': ['"draft"', q.literal('draft')],
|
197 | 203 | default: ['"published"', q.literal('published')],
|
198 | 204 | }),
|
@@ -227,12 +233,17 @@ export function _Table(props: TableProps) {
|
227 | 233 | const { cleaned, encoded } = vercelStegaSplit(type._updatedAt!)
|
228 | 234 | const date = new Date(cleaned)
|
229 | 235 | return (
|
230 |
| - <tr key={type._id} data-created-at={type._createdAt}> |
| 236 | + <tr |
| 237 | + key={type._id} |
| 238 | + data-created-at={type._createdAt} |
| 239 | + data-original-id={type._originalId} |
| 240 | + data-id={type._id} |
| 241 | + > |
| 242 | + <td width={300}>{type.title}</td> |
231 | 243 | <td style={{ whiteSpace: 'nowrap' }} width={300}>
|
232 |
| - {type.title} |
233 |
| - </td> |
234 |
| - <td style={{ whiteSpace: 'nowrap' }} width={300}> |
235 |
| - {type.status} |
| 244 | + {type.status === 'in release' && type._originalId |
| 245 | + ? getVersionFromId(type._originalId) |
| 246 | + : type.status} |
236 | 247 | </td>
|
237 | 248 | <td style={{ whiteSpace: 'nowrap' }} width={300}>
|
238 | 249 | <time dateTime={type._updatedAt}>
|
|
0 commit comments