Skip to content

Commit

Permalink
Merge pull request #20207 from akeneo/backport-20230824
Browse files Browse the repository at this point in the history
Backport 20230824
  • Loading branch information
tseho authored Aug 31, 2023
2 parents e3c673c + ed0d8f3 commit 7a8c885
Show file tree
Hide file tree
Showing 1,185 changed files with 19,083 additions and 4,589 deletions.
2 changes: 1 addition & 1 deletion .circleci/jobs/features/other.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
docker/wait_docker_up.sh
- run:
name: Install database
command: APP_ENV=prod O="--catalog src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/icecat_demo_dev" make database
command: APP_ENV=prod O="--catalog src/Akeneo/Platform/Installer/back/src/Infrastructure/Symfony/Resources/fixtures/icecat_demo_dev" make database
- run:
name: Launch Cypress
command: CYPRESS_defaultCommandTimeout=10000 CYPRESS_requestTimeout=15000 CYPRESS_responseTimeout=50000 make end-to-end-front
Expand Down
98 changes: 10 additions & 88 deletions .circleci/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,14 @@ workflows:
branches:
ignore:
- master
- checkout_ee:
- checkout_ce:
requires:
- ready_to_build?
- build_dev:
path_to_front_packages: vendor/akeneo/pim-community-dev/front-packages
requires:
- checkout_ee
- build_prod:
requires:
- checkout_ee
- test_deploy:
requires:
- build_prod
- deploy_pr_environment?:
type: approval
filters:
branches:
ignore:
- master
- deploy_pr_environment:
requires:
- deploy_pr_environment?
- build_prod
- delete_pr_environment?:
type: approval
filters:
branches:
ignore:
- master
requires:
- deploy_pr_environment
- delete_pr_environment:
requires:
- delete_pr_environment?
- test_database:
is_ee_built: false
requires:
- build_dev
- test_job_declaration:
- checkout_ce
- cypress_sanity_checks:
requires:
- build_dev
- test_back_static_and_acceptance:
Expand All @@ -62,65 +32,17 @@ workflows:
- test_back_phpunit:
requires:
- build_dev
- test_onboarder_bundle:
requires:
- build_dev
- test_back_data_migrations:
requires:
- test_back_static_and_acceptance
- test_front_static_acceptance_and_integration
- test_back_phpunit
- test_back_behat_legacy:
requires:
- test_back_static_and_acceptance
- test_front_static_acceptance_and_integration
- test_back_phpunit
- ready_to_build_only_ce?:
type: approval
filters:
branches:
ignore:
- master
- checkout_ce:
requires:
- ready_to_build_only_ce?
- build_dev:
name: build_dev_ce
is_ee_built: false
requires:
- checkout_ce
- cypress_sanity_checks:
name: cypress_sanity_checks_ce
requires:
- build_dev_ce
- test_back_static_and_acceptance:
name: test_back_static_and_acceptance_ce
requires:
- build_dev_ce
- test_front_static_acceptance_and_integration:
name: test_front_static_acceptance_and_integration_ce
requires:
- build_dev_ce
- test_back_phpunit:
name: test_back_phpunit_ce
requires:
- build_dev_ce
- test_back_data_migrations:
name: test_back_data_migrations_ce
requires:
- test_back_phpunit_ce
- build_dev
- test_back_behat_legacy:
name: test_back_behat_legacy_ce
requires:
- test_back_static_and_acceptance_ce
- test_front_static_acceptance_and_integration_ce
- test_back_phpunit_ce

- build_dev
- pull_request_success:
requires:
- cypress_sanity_checks
- test_back_phpunit
- test_back_static_and_acceptance
- test_front_static_acceptance_and_integration
- test_back_behat_legacy
- test_back_data_migrations
- test_onboarder_bundle
- test_database
- test_job_declaration
- test_back_behat_legacy_ce
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pim-dev:
$(MAKE) front-packages
$(MAKE) javascript-dev
docker/wait_docker_up.sh
APP_ENV=dev O="--catalog src/Akeneo/Platform/Bundle/InstallerBundle/Resources/fixtures/icecat_demo_dev" $(MAKE) database
APP_ENV=dev O="--catalog src/Akeneo/Platform/Installer/back/src/Infrastructure/Symfony/Resources/fixtures/icecat_demo_dev" $(MAKE) database

.PHONY: pim-prod
pim-prod:
Expand Down
56 changes: 56 additions & 0 deletions bin/backport.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

set -eu

git remote add pim-enterprise-dev [email protected]:akeneo/pim-enterprise-dev.git || true
git fetch --all

git cherry-pick --abort || true
git reset --hard origin/master
git clean -fd

