Skip to content

Commit

Permalink
feat(admin-ui): show trial license screen when no valid license key f…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
jv18creator committed Aug 17, 2023
1 parent 64386ae commit 2871a53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 5 additions & 1 deletion admin-ui/app/redux/features/licenseSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const licenseSlice = createSlice({
},
setValidatingFlow: (state, action) => {
state.isValidatingFlow = action.payload.isValidatingFlow
},
setLicenseError: (state, action) => {
state.error = action.payload
}
},
})
Expand All @@ -96,7 +99,8 @@ export const {
retrieveLicenseKey,
retrieveLicenseKeyResponse,
checkThresholdLimit,
setValidatingFlow
setValidatingFlow,
setLicenseError
} = licenseSlice.actions

export default licenseSlice.reducer
Expand Down
12 changes: 9 additions & 3 deletions admin-ui/app/redux/sagas/LicenseSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
retrieveLicenseKeyResponse,
checkThresholdLimit,
setValidatingFlow,
setApiDefaultToken
setApiDefaultToken,
setLicenseError
} from '../actions'
import LicenseApi from 'Redux/api/LicenseApi'
import { getClientWithToken, getClient } from 'Redux/api/base'
Expand Down Expand Up @@ -71,11 +72,11 @@ function* retrieveLicenseKey() {
const licenseApi = yield* getApiTokenWithDefaultScopes()
const response = yield call(licenseApi.retrieveLicense)

if (response?.['license_key']) {
if (response?.responseObject?.['licenseKey']) {
try {
const activateLicense = yield call(licenseApi.submitLicenseKey, {
payload: {
licenseKey: response['license_key']
licenseKey: response.responseObject['licenseKey']
}
})

Expand All @@ -96,6 +97,8 @@ function* retrieveLicenseKey() {
} catch (error) {
console.log('Error in generating key.', error)
yield put(retrieveLicenseKeyResponse({ isNoValidLicenseKeyFound: true }))
yield put(checkLicensePresentResponse({ isLicenseValid: false }))
yield put(generateTrialLicenseResponse(null))
}
}

Expand Down Expand Up @@ -153,6 +156,9 @@ function* generateTrailLicenseKey() {
}
} catch (error) {
console.log('Error in generating key.', error)
yield put(checkLicensePresentResponse({ isLicenseValid: false }))
yield put(generateTrialLicenseResponse(null))
yield put(setLicenseError(error.message))
}
}

Expand Down
12 changes: 2 additions & 10 deletions admin-ui/app/utils/ApiKeyRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ function ApiKeyRedirect({
<Container>
{isConfigValid == false ? (
<UploadSSA />
) : !isTimeout && !isNoValidLicenseKeyFound && isUnderThresholdLimit && (
) : !isTimeout && isUnderThresholdLimit && (
<>
{!isLicenseValid && islicenseCheckResultLoaded && isConfigValid && !isValidatingFlow && !isNoValidLicenseKeyFound ? (
{!isLicenseValid && islicenseCheckResultLoaded && isConfigValid && !isValidatingFlow && isNoValidLicenseKeyFound ? (
<ApiKey />
) : (
<div
Expand Down Expand Up @@ -71,14 +71,6 @@ function ApiKeyRedirect({
/>
)}

{(isLicenseActivationResultLoaded && !isLicenseValid) || isNoValidLicenseKeyFound && (
<GluuErrorModal
message={t('Invalid License')}
description={
'License has been not enabled for this application. Please contact support and confirm if license-key is correct.'
}
/>
)}
</Container>
</React.Fragment>
)
Expand Down

0 comments on commit 2871a53

Please sign in to comment.