Skip to content

Commit b320ea6

Browse files
committed
feat: add support for shopware 6.7
1 parent c071d3d commit b320ea6

12 files changed

Lines changed: 57 additions & 45 deletions

File tree

composer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vienthuong/impersonation",
33
"description": "A Shopware 6 Impersonation plugin",
4-
"version": "3.0.0",
4+
"version": "4.0.0",
55
"type": "shopware-platform-plugin",
66
"license": "MIT",
77
"authors": [
@@ -16,7 +16,7 @@
1616
}
1717
},
1818
"require": {
19-
"shopware/core": "~6.5.0||~6.6.0"
19+
"shopware/core": "~6.6.0||~6.7.0"
2020
},
2121
"extra": {
2222
"shopware-plugin-class": "VienThuong\\Impersonation\\Impersonation",
@@ -31,9 +31,5 @@
3131
"en-GB": "Allow administrator to impersonate any user"
3232
}
3333
},
34-
"conflict": {
35-
"shopware/storefront": "<6,>=7",
36-
"shopware/administration": "<6,>=7"
37-
},
3834
"prefer-stable": true
3935
}

src/Resources/app/administration/src/extension/component/structure/sw-page/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import template from './sw-page.html.twig';
22
import './sw-page.scss';
33

4-
const { Component, State, Service } = Shopware;
4+
const { Component, Service } = Shopware;
55

66
Component.override('sw-page', {
77
template,
@@ -14,7 +14,7 @@ Component.override('sw-page', {
1414

1515
computed: {
1616
currentUser() {
17-
return State.get('session').currentUser;
17+
return Shopware.Store.get('session').currentUser;
1818
},
1919

2020
pageClasses() {
@@ -30,7 +30,6 @@ Component.override('sw-page', {
3030
isImpersonating() {
3131
return this.impersonationService.isImpersonating();
3232
}
33-
3433
},
3534

3635
methods: {

src/Resources/app/administration/src/extension/component/structure/sw-page/sw-page.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
{% block sw_page_leave_impersonation_button %}
44
<sw-button v-if="isImpersonating"
55
class="impersonation-btn"
6-
variant="danger"
6+
variant="critical"
77
size="x-small"
88
:disabled="isLoading"
99
:isLoading="isLoading"
10-
@click="leaveImpersonation">{{ $tc('impersonation.actions.leaveImpersonation') }}</sw-button>
10+
@click="leaveImpersonation">
11+
{{ $tc('impersonation.actions.leaveImpersonation') }}
12+
</sw-button>
1113
{% endblock %}
1214

1315
{% block sw_page_notification_center %}

src/Resources/app/administration/src/extension/component/structure/sw-page/sw-page.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
.impersonation-btn {
88
z-index: 800;
9-
max-width: 100px;
109
margin-right: 10px;
1110

1211
.sw-button__content {
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import template from './sw-users-permissions-user-listing.html.twig';
2-
const { Component, Service, State } = Shopware;
2+
const { Component, Service} = Shopware;
33

4-
const componentConfiguration = {
4+
Component.override('sw-users-permissions-user-listing', {
5+
template,
56
computed: {
67
impersonationService() {
78
return Service('impersonationService');
89
},
910

1011
currentUser() {
11-
return State.get('session').currentUser;
12+
return Shopware.Store.get('session').currentUser;
1213
},
1314

1415
canImpersonate() {
@@ -35,25 +36,4 @@ const componentConfiguration = {
3536
this.$router.push({ name: 'sw.dashboard.index' });
3637
}
3738
}
38-
};
39-
40-
// Using sw-settings-user-list until its deprecated
41-
if (!Component.getComponentRegistry().has('sw-settings-user-list')) {
42-
Component.override('sw-users-permissions-user-listing', {
43-
template,
44-
...componentConfiguration
45-
});
46-
} else {
47-
/**
48-
* @deprecated tag:v6.4.0 - use 'sw-users-permissions-user-listing' instead
49-
*/
50-
Component.override('sw-settings-user-list', {
51-
template,
52-
53-
deprecated: {
54-
version: '6.4.0',
55-
comment: 'Use sw-users-permissions-user-listing instead'
56-
},
57-
...componentConfiguration
58-
});
59-
}
39+
});

src/Resources/app/administration/src/init/impersonation.init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ImpersonationService from '../service/impersonation.service';
22

33
const { State, Application } = Shopware;
44
const initContainer = Application.getContainer('init');
5-
const currentUser = State.get('session').currentUser;
5+
const currentUser = Shopware.Store.get('session')?.currentUser;
66
const httpClient = initContainer.httpClient;
77

88
Application.addServiceProvider('impersonationService', (container) => {

src/Resources/app/administration/src/service/impersonation.service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {IMPERSONATING_ATTRIBUTE_KEY} from "../constant/impersonation.constant";
22

3-
const { Application, State } = Shopware;
3+
const { Application} = Shopware;
44

55
class ImpersonationService {
66
constructor(impersonatingUser, container, httpClient) {
@@ -39,11 +39,11 @@ class ImpersonationService {
3939
}
4040

4141
async _initializeUser(user) {
42-
State.commit('setCurrentUser', user);
42+
const session = Shopware.Store.get('session');
43+
session.setCurrentUser(user);
4344

4445
await this.localeHelper.setLocaleWithId(user.localeId);
45-
46-
State.commit('context/setApiLanguageId', State.get('session').languageId);
46+
Shopware.Store.get('context').setApiLanguageId(session.languageId);
4747

4848
this.initializeUserNotifications();
4949
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"base": "/bundles/impersonation/administration/",
3+
"entryPoints": {
4+
"impersonation": {
5+
"css": [
6+
"/bundles/impersonation/administration/css/impersonation.css"
7+
],
8+
"dynamic": [],
9+
"js": [
10+
"/bundles/impersonation/administration/js/impersonation.js"
11+
],
12+
"legacy": false,
13+
"preload": []
14+
}
15+
},
16+
"legacy": false,
17+
"metadatas": {},
18+
"version": [
19+
"7.0.4",
20+
7,
21+
0,
22+
4
23+
],
24+
"viteServer": null
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"main.js": {
3+
"file": "js/impersonation.js",
4+
"name": "impersonation",
5+
"src": "main.js",
6+
"isEntry": true,
7+
"css": [
8+
"css/impersonation.css"
9+
]
10+
}
11+
}

src/Resources/public/administration/css/impersonation.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)