Skip to content

Commit

Permalink
feat(IDP): add disable and delete menu's (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Feb 22, 2024
1 parent ba076fd commit 79a02af
Show file tree
Hide file tree
Showing 10 changed files with 407 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- fixed logout redirect url issue
- Consent Pop-Up after registration
- fix reappear overlay on every page even after consent updated
- OSP IDP
- add disable, enable & delete sub-menu's to managed IdPs

### Bugfix

Expand Down
21 changes: 21 additions & 0 deletions src/assets/locales/de/idp.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@
"success": "IdP got disabled",
"error": "Something went wrong. IdP got not disabled."
},
"disableManagedIdp": {
"title": "Deaktivieren Sie den Identitätsanbieter",
"desc1": "Sie sind dabei, diesen IdP zu deaktivieren",
"desc2": "Bei der Deaktivierung des Identitätsanbieters bleiben alle Daten erhalten, der Zugriff wird jedoch gesperrt. Bitte achten Sie darauf, sich selbst bzw. Ihre Organisation nicht auszusperren. Die folgende Liste gibt einen Überblick über alle Organisationen, die bei der IdP-Verbindung registriert sind.",
"connectedCompanies": "Verbundene/verknüpfte Unternehmen:",
"none": "keiner",
"desc3": "Die Kunden werden über die Deaktivierung informiert. Eine Kommunikation der geplanten Deaktivierung von der IdP Owner Seite wird trotzdem stark empfohlen.",
"disableSuccess": "Verwalteter IdP erfolgreich deaktiviert",
"enableSuccess": "VVerwalteter IdP erfolgreich aktiviert",
"error": "Etwas ist schief gelaufen. Die Deaktivierung des verwalteten IdP war nicht erfolgreich."
},
"deleteManagedIdp": {
"title": "Identitätsanbieter löschen",
"desc1": "Sie sind dabei, diesen IdP zu löschen. Mit der Löschung des Identity Providers werden verbundene Unternehmen gelöscht bzw. auf gelöscht gesetzt. Überprüfen Sie die Liste der verbundenen Unternehmen sorgfältig und stellen Sie sicher, dass diese informiert sind, bevor Sie fortfahren.",
"desc2": "Mit der Löschung des Identity Providers werden verbundene Unternehmen gelöscht bzw. auf gelöscht gesetzt. Überprüfen Sie die Liste der verbundenen Unternehmen sorgfältig und stellen Sie sicher, dass diese informiert sind, bevor Sie fortfahren.",
"connectedCompanies": "Verbundene/verknüpfte Unternehmen:",
"none": "keiner",
"desc3": "Der Vorgang kann nicht rückgängig gemacht werden.",
"success": "Verwalteter IdP erfolgreich gelöscht",
"error": "Etwas ist schief gelaufen. Das Löschen des verwalteten IdP ist nicht erfolgreich."
},
"users": {
"title": "Update/Migrate User Accounts",
"subtitle": "Make sure users can continue working",
Expand Down
21 changes: 21 additions & 0 deletions src/assets/locales/en/idp.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@
"success": "IdP got disabled",
"error": "Something went wrong. IdP got not disabled."
},
"disableManagedIdp": {
"title": "Disable Identity Provider",
"desc1": "Your are about to disable this IdP",
"desc2": "With the deactivation of the identity provider - all data will remain, however the access will be blocked. Please ensure to not lock out yourself/your organization. Below list gives an overview all all organizations registered at the IdP connection.",
"connectedCompanies": "Connected/Linked companies :",
"none": "none",
"desc3": "The customer(s) will be informed of the deactivation. Communication of the planned deactivation from the IdP owner side is still strongly recommended.",
"disableSuccess": "Managed IdP disabled successfully",
"enableSuccess": "Managed IdP enabled successfully",
"error": "Something went wrong. Managed IdP disable is not successful."
},
"deleteManagedIdp": {
"title": "Delete Identity Provider",
"desc1": "Your are about to delete this IdP",
"desc2": "With the deletion of the identity provider - connected companies will get deleted or/and set to deleted. Validate the list of connected companies carefully and ensure that those are informed before proceeding.",
"connectedCompanies": "Connected/Linked companies :",
"none": "none",
"desc3": "The process cannot be reversed.",
"success": "Managed IdP deleted successfully",
"error": "Something went wrong. Managed IdP delete is not successful"
},
"users": {
"title": "Update/Migrate User Accounts",
"subtitle": "Make sure users can continue working",
Expand Down
143 changes: 143 additions & 0 deletions src/components/overlays/EnableIDP/DisableManagedIdp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/********************************************************************************
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useTranslation } from 'react-i18next'
import {
Button,
DialogActions,
DialogContent,
DialogHeader,
LoadingButton,
Typography,
} from '@catena-x/portal-shared-components'
import { useDispatch } from 'react-redux'
import { closeOverlay } from 'features/control/overlay'
import {
useEnableIDPMutation,
useFetchManagedIDPNetworkQuery,
} from 'features/admin/idpApiSlice'
import { success } from 'services/NotifyService'
import { useState } from 'react'

export const DisableManagedIDP = ({ id }: { id: string }) => {
const { t } = useTranslation('idp')
const dispatch = useDispatch()
const { data, refetch } = useFetchManagedIDPNetworkQuery(id)
const [enableIDP] = useEnableIDPMutation()
const [loading, setLoading] = useState(false)
const [enableErrorMessage, setEnableErrorMessage] = useState<boolean>(false)

const handleEnableDisable = async () => {
setLoading(true)
try {
data && (await enableIDP({ id, enabled: false }).unwrap())
success(t('disableManagedIdp.disableSuccess'))
setEnableErrorMessage(false)
refetch()
dispatch(closeOverlay())
setLoading(false)
} catch (err) {
setLoading(false)
setEnableErrorMessage(true)
}
}

return (
<>
<DialogHeader
title={t('disableManagedIdp.title')}
closeWithIcon={false}
onCloseWithIcon={() => dispatch(closeOverlay())}
/>
<DialogContent sx={{ padding: '0 110px 32px 110px' }}>
<Typography
variant="body2"
textAlign={'center'}
sx={{ lineHeight: '20px' }}
>
{t('disableManagedIdp.desc1')}
</Typography>
<Typography
variant="body2"
textAlign={'center'}
sx={{ lineHeight: '20px', mb: 6 }}
>
{t('disableManagedIdp.desc2')}
</Typography>
<Typography
variant="body2"
textAlign={'center'}
sx={{ lineHeight: '20px' }}
>
{t('disableManagedIdp.connectedCompanies')}
</Typography>
<Typography
variant="body2"
textAlign={'center'}
sx={{ lineHeight: '20px', mb: 3 }}
>
{data?.connectedCompanies && data.connectedCompanies.length > 0
? data.connectedCompanies.map((item) => item.companyName).join(', ')
: t('disableManagedIdp.none')}
</Typography>
<Typography
variant="body2"
textAlign={'center'}
sx={{ lineHeight: '20px' }}
>
{t('disableManagedIdp.desc3')}
</Typography>
{enableErrorMessage && (
<Typography
variant="label3"
sx={{ color: '#D91E18', display: 'block', mt: 3 }}
textAlign={'center'}
>
{t('disableManagedIdp.error')}
</Typography>
)}
</DialogContent>
<DialogActions>
<Button onClick={() => dispatch(closeOverlay())} variant="outlined">
{t('action.cancel')}
</Button>

{loading ? (
<LoadingButton
color="primary"
helperText=""
helperTextColor="success"
label=""
loadIndicator={t('action.loading')}
loading
size="medium"
onButtonClick={() => {
// do nothing
}}
sx={{ marginLeft: '10px' }}
/>
) : (
<Button variant="contained" onClick={handleEnableDisable}>
{t('action.disable')}
</Button>
)}
</DialogActions>
</>
)
}
140 changes: 140 additions & 0 deletions src/components/overlays/IDPDelete/DeleteManagedIdp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/********************************************************************************
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useTranslation } from 'react-i18next'
import {
Button,
DialogActions,
DialogContent,
DialogHeader,
LoadingButton,
Typography,
} from '@catena-x/portal-shared-components'
import { useDispatch } from 'react-redux'
import { closeOverlay } from 'features/control/overlay'
import {
useFetchManagedIDPNetworkQuery,
useRemoveIDPMutation,
} from 'features/admin/idpApiSlice'
import { success } from 'services/NotifyService'
import { useState } from 'react'

export const DeleteManagedIDP = ({ id }: { id: string }) => {
const { t } = useTranslation('idp')
const dispatch = useDispatch()
const { data } = useFetchManagedIDPNetworkQuery(id)
const [removeIDP] = useRemoveIDPMutation()
const [loadingButton, setLoadingButton] = useState(false)
const [enableErrorMessage, setEnableErrorMessage] = useState<boolean>(false)

const handleDelete = async () => {
setLoadingButton(true)
try {
await removeIDP(id).unwrap()
setLoadingButton(false)
dispatch(closeOverlay())
success(t('deleteManagedIdp.success'))
setEnableErrorMessage(false)
} catch (err) {
setEnableErrorMessage(true)
setLoadingButton(false)
}
}

return (
<>
<DialogHeader
title={t('deleteManagedIdp.title')}
closeWithIcon={false}
onCloseWithIcon={() => dispatch(closeOverlay())}
/>
<DialogContent sx={{ padding: '0 110px 32px 110px' }}>
<Typography
variant="body2"
sx={{ textAlign: 'center', lineHeight: '20px' }}
>
{t('deleteManagedIdp.desc1')}
</Typography>
<Typography
variant="body2"
sx={{ lineHeight: '20px', mb: 6, textAlign: 'center' }}
>
{t('deleteManagedIdp.desc2')}
</Typography>
<Typography
variant="body2"
sx={{ lineHeight: '20px', textAlign: 'center' }}
>
{t('deleteManagedIdp.connectedCompanies')}
</Typography>
<Typography
variant="body2"
sx={{ textAlign: 'center', lineHeight: '20px', mb: 3 }}
>
{data?.connectedCompanies && data.connectedCompanies.length > 0
? data.connectedCompanies.map((item) => item.companyName).join(', ')
: t('disableManagedIdp.none')}
</Typography>
<Typography
variant="body2"
sx={{ lineHeight: '20px', textAlign: 'center' }}
>
{t('deleteManagedIdp.desc3')}
</Typography>
{enableErrorMessage && (
<Typography
variant="label3"
sx={{
textAlign: 'center',
color: '#D91E18',
mt: 3,
display: 'block',
}}
>
{t('deleteManagedIdp.error')}
</Typography>
)}
</DialogContent>
<DialogActions>
<Button onClick={() => dispatch(closeOverlay())} variant="outlined">
{t('action.cancel')}
</Button>
{loadingButton ? (
<LoadingButton
color="primary"
label=""
helperTextColor="success"
size="medium"
sx={{ marginLeft: '10px' }}
onButtonClick={() => {
// do nothing
}}
loadIndicator={t('action.loading')}
helperText=""
loading={loadingButton}
/>
) : (
<Button variant="contained" onClick={handleDelete}>
{t('action.delete')}
</Button>
)}
</DialogActions>
</>
)
}
Loading

0 comments on commit 79a02af

Please sign in to comment.