Skip to content

Commit

Permalink
New: Extract API service to own package
Browse files Browse the repository at this point in the history
As we use the api service methods also in the react-ui package we need to share the code.
  • Loading branch information
markusguenther committed Mar 5, 2021
1 parent 1dfeb5b commit 0c44d3f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 54 deletions.
5 changes: 3 additions & 2 deletions Resources/Private/Javascript/Components/UserMenu.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { isNil } from '../Helper'
import ApiService from '../Service/ApiService'
import ApiService from '@unikka/loginas-api'
import { RestoreButton } from '../Templates/RestoreButton'

const BASE_PATH = '/neos/impersonate/'
export default class UserMenu {
constructor(_root) {
const csfrTokenField = document.querySelector('[data-csrf-token]')
this._csrfToken = !isNil(csfrTokenField)
? csfrTokenField.getAttribute('data-csrf-token')
: ''
this._root = _root
this._apiService = new ApiService(this._csrfToken)
this._apiService = new ApiService(BASE_PATH, this._csrfToken)

if (!isNil(_root)) {
this._checkImpersonateStatus()
Expand Down
5 changes: 3 additions & 2 deletions Resources/Private/Javascript/Components/UserModule.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {isNil} from '../Helper'
import ApiService from '../Service/ApiService'
import ApiService from '@unikka/loginas-api'
import {ImpersonateButton} from '../Templates/ImpersonateButton'

const BASE_PATH = '/neos/impersonate/'
export default class UserModule {
constructor(_root) {
const csfrTokenField = document.querySelector('[data-csrf-token]')
this._root = _root
this._csrfToken = !isNil(csfrTokenField) ? csfrTokenField.getAttribute('data-csrf-token') : ''
this._apiService = new ApiService(this._csrfToken)
this._apiService = new ApiService(BASE_PATH, this._csrfToken)

if (!isNil(_root)) {
this._initialize()
Expand Down
50 changes: 0 additions & 50 deletions Resources/Private/Javascript/Service/ApiService.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"repository": "git@github.com:unikka/login-as.git",
"license": "GNU GPLv3",
"dependencies": {
"@unikka/loginas-api": "^1.0.1",
"core-js": "^3.8.0",
"regenerator-runtime": "^0.13.7"
},
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,14 @@
resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d"
integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==

"@unikka/loginas-api@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@unikka/loginas-api/-/loginas-api-1.0.1.tgz#45669d2642f7fd3e1ef06f8bb2f81410164b4046"
integrity sha512-P/MBabF3tC9TIElc4ZQ28bZJbSDSrIJP+Wlyf2pJf71oWXhNlcuoVNezhqRdtrXqoJ9z/nAqUtTCJLypscM5oQ==
dependencies:
core-js "^3.8.0"
regenerator-runtime "^0.13.7"

JSONStream@^1.0.4, JSONStream@^1.3.4, JSONStream@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
Expand Down

0 comments on commit 0c44d3f

Please sign in to comment.