LAST_TAG=$(git show origin/master:last_backport.txt || echo "monorepo")
DIRECTORIES=(
frontend/build
frontend/webpack
components/identifier-generator
src/Acme
src/Akeneo
src/Behat
src/Oro
front-packages/akeneo-design-system
front-packages/shared
upgrades/schema
upgrades/test_schema
tests
)
COMMITS=$(git log --reverse --first-parent --pretty=format:"%h" ${LAST_TAG}..pim-enterprise-dev/master ${DIRECTORIES[@]})

for commit in ${COMMITS[@]}; do
message="$(git log --format=%s -n 1 ${commit})"
author="$(git log --format='%an <%ae>' -n 1 ${commit})"
date="$(git log --format='%ad' -n 1 ${commit})"

echo ${commit} ${message} ${date}

git cherry-pick --allow-empty -Xtheirs -Xfind-renames --no-commit -m 1 ${commit} || true
git reset HEAD

if [ -d "tests/community" ]
then
rsync -av tests/community/ tests/
rm -rf tests/enterprise/ tests/community/
fi

find tests/ -type f -exec perl -pi -e "s#tests/community#tests#g" {} +
sed -i 's#(string) new Path('"'"'tests'"'"', '"'"'community'"'"'#(string) new Path('"'"'tests'"'"'#' tests/back/Integration/IntegrationTestsBundle/Configuration/Catalog.php

git add ${DIRECTORIES[@]}
git checkout .
git clean -fd
git commit --allow-empty --message="${message}" --author="${author}" --date="${date}"
done

git log --first-parent pim-enterprise-dev/master --pretty=format:"%h" -n 1 > last_backport.txt
git add last_backport.txt
git commit -m "Updates last commit backported"
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Akeneo\Pim\Automation\IdentifierGenerator\Infrastructure\Controller;

use Akeneo\Pim\Automation\IdentifierGenerator\Application\Get\GetNomenclatureQuery;
use Akeneo\Pim\Automation\IdentifierGenerator\Application\Exception\UndefinedAttributeException;
use Akeneo\Pim\Automation\IdentifierGenerator\Application\Exception\UnexpectedAttributeTypeException;
use Akeneo\Pim\Automation\IdentifierGenerator\Application\Get\GetNomenclatureHandler;
use Akeneo\Pim\Automation\IdentifierGenerator\Application\Get\GetNomenclatureQuery;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -32,10 +32,13 @@ public function __invoke(Request $request, string $propertyCode): Response
return new RedirectResponse('/');
}

$query = new GetNomenclatureQuery($propertyCode);

try {
return new JsonResponse(($this->getNomenclatureHandler)($query));
$nomenclature = ($this->getNomenclatureHandler)(new GetNomenclatureQuery($propertyCode));
if ([] === $nomenclature['values']) {
$nomenclature['values'] = (object)[];
}

return new JsonResponse($nomenclature);
} catch (UndefinedAttributeException $e) {
throw new NotFoundHttpException($e->getMessage());
} catch (UnexpectedAttributeTypeException $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Akeneo\Pim\Automation\IdentifierGenerator\Infrastructure\Symfony\Install;

use Akeneo\Platform\Bundle\InstallerBundle\Event\InstallerEvents;
use Akeneo\Platform\Installer\Infrastructure\Event\InstallerEvents;
use Doctrine\DBAL\Connection;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Akeneo\Pim\Enrichment\Component\Product\Factory\WriteValueCollectionFactory;
use Akeneo\Pim\Enrichment\Component\Product\Model\Product;
use Akeneo\Pim\Enrichment\Component\Product\Model\ProductInterface;
use Akeneo\Platform\Bundle\InstallerBundle\Command\ZddMigration;
use Akeneo\Platform\Installer\Infrastructure\Command\ZddMigration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Types\Types;
use Psr\Log\LoggerInterface;
Expand Down
4 changes: 2 additions & 2 deletions components/identifier-generator/back/tests/.php_cd.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
'Akeneo\Pim\Structure\Component\Model\AttributeInterface',
'Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface',
'Akeneo\Pim\Structure\Family\ServiceAPI',
'Akeneo\Platform\Bundle\InstallerBundle\Command\ZddMigration',
'Akeneo\Platform\Bundle\InstallerBundle\Event\InstallerEvents',
'Akeneo\Platform\Installer\Infrastructure\Command\ZddMigration',
'Akeneo\Platform\Installer\Infrastructure\Event\InstallerEvents',
'Akeneo\Platform\Bundle\FrameworkBundle\Security\SecurityFacadeInterface',
'Akeneo\UserManagement\Bundle\Context\UserContext',
'Akeneo\Tool\Component\Batch\Event\EventInterface',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function it_should_get_an_existing_family_nomenclature(): void
'operator' => '=',
'value'=> 3,
'generate_if_empty'=> false,
'values'=> [ 'FamilyA1' => 'FA1', 'FamilyA2' => 'FA2'],
'values'=> ['FamilyA1' => 'FA1', 'FamilyA2' => 'FA2'],
], \json_decode($response->getContent(), true));
}

