From 392764df75b81f50c25ccdfb4884c64a067c7dd3 Mon Sep 17 00:00:00 2001 From: Novak Zaballa Date: Fri, 7 Jun 2024 10:11:04 -0400 Subject: [PATCH] Change IDP Metadata UI, and download it --- frontend/web/components/XMLUpload.tsx | 3 +- frontend/web/components/modals/CreateSAML.tsx | 126 ++++++++++-------- 2 files changed, 70 insertions(+), 59 deletions(-) diff --git a/frontend/web/components/XMLUpload.tsx b/frontend/web/components/XMLUpload.tsx index 866e9aecff84..6bee93bad091 100644 --- a/frontend/web/components/XMLUpload.tsx +++ b/frontend/web/components/XMLUpload.tsx @@ -56,10 +56,9 @@ const XMLUpload: FC = ({ onChange, value }) => {
- Select a file or drag and drop here + Drag a file or click to select a file
XML File
-
)} diff --git a/frontend/web/components/modals/CreateSAML.tsx b/frontend/web/components/modals/CreateSAML.tsx index 4390435be9bc..586d1a71ac23 100644 --- a/frontend/web/components/modals/CreateSAML.tsx +++ b/frontend/web/components/modals/CreateSAML.tsx @@ -14,8 +14,8 @@ import { Req } from 'common/types/requests' import ErrorMessage from 'components/ErrorMessage' import { getStore } from 'common/store' import XMLUpload from 'components/XMLUpload' -import Tabs from 'components/base/forms/Tabs' -import TabItem from 'components/base/forms/TabItem' +import { IonIcon } from '@ionic/react' +import { cloudDownloadOutline } from 'ionicons/icons' type CreateSAML = { organisationId: number @@ -43,16 +43,21 @@ const CreateSAML: FC = ({ organisationId, samlName }) => { return regularExpresion.test(name) } - const download = () => { + const convetToXmlFile = (fileName: string, data: string) => { + const blob = new Blob([data], { type: 'application/xml' }) + const link = document.createElement('a') + link.download = `${fileName}.xml` + link.href = window.URL.createObjectURL(blob) + link.click() + } + + const downloadServiceProvider = () => { setIsLoading(true) - getSamlConfigurationMetadata(getStore(), { name: name }) + const name = data?.name || samlName + getSamlConfigurationMetadata(getStore(), { name: name! }) .then((res) => { if (res.error) { - const blob = new Blob([res.error.data], { type: 'application/xml' }) - const link = document.createElement('a') - link.download = `${data?.name}.xml` - link.href = window.URL.createObjectURL(blob) - link.click() + convetToXmlFile(name!, res.error.data) } }) .finally(() => { @@ -60,6 +65,11 @@ const CreateSAML: FC = ({ organisationId, samlName }) => { }) } + const downloadIDPMetadata = () => { + const name = data?.name || samlName + convetToXmlFile(`IDP metadata ${name!}`, data?.idp_metadata_xml || '') + } + return (
= ({ organisationId, samlName }) => { } /> - - -
- -
-
- -
- {uploadMetadataXml && ( - + + + {data?.idp_metadata_xml && ( +
+ - )} - { - setFile(file) - setUploadMetadataXml(data as string) - setMetadataXml(data as string) - }} - /> -
- - - } - title={'IDP Metadata XML'} - /> + } + place='right' + > + Download IDP Metadata + +
+ )} + + + + + Or + + + { + setFile(file) + setUploadMetadataXml(data as string) + setMetadataXml(data as string) + }} + /> +
- {data?.idp_metadata_xml && ( - - )} +