Skip to content

Commit

Permalink
fix(app subscription): allow empty url in register url overlay (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhigarg-bmw authored Jun 4, 2024
1 parent 2f4c2a8 commit 28767af
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 53 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Fix consistency issue in overlays where form input is used
- Company Wallet
- Use appropriate path to display logo on cards
- App Subscription
- Register URL changes for Autosetup
- Refactor
- Remove unnecessary import of Typography, Dialog and Circular Progress from mui and use those from shared-components
- Connector Management
Expand Down
11 changes: 6 additions & 5 deletions src/assets/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1457,12 +1457,13 @@
"message": "The terms of use, as well as the data models and further information can be viewed by clicking on the documents shared below."
},
"register": {
"heading": "Autosetup URL",
"message": "This is some text for the dialog component. Lorem ispum dolores mia dela culpa dela rey.",
"endpointConfigured": "Endpoint Configured",
"autosetupURL": "AutoSetup URL",
"heading": "Configuration Autosetup URL",
"message": "The company autosetup URL configuration feature allows operators to set up a custom URL that will be used to automatically submit subscription requests to the service provider when app subscriptions are triggered on the marketplace. This feature also enables operators to retrieve technical configuration elements and activate the subscription.",
"endpointConfigured": "Configured Provider Endpoint",
"autosetupURL": "Set a new endpoint URL",
"inputPlaceholder": "...enter your setup url",
"providerErrorMessage": "Something went wrong!",
"providerSuccessMessage": "Service Provider Details added successfully."
"providerSuccessMessage": "Details updated successfully."
},
"activation": {
"heading": "Activate App Subscription",
Expand Down
13 changes: 7 additions & 6 deletions src/assets/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1424,12 +1424,13 @@
"message": "The terms of use, as well as the data models and further information can be viewed by clicking on the documents shared below."
},
"register": {
"heading": "Autosetup URL",
"message": "Enter your autosetup url in the input field below to store the autosetup endpoint. The endpoint will get triggered by CX as soon as a interested company is hitting the 'Subscribe' button in the marketplace.",
"endpointConfigured": "Current Endpoint",
"autosetupURL": "AutoSetup URL",
"heading": "Configuration Autosetup URL",
"message": "The company autosetup URL configuration feature allows operators to set up a custom URL that will be used to automatically submit subscription requests to the service provider when app subscriptions are triggered on the marketplace. This feature also enables operators to retrieve technical configuration elements and activate the subscription.",
"endpointConfigured": "Configured Provider Endpoint",
"autosetupURL": "Set a new endpoint URL",
"inputPlaceholder": "...enter your setup url",
"providerErrorMessage": "Something went wrong! Please try it later again.",
"providerSuccessMessage": "Service Provider Details added successfully."
"providerSuccessMessage": "Details updated successfully."
},
"activation": {
"heading": "Activate App Subscription",
Expand Down Expand Up @@ -1940,7 +1941,7 @@
},
"approvedMessage": "Credential Request Accepted successfully.",
"declinedMessage": "Credential Request Declined successfully.",
"errorMessage": "Something went wrong!",
"errorMessage": "Something went wrong. Please contact your administrator.",
"revokeOverlay": {
"title": "Revoke Credential",
"description": "Revoking a credential cannot be undone.",
Expand Down
106 changes: 76 additions & 30 deletions src/components/overlays/AddServiceProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import {
Button,
CircleProgress,
DialogActions,
DialogContent,
DialogHeader,
Expand All @@ -33,19 +34,20 @@ import { useEffect, useState } from 'react'
import { useDispatch } from 'react-redux'
import { useTranslation } from 'react-i18next'
import './style.scss'
import type { store } from 'features/store'
import {
useAddServiceProviderMutation,
useFetchServiceProviderQuery,
} from 'features/serviceProvider/serviceProviderApiSlice'
import Patterns from 'types/Patterns'
import { setSuccessType } from 'features/serviceProvider/slice'
import DeleteIcon from '@mui/icons-material/DeleteOutlineOutlined'

export default function AddServiceProvider() {
const { t } = useTranslation()
const dispatch = useDispatch<typeof store.dispatch>()
const [inputURL, setInputURL] = useState('')
const dispatch = useDispatch()
const [inputURL, setInputURL] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
const [deleteLoading, setDeleteLoading] = useState(false)
const [UrlErrorMsg, setUrlErrorMessage] = useState('')
const [saveErrorMsg, setSaveErrorMessage] = useState(false)

Expand All @@ -57,7 +59,8 @@ export default function AddServiceProvider() {
}, [refetch, dispatch])

const addInputURL = (value: string) => {
setInputURL(value)
setInputURL(value ?? null)
if (!value) return
if (!Patterns.URL.test(value.trim())) {
setUrlErrorMessage(t('content.appSubscription.pleaseEnterValidURL'))
} else {
Expand All @@ -66,7 +69,8 @@ export default function AddServiceProvider() {
}

const addURL = async () => {
setLoading(true)
if (inputURL) setLoading(true)
else setDeleteLoading(true)
try {
await addServiceProvider({ url: inputURL }).unwrap()
dispatch(setSuccessType(true))
Expand All @@ -78,7 +82,7 @@ export default function AddServiceProvider() {
}

return (
<>
<div className="registerUrlMain">
<DialogHeader
{...{
title: t('content.appSubscription.register.heading'),
Expand All @@ -90,29 +94,71 @@ export default function AddServiceProvider() {

<DialogContent>
<div className="manageInputURL">
<Input
label={
<Typography variant="body2">
{t('content.appSubscription.register.endpointConfigured')}
</Typography>
}
value={data ? data.url : ''}
disabled={true}
sx={{ marginBottom: '20px' }}
/>
<Input
label={
<Typography variant="body2">
{t('content.appSubscription.register.autosetupURL')}
</Typography>
}
placeholder="URL of the customer tentant"
onChange={(e) => {
addInputURL(e.target.value)
}}
value={inputURL}
/>
<p className="error">{UrlErrorMsg}</p>
{data ? (
<>
<div className="urlListMain">
<Typography variant="body2">
{t('content.appSubscription.register.endpointConfigured')}
</Typography>
<div className="urlList">
{data?.url ? (
<>
{deleteLoading ? (
<CircleProgress
colorVariant="primary"
interval={800}
iteration
size={20}
step={100}
thickness={1}
variant="indeterminate"
/>
) : (
<DeleteIcon
onClick={() => {
addURL()
}}
className="deleteIcon"
/>
)}
<Typography variant="label2" className="urlDetail">
{data.url}
</Typography>
</>
) : (
'-'
)}
</div>
</div>
<Input
label={
<Typography variant="body2">
{t('content.appSubscription.register.autosetupURL')}
</Typography>
}
placeholder={t(
'content.appSubscription.register.inputPlaceholder'
)}
onChange={(e) => {
addInputURL(e.target.value)
}}
value={inputURL}
/>
<p className="error">{UrlErrorMsg}</p>
</>
) : (
<div className="progress">
<CircleProgress
colorVariant="primary"
interval={800}
iteration
size={50}
step={100}
thickness={5}
variant="indeterminate"
/>
</div>
)}
</div>
</DialogContent>

Expand Down Expand Up @@ -155,6 +201,6 @@ export default function AddServiceProvider() {
description={t('content.appSubscription.register.providerErrorMessage')}
showIcon={true}
/>
</>
</div>
)
}
39 changes: 34 additions & 5 deletions src/components/overlays/AddServiceProvider/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,39 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

.manageInputURL {
padding: 0 80px;
.error {
color: #e93333;
.registerUrlMain {
.dialog-header-main {
h4 {
width: 75%;
margin: 40px auto 0;
}
}
.urlListMain {
background-color: #dedede;
padding: 20px;
.urlList {
display: flex;
margin-top: 10px;
.deleteIcon {
cursor: pointer;
}
.deleteIcon:hover {
color: #0f71cb;
}
.urlDetail {
margin-left: 10px;
}
}
}
.progress {
display: flex;
align-items: center;
justify-content: center;
}
.manageInputURL {
padding: 0 80px;
.error {
color: #e93333;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export default function AdminCredentialElements() {
const fileType = response.headers.get('content-type')
const file = response.data
download(file, fileType, documentName)
} catch (error) {
console.error(error, 'ERROR WHILE FETCHING DOCUMENT')
} catch (err) {
error(t('content.adminCertificate.errorMessage'))
}
}

Expand Down Expand Up @@ -252,7 +252,7 @@ export default function AdminCredentialElements() {
{
field: 'document',
headerName: t('content.adminCertificate.table.document'),
flex: 1.5,
flex: 2,
renderCell: ({ row }: { row: CredentialData }) =>
row.documents?.map((document) => {
return (
Expand Down Expand Up @@ -293,7 +293,7 @@ export default function AdminCredentialElements() {
{
field: 'approveDecline',
headerName: '',
flex: 2.5,
flex: 2,
renderCell: ({ row }: { row: CredentialData }) =>
renderApproveDeclineBtn(row),
},
Expand Down
2 changes: 1 addition & 1 deletion src/features/serviceProvider/serviceProviderApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type SubscriptionServiceRequest = {
}

export type ServiceRequest = {
url: string
url: string | null
}

export const apiSlice = createApi({
Expand Down
2 changes: 1 addition & 1 deletion src/types/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ export const ALL_PAGES: IPage[] = [
},
{
name: PAGES.COMPANY_DATA,
role: ROLES.COMPANY_DATA,
role: ROLES.MY_ORGANIZATION_VIEW,
element: <CompanyData />,
},
]
Expand Down
1 change: 0 additions & 1 deletion src/types/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export enum ROLES {
VIEW_SUBSCRIPTION = 'view_subscription',
DELETE_CERTIFICATES = 'delete_certificates',
MY_ACCOUNT = 'view_own_user_account',
COMPANY_DATA = 'view_company_data',
CREDENTIAL_REQUESTS = 'view_credential_requests',
REVOKE_CREDENTIALS_ISSUER = 'revoke_credentials_issuer',
}
Expand Down

0 comments on commit 28767af

Please sign in to comment.