Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ater to master * commit '70cafb506f3ad80cb9860a3a0a9910e32ee74939': NEXT-3806 - Add blocks NEXT-3806 - Auto-Updater
- Loading branch information
Showing
57 changed files
with
2,710 additions
and
5 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...ources/administration/src/app/assets/icons/svg/icons-default-arrow-360-full.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/Administration/Resources/administration/src/core/service/api/update.api.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import ApiService from '../api.service'; | ||
|
||
/** | ||
* Gateway for the API end point "update" | ||
* @class | ||
* @extends ApiService | ||
*/ | ||
class UpdateService extends ApiService { | ||
constructor(httpClient, loginService, apiEndpoint = 'update') { | ||
super(httpClient, loginService, apiEndpoint); | ||
this.name = 'updateService'; | ||
} | ||
|
||
checkForUpdates() { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.get(`/_action/${this.getApiBasePath()}/check`, { headers }) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
checkRequirements() { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.get(`/_action/${this.getApiBasePath()}/check-requirements`, { headers }) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
pluginCompatibility() { | ||
const headers = this.getBasicHeaders(); | ||
const params = this.getBasicParams(); | ||
|
||
return this.httpClient | ||
.get(`/_action/${this.getApiBasePath()}/plugin-compatibility`, { params, headers }) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
downloadUpdate(offset) { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.get(`/_action/${this.getApiBasePath()}/download-latest-update?offset=${offset}`, { headers }) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
unpackUpdate(offset) { | ||
const headers = this.getBasicHeaders(); | ||
|
||
return this.httpClient | ||
.get(`/_action/${this.getApiBasePath()}/unpack?offset=${offset}`, { headers }) | ||
.then((response) => { | ||
return ApiService.handleResponse(response); | ||
}); | ||
} | ||
|
||
getBasicParams(additionalParams = {}) { | ||
const basicParams = { | ||
language: localStorage.getItem('sw-admin-locale') | ||
}; | ||
|
||
return Object.assign({}, basicParams, additionalParams); | ||
} | ||
} | ||
|
||
export default UpdateService; |
70 changes: 70 additions & 0 deletions
70
...nistration/Resources/administration/src/core/service/shopware-updates-listener.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Application } from 'src/core/shopware'; | ||
|
||
/** | ||
* @module core/service/shopware-updates-listener | ||
*/ | ||
|
||
/** | ||
* | ||
* @memberOf module:core/service/shopware-updates-listener | ||
* @method addShopwareUpdatesListener | ||
* @param loginService | ||
* @param serviceContainer | ||
*/ | ||
export default function addShopwareUpdatesListener(loginService, serviceContainer) { | ||
/** @var {String} localStorage token */ | ||
let applicationRoot = null; | ||
|
||
loginService.addOnLoginListener(() => { | ||
serviceContainer.updateService.checkForUpdates() | ||
.then((response) => { | ||
if (response.version) { | ||
createUpdatesAvailableNotification(response); | ||
} | ||
}) | ||
.catch(); | ||
}); | ||
|
||
function createUpdatesAvailableNotification(response) { | ||
const cancelLabel = | ||
getApplicationRootReference().$t('global.notification-center.shopware-updates-listener.cancel'); | ||
const updateLabel = | ||
getApplicationRootReference().$t('global.notification-center.shopware-updates-listener.updateNow'); | ||
|
||
const notification = { | ||
title: getApplicationRootReference().$t( | ||
'global.notification-center.shopware-updates-listener.updatesAvailableTitle', { | ||
version: response.version | ||
} | ||
), | ||
message: getApplicationRootReference().$t( | ||
'global.notification-center.shopware-updates-listener.updatesAvailableMessage', { | ||
version: response.version | ||
} | ||
), | ||
variant: 'info', | ||
growl: true, | ||
system: true, | ||
actions: [{ | ||
label: updateLabel, | ||
route: { name: 'sw.settings.shopware.updates.wizard' } | ||
}, { | ||
label: cancelLabel | ||
}], | ||
autoClose: false | ||
}; | ||
|
||
getApplicationRootReference().$store.dispatch( | ||
'notification/createNotification', | ||
notification | ||
); | ||
} | ||
|
||
function getApplicationRootReference() { | ||
if (!applicationRoot) { | ||
applicationRoot = Application.getApplicationRoot(); | ||
} | ||
|
||
return applicationRoot; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ministration/src/module/sw-settings-shopware-updates/extension/sw-settings-index/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from 'src/core/shopware'; | ||
import template from './sw-settings-index.html.twig'; | ||
|
||
Component.override('sw-settings-index', { | ||
template | ||
}); |
13 changes: 13 additions & 0 deletions
13
...dule/sw-settings-shopware-updates/extension/sw-settings-index/sw-settings-index.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% block sw_settings_content_card_slot_system %} | ||
{% parent %} | ||
|
||
{% block sw_settings_shopware_updates %} | ||
<sw-settings-item id="sw-settings-shopware-updates" | ||
:label="$tc('sw-settings-shopware-updates.general.menuTitle')" | ||
:to="{ name: 'sw.settings.shopware.updates.index' }"> | ||
<template slot="icon"> | ||
<sw-icon name="default-arrow-360-full"></sw-icon> | ||
</template> | ||
</sw-settings-item> | ||
{% endblock %} | ||
{% endblock %} |
45 changes: 45 additions & 0 deletions
45
src/Administration/Resources/administration/src/module/sw-settings-shopware-updates/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Module } from 'src/core/shopware'; | ||
|
||
import './extension/sw-settings-index'; | ||
import './page/sw-settings-shopware-updates-index'; | ||
import './page/sw-settings-shopware-updates-wizard'; | ||
import './view/sw-settings-shopware-updates-info'; | ||
import './view/sw-settings-shopware-updates-requirements'; | ||
import './view/sw-settings-shopware-updates-plugins'; | ||
|
||
import deDE from './snippet/de-DE.json'; | ||
import enGB from './snippet/en-GB.json'; | ||
|
||
Module.register('sw-settings-shopware-updates', { | ||
type: 'core', | ||
name: 'settings-shopware-updates', | ||
title: 'sw-settings-shopware-updates.general.emptyTitle', | ||
description: 'sw-settings-shopware-updates.general.emptyTitle', | ||
version: '1.0.0', | ||
targetVersion: '1.0.0', | ||
color: '#9AA8B5', | ||
icon: 'default-action-settings', | ||
favicon: 'icon-module-settings.png', | ||
|
||
snippets: { | ||
'de-DE': deDE, | ||
'en-GB': enGB | ||
}, | ||
|
||
routes: { | ||
index: { | ||
component: 'sw-settings-shopware-updates-index', | ||
path: 'index', | ||
meta: { | ||
parentPath: 'sw.settings.index' | ||
} | ||
}, | ||
wizard: { | ||
component: 'sw-settings-shopware-updates-wizard', | ||
path: 'wizard', | ||
meta: { | ||
parentPath: 'sw.settings.index' | ||
} | ||
} | ||
} | ||
}); |
80 changes: 80 additions & 0 deletions
80
.../src/module/sw-settings-shopware-updates/page/sw-settings-shopware-updates-index/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Component, Mixin, Application } from 'src/core/shopware'; | ||
import template from './sw-settings-shopware-updates-index.html.twig'; | ||
import './sw-settings-shopware-updates-index.scss'; | ||
|
||
Component.register('sw-settings-shopware-updates-index', { | ||
template, | ||
|
||
inject: ['updateService'], | ||
mixins: [ | ||
Mixin.getByName('notification') | ||
], | ||
data() { | ||
return { | ||
isLoading: false, | ||
isSaveSuccessful: false, | ||
isSearchingForUpdates: false, | ||
updateModalShown: false, | ||
updateInfo: null | ||
}; | ||
}, | ||
|
||
metaInfo() { | ||
return { | ||
title: this.$createTitle() | ||
}; | ||
}, | ||
|
||
methods: { | ||
searchForUpdates() { | ||
this.isSearchingForUpdates = true; | ||
this.updateService.checkForUpdates().then(response => { | ||
this.isSearchingForUpdates = false; | ||
|
||
if (response.version) { | ||
this.updateInfo = response; | ||
this.updateModalShown = true; | ||
} else { | ||
this.createNotificationSuccess({ | ||
title: this.$t('sw-settings-shopware-updates.notifications.title'), | ||
message: this.$t('sw-settings-shopware-updates.notifications.alreadyUpToDate') | ||
}); | ||
} | ||
}); | ||
}, | ||
|
||
openUpdateWizard() { | ||
this.updateModalShown = false; | ||
|
||
this.$nextTick(() => { | ||
this.$router.push({ name: 'sw.settings.shopware.updates.wizard' }); | ||
}); | ||
}, | ||
|
||
saveFinish() { | ||
this.isSaveSuccessful = false; | ||
}, | ||
|
||
onSave() { | ||
this.isSaveSuccessful = false; | ||
this.isLoading = true; | ||
|
||
this.$refs.systemConfig.saveAll().then(() => { | ||
this.isLoading = false; | ||
this.isSaveSuccessful = true; | ||
}).catch((err) => { | ||
this.isLoading = false; | ||
this.createNotificationError({ | ||
title: this.$tc('sw-settings-store.general.titleSaveError'), | ||
message: err | ||
}); | ||
}); | ||
} | ||
}, | ||
|
||
computed: { | ||
shopwareVersion() { | ||
return Application.getContainer('init').contextService.config.version; | ||
} | ||
} | ||
}); |
Oops, something went wrong.