Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
public function isUserFixable(): bool
{
return true;
return false;
}

public function getLevel(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ import { MIGRATION_STORE_ID, type MigrationStore } from '../../../store/migratio

const { Criteria } = Shopware.Data;

/**
* @private
*
* Determines which component resolves a specific error code.
* 'DEFAULT' means the default component renders a matching input field.
* null will render an unresolvable message.
*/
export const ERROR_CODE_COMPONENT_MAPPING: Record<string, string> = {
SWAG_MIGRATION_VALIDATION_INVALID_FIELD_VALUE: 'DEFAULT',
SWAG_MIGRATION_VALIDATION_INVALID_FOREIGN_KEY: 'DEFAULT',
SWAG_MIGRATION_VALIDATION_MISSING_REQUIRED_FIELD: 'DEFAULT',
} as const;

/**
* @private
*/
Expand Down Expand Up @@ -154,6 +167,10 @@ export default Shopware.Component.wrapComponentConfig({

return selection;
},

resolvingComponent(): string | null {
return ERROR_CODE_COMPONENT_MAPPING[this.selectedLog.code] || null;
},
},

methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,40 @@
</div>

<div class="swag-migration-error-resolution-modal__right-content">
<swag-migration-error-resolution-field
:log="selectedLog"
:disabled="loading || selectedLogIds.length === 0"
/>
<div v-if="resolvingComponent === 'DEFAULT'" class="swag-migration-error-resolution-modal__right-content-default">
<swag-migration-error-resolution-field
:log="selectedLog"
:disabled="loading || selectedLogIds.length === 0"
/>

<mt-button
class="swag-migration-error-resolution-modal__right-content-button"
variant="primary"
:is-loading="submitLoading"
:disabled="loading || selectedLogIds.length === 0"
@click="onSubmitResolution"
>
{{ $tc('swag-migration.index.error-resolution.modals.error.right.apply') }}
</mt-button>
</div>

<mt-button
class="swag-migration-error-resolution-modal__right-content-button"
variant="primary"
:is-loading="submitLoading"
:disabled="loading || selectedLogIds.length === 0"
@click="onSubmitResolution"
>
{{ $tc('swag-migration.index.error-resolution.modals.error.right.apply') }}
</mt-button>
<div v-else-if="resolvingComponent !== null" class="swag-migration-error-resolution-modal__right-content-resolving">
<component
:is="resolvingComponent"
:selected-log="selectedLog"
:selected-log-ids="selectedLogIds"
@submit-resolution="onSubmitResolution"
/>
</div>

<div v-else class="swag-migration-error-resolution-modal__right-content-unresolvable">
<mt-banner
:title="$tc('swag-migration.index.error-resolution.modals.error.right.unresolvableBanner.title')"
variant="attention"
>
{{ $tc('swag-migration.index.error-resolution.modals.error.right.unresolvableBanner.content') }}
</mt-banner>
</div>
</div>
</div>
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@
"title": "Unbekannter Feldtyp",
"content": "Der Feldtyp konnte nicht ermittelt werden. Bitte korrigieren Sie die Rohdaten."
},
"unresolvableBanner": {
"title": "Dieser Fehler kann derzeit nicht über den Migration Assistant behoben werden.",
"content": "Weitere Informationen finden sich in der Log-Datei."
},
"apply": "Änderungen anwenden"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@
"title": "Unknown field type",
"content": "The field type could not be determined. Please correct the raw source data. The value has to be in the correct format."
},
"unresolvableBanner": {
"title": "This error currently cannot be resolved via the Migration Assistant",
"content": "Please check the log file for more information."
},
"apply": "Apply changes"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* @sw-package after-sales
*/
import { mount } from '@vue/test-utils';
import SwagMigrationErrorResolutionModal from 'SwagMigrationAssistant/module/swag-migration/component/swag-migration-error-resolution/swag-migration-error-resolution-modal';
import SwagMigrationErrorResolutionModal, {
ERROR_CODE_COMPONENT_MAPPING,
} from 'SwagMigrationAssistant/module/swag-migration/component/swag-migration-error-resolution/swag-migration-error-resolution-modal';
import SwagMigrationErrorResolutionDetailsModal from 'SwagMigrationAssistant/module/swag-migration/component/swag-migration-error-resolution/swag-migration-error-resolution-details-modal';
import SwagMigrationErrorResolutionField from 'SwagMigrationAssistant/module/swag-migration/component/swag-migration-error-resolution/swag-migration-error-resolution-field';
import SwagMigrationErrorResolutionFieldScalar from 'SwagMigrationAssistant/module/swag-migration/component/swag-migration-error-resolution/swag-migration-error-resolution-field/swag-migration-error-resolution-field-scalar';
Expand Down Expand Up @@ -176,6 +178,16 @@ describe('module/swag-migration/component/swag-migration-error-resolution/swag-m
Shopware.Store.get('notification').$reset();
});

describe('constants', () => {
it('should provide error code to component mapping', () => {
expect(ERROR_CODE_COMPONENT_MAPPING).toStrictEqual({
SWAG_MIGRATION_VALIDATION_INVALID_FIELD_VALUE: 'DEFAULT',
SWAG_MIGRATION_VALIDATION_INVALID_FOREIGN_KEY: 'DEFAULT',
SWAG_MIGRATION_VALIDATION_MISSING_REQUIRED_FIELD: 'DEFAULT',
});
});
});

describe('initial loading', () => {
it('should load initial data when modal is opened', async () => {
const wrapper = await createWrapper();
Expand Down Expand Up @@ -503,6 +515,39 @@ describe('module/swag-migration/component/swag-migration-error-resolution/swag-m
});

describe('create resolution fix', () => {
it.each(Object.keys(ERROR_CODE_COMPONENT_MAPPING).map((code) => ({ code })))(
'should render default resolve component for defined codes: $code',
async ({ code }) => {
const wrapper = await createWrapper({
...defaultProps,
selectedLog: {
...fixtureLogGroups.at(1),
code: code,
entityName: 'media',
fieldName: 'title',
},
});
await flushPromises();

expect(wrapper.find('.swag-migration-error-resolution-modal__right-content-default').exists()).toBe(true);
},
);

it('should render unresolvable field component for unsupported error codes', async () => {
const wrapper = await createWrapper({
...defaultProps,
selectedLog: {
...fixtureLogGroups.at(1),
code: 'SOME_UNSUPPORTED_ERROR_CODE',
entityName: 'media',
fieldName: 'title',
},
});
await flushPromises();

expect(wrapper.find('.swag-migration-error-resolution-modal__right-content-unresolvable').exists()).toBe(true);
});

it('should disable input & create button when no logs are selected', async () => {
const wrapper = await createWrapper();
await flushPromises();
Expand Down Expand Up @@ -569,7 +614,7 @@ describe('module/swag-migration/component/swag-migration-error-resolution/swag-m
const wrapper = await createWrapper({
...defaultProps,
selectedLog: {
...fixtureLogGroups.at(2),
...fixtureLogGroups.at(1),
entityName: 'product',
fieldName: 'taxId',
},
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Migration/Logging/Log/MigrationLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static function logProvider(): \Generator
'logClass' => MigrationValidationMissingRequiredFieldLog::class,
'code' => 'SWAG_MIGRATION_VALIDATION_MISSING_REQUIRED_FIELD',
'level' => AbstractMigrationLogEntry::LOG_LEVEL_ERROR,
'userFixable' => true,
'userFixable' => false,
];

yield MigrationValidationUnexpectedFieldLog::class => [
Expand Down
Loading