diff --git a/.github/workflows/test-on-pr.yml b/.github/workflows/test-on-pr.yml new file mode 100644 index 000000000..a53ded8c1 --- /dev/null +++ b/.github/workflows/test-on-pr.yml @@ -0,0 +1,32 @@ +name: Test on PR + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - "packages/**" + - "plugins/wp-react-blocks-plugin/**" + - "pnpm-workspace.yaml" + - "package.json" + - "pnpm-lock.yaml" + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/actions/setup + + - name: Run PNPM Build + run: pnpm run build \ No newline at end of file diff --git a/plugins/wp-react-blocks-plugin/blocks/filter/BlockEdit.js b/plugins/wp-react-blocks-plugin/blocks/filter/BlockEdit.js index b0f8c26b6..fd19d98bb 100644 --- a/plugins/wp-react-blocks-plugin/blocks/filter/BlockEdit.js +++ b/plugins/wp-react-blocks-plugin/blocks/filter/BlockEdit.js @@ -254,46 +254,51 @@ class BlockEdit extends BlockEditWithAPIMetadata { } - {app != 'csv' && this.state.filters && - - { - if (param != '') { - const type = this.state.filters.filter(f => f.param === param)[0].type - setAttributes({ param, type, hiddenFilters: [], defaultValues: "" }) - } else { - setAttributes({ param: "", type: "", hiddenFilters: [], defaultValues: "" }) - } - }} - help={__('Select the main filter parameter.')} - /> - - - - - - { - if (parentFilter && parentFilter !== "") { - const parentFilterObj = this.state.filters.find(f => f.value === parentFilter); - if (parentFilterObj) { - setAttributes({ parentFilter, parentFilterParam: parentFilterObj.param }); - } - } else { - setAttributes({ parentFilter: "", parentFilterParam: "" }); - } - }} /> - + {app && app !== 'csv' && + {this.state.filters ? ( + <> + + { + if (param != '') { + const type = this.state.filters.filter(f => f.param === param)[0].type + setAttributes({ param, type, hiddenFilters: [], defaultValues: "" }) + } else { + setAttributes({ param: "", type: "", hiddenFilters: [], defaultValues: "" }) + } + }} + help={__('Select the main filter parameter.')} + /> + + + { + if (parentFilter && parentFilter !== "") { + const parentFilterObj = this.state.filters.find(f => f.value === parentFilter); + if (parentFilterObj) { + setAttributes({ parentFilter, parentFilterParam: parentFilterObj.param }); + } + } else { + setAttributes({ parentFilter: "", parentFilterParam: "" }); + } + }} /> + + + ) : ( + +

{__('Loading filter options...')}

+
+ )}
} - {app == 'csv' && this.state.filters && + {app && app === 'csv' && setAttributes({ param })} @@ -321,7 +326,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { help={__('How to determine the default value.')} /> - {defaultValueCriteria == DEFAULT_VALUE_INPUT && + {defaultValueCriteria === DEFAULT_VALUE_INPUT && setAttributes({ defaultValues })} help={__("Manually specified default values.")} @@ -338,7 +343,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { onChange={(filterType) => { setAttributes({ filterType: filterType, isRange: filterType == "range" }) }} - options={app == 'csv' ? [{ + options={app === 'csv' ? [{ label: "Multi select", value: "multi-select" }, { label: "Single select", value: "single-select" }, { @@ -369,7 +374,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { /> } - {app != 'csv' && + {app !== 'csv' && setAttributes({ useFilterItems: !useFilterItems, filters: [], hiddenFilters: [] })} /> - {useFilterItems && @@ -506,7 +511,7 @@ class BlockEdit extends BlockEditWithAPIMetadata { help={__("Show a message when filter list is empty is empty.")} /> - {filterType == "multi-select" && <> + {filterType === "multi-select" && <>