Skip to content

Commit

Permalink
FFWEB-2711:Add loader for export button
Browse files Browse the repository at this point in the history
Add loader for export button - it will prevent to execute several exports at the same time
  • Loading branch information
Rayn93 authored May 5, 2023
1 parent c22f7d2 commit 3a521bb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
## Unreleased
### Add
- Add refresh export cache button
- Add loader for export button
### Fix
- Fix problem with autowire EntityRepository and SalesChannelRepository for Shopware 6.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Component.register('ui-feed-export-form', {
typeSelectOptions: [],
isCacheDisable: false,
isLoadingCache: false,
isLoadingExport: false,
}
},

Expand Down Expand Up @@ -65,6 +66,11 @@ Component.register('ui-feed-export-form', {
message: this.$tc('ui-feed-export.component.export_form.alert_error.text')
})
},
errorNotValidParams() {
this.createNotificationError({
message: this.$tc('ui-feed-export.component.export_form.alert_not_valid_params.text')
})
},
successRefreshCacheWindow() {
this.createNotificationSuccess({
message: this.$tc('ui-feed-export.component.export_form.refresh_cache_success.text')
Expand All @@ -75,18 +81,36 @@ Component.register('ui-feed-export-form', {
message: this.$tc('ui-feed-export.component.export_form.refresh_cache_error.text')
})
},
validateParams(params) {
if (params.salesChannelValue === null ||
params.salesChannelLanguageValue === null ||
params.exportTypeValue === null ) {
return false;
}

return true;
},
getFeedExportFile(url) {
const httpClient = Shopware.Service('syncService').httpClient;
const basicHeaders = {
Authorization: `Bearer ${Shopware.Context.api.authToken.access}`,
'Content-Type': 'application/json'
};
const params = {
salesChannelValue: this.salesChannelValue,
salesChannelLanguageValue: this.salesChannelLanguageValue,
exportTypeValue: this.exportTypeValue
};

if (!this.validateParams(params)) {
this.errorNotValidParams();

return;
}

this.isLoadingExport = true;
const httpClient = Shopware.Service('syncService').httpClient;
const basicHeaders = {
Authorization: `Bearer ${Shopware.Context.api.authToken.access}`,
'Content-Type': 'application/json'
};


httpClient
.get(url, {
headers: basicHeaders,
Expand All @@ -98,6 +122,8 @@ Component.register('ui-feed-export-form', {
} else {
this.errorFeedGenerationWindow();
}

this.isLoadingExport = false;
});
},
refreshExportCache(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

</sw-container>
<sw-button @click="getFeedExportFile('_action/fact-finder/generate-feed')"
:isLoading="isLoadingExport"
:disabled="isLoadingExport"
variant="success"
block="true"
size="large">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
"title": "Refresh cache Export"
},
"alert_success": {
"text": "Integration process has been started"
"text": "Export has been generated"
},
"alert_error": {
"text": "An error occurred during integration process"
},
"alert_not_valid_params": {
"text": "Please choose export parameters"
},
"refresh_cache_success": {
"text": "Export cache has been refreshed"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
"title": "Refresh cache Export"
},
"alert_success": {
"text": "Integration process has been started"
"text": "Export has been generated"
},
"alert_error": {
"text": "An error occurred during integration process"
},
"export_type": {
"label": "Select export type"
},
"alert_not_valid_params": {
"text": "Please choose export parameters"
},
"refresh_cache_success": {
"text": "Export cache has been refreshed"
},
Expand Down

Large diffs are not rendered by default.

0 comments on commit 3a521bb

Please sign in to comment.