Skip to content

Commit f10ec67

Browse files
committed
feat: admin ui license registration #497
1 parent befb408 commit f10ec67

File tree

6 files changed

+3
-161
lines changed

6 files changed

+3
-161
lines changed

admin-ui/app/redux/actions/LicenseActions.js

-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
CHECK_FOR_VALID_LICENSE,
33
CHECK_FOR_VALID_LICENSE_RESPONSE,
44
ACTIVATE_CHECK_USER_API,
5-
ACTIVATE_CHECK_LICENCE_API_VALID,
65
ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE,
76
ACTIVATE_CHECK_USER_LICENSE_KEY,
87
} from './types'
@@ -21,10 +20,6 @@ export const checkUserLicenceKey = (payload) => ({
2120
type: ACTIVATE_CHECK_USER_LICENSE_KEY,
2221
payload: { payload },
2322
})
24-
export const checkUserApiKeyResponse = (payload) => ({
25-
type: ACTIVATE_CHECK_LICENCE_API_VALID,
26-
payload: payload,
27-
})
2823
export const checkUserLicenseKeyResponse = (payload) => ({
2924
type: ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE,
3025
payload: payload,

admin-ui/app/redux/actions/types.js

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export const ACTIVATE_CHECK_USER_API = 'ACTIVATE_CHECK_USER_API'
7070
export const ACTIVATE_CHECK_USER_LICENSE_KEY = 'ACTIVATE_CHECK_USER_LICENSE_KEY'
7171
export const ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE =
7272
'ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE'
73-
export const ACTIVATE_CHECK_LICENCE_API_VALID =
74-
'ACTIVATE_CHECK_LICENCE_API_VALID'
7573

7674
//OIDC DISCOVERY
7775
export const GET_OIDC_DISCOVERY = 'GET_OIDC_DISCOVERY'

admin-ui/app/redux/api/LicenseApi.js

-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ export default class LicenseApi {
1212
})
1313
}
1414