Expand All @@ -63,12 +63,16 @@ public function it_should_get_a_non_existing_family_nomenclature(): void
);
$response = $this->client->getResponse();
Assert::assertSame(Response::HTTP_OK, $response->getStatusCode());
Assert::assertSame([
'operator' => null,
'value'=> null,
'generate_if_empty'=> null,
'values'=> [],
], \json_decode($response->getContent(), true));
Assert::assertJsonStringEqualsJsonString(<<<JSON
{
"operator": null,
"value": null,
"generate_if_empty": null,
"values": {}
}
JSON,
$response->getContent()
);
}

/** @test */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,6 @@ protected function createProduct(string $identifier, array $userIntents): string
return $this->getProductUuid($identifier)->toString();
}

protected function getUserId(string $username): int
{
$query = <<<SQL
SELECT id FROM oro_user WHERE username = :username
SQL;
$stmt = $this->get('database_connection')->executeQuery($query, ['username' => $username]);
$id = $stmt->fetchOne();
if (null === $id) {
throw new \InvalidArgumentException(\sprintf('No user exists with username "%s"', $username));
}

return \intval($id);
}

private function getIdentifierGeneratorPrefixes(): array
{
$query = <<<SQL
Expand Down
3 changes: 2 additions & 1 deletion components/identifier-generator/front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"dependencies": {
"@akeneo-pim-community/shared": "link:../../../front-packages/shared",
"@akeneo-pim-community/structure": "link:../../../src/Akeneo/Pim/Structure/front",
"akeneo-design-system": "link:../../../front-packages/akeneo-design-system",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
Expand All @@ -45,7 +46,7 @@
"translation:build:ee": "cp ../../../../../../public/js/translation/en_US.js ./src/translations.json",
"route:build": "cp ../../../public/js/fos_js_routes.json ./src/routes.json",
"route:build:ee": "cp ../../../../../../public/js/fos_js_routes.json ./src/routes.json",
"packages:build": "yarn --cwd=$npm_package_config_front_packages_path/akeneo-design-system lib:build && yarn workspace @akeneo-pim-community/shared lib:build",
"packages:build": "yarn --cwd=$npm_package_config_front_packages_path/akeneo-design-system lib:build && yarn workspace @akeneo-pim-community/shared lib:build && yarn workspace @akeneo-pim-community/structure lib:build",
"eslint": "eslint --config .eslintrc.json src/**/*.{ts,tsx}",
"lint:fix": "prettier --config .prettierrc.json --parser typescript --write \"./src/**/*.{ts,tsx}\" && eslint --config .eslintrc.json src/**/*.{ts,tsx} --fix",
"lint:check": "prettier --config .prettierrc.json --parser typescript --check \"./src/**/*.{ts,tsx}\" && yarn eslint --config .eslintrc.json --ext .tsx,.ts ./src"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ import React from 'react';
import {Field, Helper, SelectInput} from 'akeneo-design-system';
import {useIdentifierAttributes} from '../hooks/';
import {useTranslate} from '@akeneo-pim-community/shared';
import {AttributeCode} from '@akeneo-pim-community/structure';

enum Status {
FORBIDDEN,
ERROR,
SUCCESS,
}

const IdentifierAttributeSelector: React.FC<{code: string}> = ({code}) => {
type IdentifierAttributeSelector = {
code: AttributeCode;
onChange: (attributeCode: AttributeCode) => void;
}

const IdentifierAttributeSelector: React.FC<IdentifierAttributeSelector> = ({code, onChange}) => {
const translate = useTranslate();
const {data: attributes = [], error} = useIdentifierAttributes();
const status = error?.message === 'Forbidden' ? Status.FORBIDDEN : error?.message ? Status.ERROR : Status.SUCCESS;
const handleChange = (attributeCode: AttributeCode) => {
onChange(attributeCode);
};

return (
<Field label={translate('pim_identifier_generator.create.form.select_identifier_attribute')}>
Expand All @@ -21,8 +30,9 @@ const IdentifierAttributeSelector: React.FC<{code: string}> = ({code}) => {
data-testid="identifierAttribute"
openLabel={translate('pim_common.open')}
placeholder=""
readOnly={true}
value={status === Status.SUCCESS ? code : null}
onChange={handleChange}
clearable={false}
>
{attributes?.map(attribute => (
<SelectInput.Option key={attribute.code} title={attribute?.label} value={attribute.code}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import {AttributeCode} from '@akeneo-pim-community/structure';

type IdentifierAttributeSelector = {
code: AttributeCode;
onChange: (attributeCode: AttributeCode) => void;
}

const IdentifierAttributeSelector: React.FC<IdentifierAttributeSelector> = ({onChange}) => {
const handleChange = () => {
onChange('ean');
};

return (
<>
IdentifierAttributeSelectorMock
<button onClick={handleChange}>Change target</button>
</>
);
};

export {IdentifierAttributeSelector};
Loading

0 comments on commit 7a8c885

Please sign in to comment.