Skip to content

Commit 7366274

Browse files
ntsekourastyxla
andauthored
Experiment: Content types reuse createStatusAction (#78102)
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
1 parent 69090de commit 7366274

14 files changed

Lines changed: 42 additions & 159 deletions

File tree

packages/content-types/src/post-types/actions/activate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import { __, _n, sprintf } from '@wordpress/i18n';
66
/**
77
* Internal dependencies
88
*/
9-
import { createStatusAction } from './utils';
9+
import { createStatusAction } from '../../utils/actions';
10+
import { POST_TYPE_ENTITY } from '../../constants';
11+
import type { PostTypeFormData } from '../types';
1012

11-
const activateAction = createStatusAction( {
13+
const activateAction = createStatusAction< PostTypeFormData >( {
1214
id: 'activate',
1315
label: __( 'Activate' ),
16+
entity: POST_TYPE_ENTITY,
1417
targetStatus: 'publish',
1518
messages: {
1619
successSingle: __( 'Post type activated.' ),

packages/content-types/src/post-types/actions/deactivate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import { __, _n, sprintf } from '@wordpress/i18n';
66
/**
77
* Internal dependencies
88
*/
9-
import { createStatusAction } from './utils';
9+
import { createStatusAction } from '../../utils/actions';
10+
import { POST_TYPE_ENTITY } from '../../constants';
11+
import type { PostTypeFormData } from '../types';
1012

11-
const deactivateAction = createStatusAction( {
13+
const deactivateAction = createStatusAction< PostTypeFormData >( {
1214
id: 'deactivate',
1315
label: __( 'Deactivate' ),
16+
entity: POST_TYPE_ENTITY,
1417
targetStatus: 'draft',
1518
messages: {
1619
successSingle: __( 'Post type deactivated.' ),

packages/content-types/src/post-types/actions/delete.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { Stack, Text } from '@wordpress/ui';
1414
/**
1515
* Internal dependencies
1616
*/
17-
import type { CoreDataError, PostTypeFormData } from '../types';
17+
import type { PostTypeFormData } from '../types';
18+
import type { CoreDataError } from '../../types';
1819
import { POST_TYPE_ENTITY } from '../../constants';
1920

2021
function DeletePostTypeModal( {

packages/content-types/src/post-types/actions/duplicate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import { Stack } from '@wordpress/ui';
2323
import { useSlugField } from '../fields/general';
2424
import { pluralLabelField, singularLabelField } from '../../utils/fields';
2525
import { serializeForSave } from '../utils';
26-
import type { CoreDataError, PostTypeFormData } from '../types';
26+
import type { PostTypeFormData } from '../types';
27+
import type { CoreDataError } from '../../types';
2728
import { POST_TYPE_ENTITY } from '../../constants';
2829

2930
const SLUG_MAX_LENGTH = 20;

packages/content-types/src/post-types/actions/utils.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.

packages/content-types/src/post-types/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,3 @@ export interface PostTypeFormData extends ContentType {
8686
has_archive: boolean;
8787
};
8888
}
89-
90-
export type CoreDataError = { message?: string; code?: string };

packages/content-types/src/taxonomies/actions/activate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import { __, _n, sprintf } from '@wordpress/i18n';
66
/**
77
* Internal dependencies
88
*/
9-
import { createStatusAction } from './utils';
9+
import { createStatusAction } from '../../utils/actions';
10+
import { TAXONOMY_ENTITY } from '../../constants';
11+
import type { TaxonomyFormData } from '../types';
1012

11-
const activateAction = createStatusAction( {
13+
const activateAction = createStatusAction< TaxonomyFormData >( {
1214
id: 'activate',
1315
label: __( 'Activate' ),
16+
entity: TAXONOMY_ENTITY,
1417
targetStatus: 'publish',
1518
messages: {
1619
successSingle: __( 'Taxonomy activated.' ),

packages/content-types/src/taxonomies/actions/deactivate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import { __, _n, sprintf } from '@wordpress/i18n';
66
/**
77
* Internal dependencies
88
*/
9-
import { createStatusAction } from './utils';
9+
import { createStatusAction } from '../../utils/actions';
10+
import { TAXONOMY_ENTITY } from '../../constants';
11+
import type { TaxonomyFormData } from '../types';
1012

11-
const deactivateAction = createStatusAction( {
13+
const deactivateAction = createStatusAction< TaxonomyFormData >( {
1214
id: 'deactivate',
1315
label: __( 'Deactivate' ),
16+
entity: TAXONOMY_ENTITY,
1417
targetStatus: 'draft',
1518
messages: {
1619
successSingle: __( 'Taxonomy deactivated.' ),

packages/content-types/src/taxonomies/actions/delete.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { Stack, Text } from '@wordpress/ui';
1414
/**
1515
* Internal dependencies
1616
*/
17-
import type { CoreDataError, TaxonomyFormData } from '../types';
17+
import type { TaxonomyFormData } from '../types';
18+
import type { CoreDataError } from '../../types';
1819
import { TAXONOMY_ENTITY } from '../../constants';
1920

2021
function DeleteTaxonomyModal( {

packages/content-types/src/taxonomies/actions/duplicate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import { Stack } from '@wordpress/ui';
2323
import { useSlugField } from '../fields/general';
2424
import { pluralLabelField, singularLabelField } from '../../utils/fields';
2525
import { serializeForSave } from '../utils';
26-
import type { CoreDataError, TaxonomyFormData } from '../types';
26+
import type { TaxonomyFormData } from '../types';
27+
import type { CoreDataError } from '../../types';
2728
import { TAXONOMY_ENTITY } from '../../constants';
2829

2930
const SLUG_MAX_LENGTH = 32;

0 commit comments

Comments
 (0)