Skip to content

Commit

Permalink
display sync status field
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Jan 4, 2024
1 parent a8a3ce3 commit b86cbd2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/dataviews/src/view-grid.js
Expand Up @@ -30,7 +30,6 @@ export default function ViewGrid( {
);
const visibleFields = fields.filter(
( field ) =>
!! field.render &&
! view.hiddenFields.includes( field.id ) &&
! [ view.layout.mediaField, view.layout.primaryField ].includes(
field.id
Expand Down Expand Up @@ -88,7 +87,7 @@ export default function ViewGrid( {
{ field.header }
</div>
<div className="dataviews-view-grid__field-value">
{ field.render( { item } ) }
{ renderedValue }
</div>
</VStack>
);
Expand Down
1 change: 0 additions & 1 deletion packages/dataviews/src/view-list.js
Expand Up @@ -32,7 +32,6 @@ export default function ViewList( {
);
const visibleFields = fields.filter(
( field ) =>
!! field.render &&
! view.hiddenFields.includes( field.id ) &&
! [ view.layout.primaryField, view.layout.mediaField ].includes(
field.id
Expand Down
1 change: 0 additions & 1 deletion packages/dataviews/src/view-table.js
Expand Up @@ -300,7 +300,6 @@ function ViewTable( {
} ) {
const visibleFields = fields.filter(
( field ) =>
!! field.render &&
! view.hiddenFields.includes( field.id ) &&
! [ view.layout.mediaField, view.layout.primaryField ].includes(
field.id
Expand Down
Expand Up @@ -78,7 +78,7 @@ const DEFAULT_VIEW = {
search: '',
page: 1,
perPage: 20,
hiddenFields: [],
hiddenFields: [ 'sync-status' ],
layout: {
...defaultConfigPerViewType[ LAYOUT_GRID ],
},
Expand Down Expand Up @@ -260,13 +260,22 @@ export default function DataviewsPatterns() {
_fields.push( {
header: __( 'Sync Status' ),
id: 'sync-status',
render: ( { item } ) => {
// User patterns can have their sync statuses checked directly.
// Non-user patterns are all unsynced for the time being.
const [ , notSyncedStatus ] = SYNC_FILTERS;
return ! item.syncStatus
? notSyncedStatus.label
: SYNC_FILTERS.find(
( { value } ) => value === item.syncStatus
)?.label;
},
type: ENUMERATION_TYPE,
elements: SYNC_FILTERS,
filterBy: {
operators: [ OPERATOR_IN ],
},
enableSorting: false,
enableHiding: false,
} );
}
return _fields;
Expand Down Expand Up @@ -348,7 +357,7 @@ export default function DataviewsPatterns() {
view={ view }
onChangeView={ onChangeView }
deferredRendering={ true }
supportedLayouts={ [ LAYOUT_GRID, 'table' ] }
supportedLayouts={ [ LAYOUT_GRID ] }
/>
</Page>
</ExperimentalBlockEditorProvider>
Expand Down

0 comments on commit b86cbd2

Please sign in to comment.