15-
submitApiKey = (data) => {
16-
const options = {}
17-
options['licenseSpringCredentials'] = data.payload
18-
return new Promise((resolve, reject) => {
19-
this.api.saveLicenseApiCredentials(options, (error, data) => {
20-
handleResponse(error, reject, resolve, data)
21-
})
22-
})
23-
}
2415
submitLicenseKey = (data) => {
2516
const options = {}
2617
options['licenseRequest'] = data.payload

admin-ui/app/redux/reducers/LicenseReducer.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,7 @@ export default function licenseReducer(state = INIT_STATE, action) {
3838
isLoading: true,
3939
error: '',
4040
}
41-
case ACTIVATE_CHECK_LICENCE_API_VALID:
42-
if (action.payload.apiResult) {
43-
return {
44-
...state,
45-
isLicenceAPIkeyValid: action.payload,
46-
error: '',
47-
isLoading: false,
48-
}
49-
} else {
50-
return {
51-
...state,
52-
error: action.payload.responseMessage,
53-
isLoading: false,
54-
}
55-
}
41+
5642
case ACTIVATE_CHECK_USER_LICENSE_KEY_RESPONSE:
5743
if (action.payload.apiResult) {
5844
return {

admin-ui/app/redux/sagas/LicenseSaga.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { checkLicensePresentResponse } from '../actions'
1212
import LicenseApi from '../api/LicenseApi'
1313
import { getClient, getClientWithToken } from '../api/base'
1414
import {
15-
checkUserApiKeyResponse,
1615
checkUserLicenseKeyResponse,
1716
} from '../actions'
1817
import {
@@ -46,15 +45,7 @@ function* checkLicensePresentWorker() {
4645
yield put(checkLicensePresentResponse())
4746
}
4847

49-
function* activateCheckUserApi({ payload }) {
50-
try {
51-
const licenseApi = yield* getApiTokenWithDefaultScopes()
52-
const response = yield call(licenseApi.submitApiKey, payload)
53-
yield put(checkUserApiKeyResponse(response))
54-
} catch (error) {
55-
console.log(error)
56-
}
57-
}
48+
5849
function* activateCheckUserLicenseKey({ payload }) {
5950
try {
6051
const licenseApi = yield* getApiTokenWithDefaultScopes()
@@ -71,15 +62,12 @@ export function* checkLicensePresentWatcher() {
7162
yield takeEvery(ACTIVATE_CHECK_USER_LICENSE_KEY, activateCheckUserLicenseKey)
7263
}
7364

74-
export function* activateCheckApiKeyWatcher() {
75-
yield takeEvery(ACTIVATE_CHECK_USER_API, activateCheckUserApi)
76-
}
65+
7766
/**
7867
* License Root Saga
7968
*/
8069
export default function* rootSaga() {
8170
yield all([
8271
fork(checkLicensePresentWatcher),
83-
fork(activateCheckApiKeyWatcher),
8472
])
8573
}

admin-ui/app/utils/LicenseScreens/ApiKey.js

-116
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@ function ApiKey() {
88
const dispatch = useDispatch()
99
const serverError = useSelector((state) => state.licenseReducer.error)
1010
const isLoading = useSelector((state) => state.licenseReducer.isLoading)
11-
const isLicenceAPIkeyValid = useSelector(
12-
(state) => state.licenseReducer.isLicenceAPIkeyValid,
13-
)
14-
const params = {
15-
apiKey: '',
16-
productCode: '',
17-
sharedKey: '',
18-
managementKey: '',
19-
}
2011

21-
const [values, setValues] = useState(params)
22-
const [error, setError] = useState(params)
2312
const [submitted, setIsSubmitted] = useState(false)
2413
const [licenseKey, setLicenseKey] = useState('')
2514

@@ -31,39 +20,6 @@ function ApiKey() {
3120
}))
3221
}
3322

34-
useEffect(() => {
35-
checkForError()
36-
}, [JSON.stringify(values)])
37-
const checkForError = () => {
38-
let err = false
39-
for (const i in values) {
40-
if (values[i] == '') {
41-
err = true
42-
setError((prevState) => ({
43-
...prevState,
44-
[i]: 'This field is required',
45-
}))
46-
} else {
47-
setError((prevState) => ({
48-
...prevState,
49-
[i]: '',
50-
}))
51-
}
52-
}
53-
return err
54-
}
55-
56-
const submitValues = () => {
57-
setIsSubmitted(true)
58-
if (!checkForError()) {
59-
dispatch(checkUserApi(values))
60-
}
61-
console.log(values)
62-
}
63-
useEffect(() => {
64-
setIsSubmitted(false)
65-
}, [isLicenceAPIkeyValid])
66-
6723
const submitLicenseKey = () => {
6824
setIsSubmitted(true)
6925
if (licenseKey != '') {
@@ -104,77 +60,6 @@ function ApiKey() {
10460
</div>
10561
</div>
10662

107-
{!isLicenceAPIkeyValid ? (
108-
<div className="row">
109-
<div className="col-md-8 mx-auto">
110-
<label>Api Key*</label>
111-
<input
112-
type="text"
113-
className={
114-
submitted && error.apiKey
115-
? 'border-danger form-control'
116-
: 'form-control'
117-
}
118-
value={values.apiKey}
119-
name="apiKey"
120-
onChange={handleChange}
121-
/>
122-
<div className="text-danger">{submitted && error.apiKey}</div>
123-
<label>Product Code*</label>
124-
<input
125-
type="text"
126-
className={
127-
submitted && error.productCode
128-
? 'border-danger form-control'
129-
: 'form-control'
130-
}
131-
value={values.productCode}
132-
name="productCode"
133-
onChange={handleChange}
134-
/>
135-
<div className="text-danger">
136-
{submitted && error.productCode}
137-
</div>
138-
<label>Shared Key*</label>
139-
<input
140-
type="text"
141-
className={
142-
submitted && error.sharedKey
143-
? 'border-danger form-control'
144-
: 'form-control'
145-
}
146-
value={values.sharedKey}
147-
name="sharedKey"
148-
onChange={handleChange}
149-
/>
150-
<div className="text-danger">{submitted && error.sharedKey}</div>
151-
<label>Management Key*</label>
152-
<input
153-
type="text"
154-
className={
155-
submitted && error.managementKey
156-
? 'border-danger form-control'
157-
: 'form-control'
158-
}
159-
value={values.managementKey}
160-
name="managementKey"
161-
onChange={handleChange}
162-
/>
163-
<div className="text-danger">
164-
{submitted && error.managementKey}
165-
</div>
166-
<button
167-
type="button"
168-
disabled={isLoading}
169-
onClick={() => submitValues()}
170-
className="btn mt-3"
171-
style={{ backgroundColor: '#00a361', color: 'white' }}
172-
>
173-
{isLoading ? 'Submitting please wait...' : 'Submit'}
174-
</button>
175-
</div>
176-
</div>
177-
) : (
17863
<div className="row">
17964
<div className="col-md-8 mx-auto">
18065
<label>License Key*</label>
@@ -203,7 +88,6 @@ function ApiKey() {
20388
</button>
20489
</div>
20590
</div>
206-
)}
20791
</div>
20892
</div>
20993
)

0 commit comments

Comments
 (0)