-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revisions: add new selectors to fetch entity revisions (#54046)
* Fetching entity revisions using loaded name argument e.g., post:id:revisions Revisions loaded into state tree under revisions[parent] Invalidate revisions after saved entity Revisions url params are contained in entity config Testing with global styles - modifying CPT to show in rest Implementing thin API layer for Revisions over the getEntityRecords implementation Duplicated the logic in the selectors for revisions functions Added tests * Revert edit context query param when fetching post types Reverting timeout in performance tests. * Tidying up reducer, allowing revisions for posts and pages only * Adding types to the base entity records for revisions and global styles revisions. * Removed unnecessary REST API change for global styles: it was to pull in the CPT in the /types response, which we don't need for core-data since it's a root entity. * Remove duplicated queried-data reducer functions for revisions, and use them in the main reducer Create dedicated resolvers for getRevision/s, thereby removing the split name parsing required (name:id:revisions) Create dedicated action receivers for revisions Rename from getEntityRevisions to getRevisions Fully remove parseEntityName Updated selector tests Use queriedDataReducer shape for revisions. The queriedDataReducer doesn't need to know about the revisions action type. Update doc comments Updated CHANGELOG.md * This commit: - removes `hasRevisions` because it has no noticeable benefit, at least as far as I can see. I'm probably wrong. - removes the default revisions query context for the API call (the default is 'view' anyway) - fixes the revisions reducer - Add _fields logic to resolvers and selectors Adds basic reducer tests * updated variable names: parentId > recordKey, key > revisionKey removing lock-related code deleting `recordKey` from action object before sending to queriedDataReducer updating docs * Removing revisions when items are removed.
- Loading branch information
Showing
14 changed files
with
947 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/core-data/src/entity-types/global-styles-revision.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { Context, ContextualField, OmitNevers } from './helpers'; | ||
|
||
import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records'; | ||
|
||
declare module './base-entity-records' { | ||
export namespace BaseEntityRecords { | ||
export interface GlobalStylesRevision< C extends Context > { | ||
/** | ||
* The ID for the author of the global styles revision. | ||
*/ | ||
author: number; | ||
/** | ||
* The date the post global styles revision published, in the site's timezone. | ||
*/ | ||
date: string | null; | ||
/** | ||
* The date the global styles revision was published, as GMT. | ||
*/ | ||
date_gmt: ContextualField< string | null, 'view' | 'edit', C >; | ||
/** | ||
* Unique identifier for the revision. | ||
*/ | ||
id: number; | ||
/** | ||
* The date the global styles revision was last modified, in the site's timezone. | ||
*/ | ||
modified: ContextualField< string, 'view' | 'edit', C >; | ||
/** | ||
* The date the global styles revision was last modified, as GMT. | ||
*/ | ||
modified_gmt: ContextualField< string, 'view' | 'edit', C >; | ||
/** | ||
* Identifier for the parent of the revision. | ||
*/ | ||
parent: number; | ||
styles: Record< string, Object >; | ||
settings: Record< string, Object >; | ||
} | ||
} | ||
} | ||
|
||
export type GlobalStylesRevision< C extends Context = 'view' > = OmitNevers< | ||
_BaseEntityRecords.GlobalStylesRevision< C > | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.