Skip to content

Commit 44e3149

Browse files
committed
Introduce Posts & Post Types Selects
1 parent d691048 commit 44e3149

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4949
-3406
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
charset = utf-8
33
end_of_line = lf
44
indent_size = 4
5-
indent_style = space
5+
indent_style = tab
66
insert_final_newline = true
77
max_line_length = 120
88
tab_width = 4

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ const baseConfiguration = require('@wordpress/scripts/config/.eslintrc.js');
22

33
module.exports = {
44
...baseConfiguration,
5+
rules: {
6+
...baseConfiguration.rules,
7+
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
8+
},
59
settings: {
610
'import/resolver': {
711
typescript: {},

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/workflows/js-qa.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: JS Quality Assurance
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
paths:
10+
- '**/workflows/*js*'
11+
- '**.js'
12+
- '**.jsx'
13+
- '**.ts'
14+
- '**.tsx'
15+
- '**.json'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
if: "!github.event.pull_request.draft"
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Setup Node
26+
uses: actions/setup-node@v2
27+
with:
28+
cache: 'yarn'
29+
node-version: '16'
30+
31+
- name: Install
32+
run: yarn install
33+
34+
- name: Coding Style
35+
run: yarn cs
36+
37+
- name: Linting JavaScript
38+
run: yarn lint:js
39+
40+
- name: Unit Tests
41+
run: yarn test

.github/workflows/php-qa.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: PHP Quality Assurance
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
paths:
9+
- '**.php'
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
if: "!contains(github.event.head_commit.message, '--skip ci') && !github.event.pull_request.draft"
15+
strategy:
16+
matrix:
17+
php-versions: [ '8.0' ]
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-versions }}
26+
27+
- name: Check syntax error in sources
28+
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
29+
30+
- name: Install dependencies
31+
uses: "ramsey/composer-install@v1"
32+
33+
- name: Check code styles
34+
run: composer cs

.prettierignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
*.json
2-
*.scss
3-
*.css
4-
51
.psalm
62
.github
73

84
./coverage
95
./vendor
106
./node_modules
11-
./public
7+
./build

.prettierrc.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
const prettierConfig = require('@wordpress/scripts/config/.prettierrc.js')
1+
const prettierConfig = require('@wordpress/scripts/config/.prettierrc.js');
22

3-
module.exports = prettierConfig
3+
module.exports = {
4+
...prettierConfig,
5+
importOrder: [
6+
'<THIRD_PARTY_MODULES>',
7+
'^@jest/(.*)$',
8+
'^@testing-library/(.*)$',
9+
'^@faker-js/faker',
10+
'^@wordpress/(.*)$',
11+
'^[./]',
12+
],
13+
importOrderSeparation: true,
14+
importOrderSortSpecifiers: false,
15+
importOrderCaseInsensitive: false,
16+
};

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"php.suggest.basic": true,
3+
"php.validate.enable": true,
4+
"php.validate.executablePath": "/usr/bin/php",
5+
"php.format.codeStyle": "Off",
6+
"phpCodeSniffer.standardCustom": "./phpcs.xml",
7+
"phpCodeSniffer.standard": "Custom",
8+
"phpCodeSniffer.autoExecutable": true,
9+
"[php]": {
10+
"editor.defaultFormatter": "obliviousharmony.vscode-php-codesniffer"
11+
},
12+
"prettier.configPath": ".prettierrc.js"
13+
}

.wp-env.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{
2-
"core": "WordPress/WordPress",
3-
"plugins": [
4-
"."
5-
],
6-
"env": {
7-
"development": {
8-
"phpVersion": "8.0",
9-
"mappings": {
10-
"wp-content/plugins/entities-search": "."
11-
}
12-
}
13-
}
2+
"core": "./vendor/roots/wordpress-no-content",
3+
"plugins": ["."],
4+
"env": {
5+
"development": {
6+
"phpVersion": "8.0",
7+
"mappings": {
8+
"wp-content/plugins/entities-search": "."
9+
}
10+
}
11+
}
1412
}

@types/index.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import type { Set } from 'immutable';
2+
import React from 'react';
3+
4+
import { BaseEntityRecords, Context } from '@wordpress/core-data';
5+
6+
type ComponentStateAware<V> = {
7+
value: Set<V>;
8+
setValue(value: ComponentStateAware<V>['value']): void;
9+
};
10+
11+
export default EntitiesSearch;
12+
13+
declare namespace EntitiesSearch {
14+
type PostType<C extends Context = 'view'> = BaseEntityRecords.Type<C>;
15+
16+
type ViewablePostType = Readonly<{
17+
[K in keyof PostType<'edit'>]: K extends 'viewable'
18+
? true
19+
: PostType<'edit'>[K];
20+
}>;
21+
22+
type ControlOption<V extends any> = Readonly<{
23+
value: V;
24+
label: string;
25+
}>;
26+
27+
type ComponentStateAware<V> = {
28+
value: V;
29+
setValue(value: ComponentStateAware['value']): void;
30+
};
31+
32+
type EntitiesRecords<Entity> = Readonly<{
33+
records(): Set<Entity>;
34+
isResolving(): boolean;
35+
errored(): boolean;
36+
succeed(): boolean;
37+
}>;
38+
39+
/**
40+
* Components
41+
*/
42+
interface PostTypeSelect<V> {
43+
readonly value: V | null;
44+
readonly options: Set<ControlOption<V>>;
45+
readonly onChange: (value: PostTypeSelect<V>['value']) => void;
46+
}
47+
48+
interface PostsSelect<V> {
49+
readonly value: Set<V> | null;
50+
readonly options: Set<ControlOption<V>>;
51+
readonly onChange: (values: PostsSelect<V>['value']) => void;
52+
}
53+
54+
interface PostsController<P, T> {
55+
readonly postsComponent: React.ComponentType<
56+
ComponentStateAware<Set<P>>
57+
>;
58+
readonly typesComponent: React.ComponentType<ComponentStateAware<T>>;
59+
}
60+
}

0 commit comments

Comments
 (0)