Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sd document): update SD document download API #1038

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

- **IDP management**
- Fixed statusTag color in status coloumn [#978](https://github.com/eclipse-tractusx/portal-frontend/pull/978)
- **Connector Management**
- Updated SD document download API to fix downloading SD document issue [#1038](https://github.com/eclipse-tractusx/portal-frontend/pull/1038)
- **Service Release Process**
- Fixed back button navigation to service management instead of navigating to home page[#1038](https://github.com/eclipse-tractusx/portal-frontend/pull/1038)
- **Application Requests**
- Fixed 'activeTab' conditions to load data for Tab-2(Registration Process) [#1050](https://github.com/eclipse-tractusx/portal-frontend/pull/1050)

Expand Down
15 changes: 6 additions & 9 deletions src/components/pages/EdcConnector/ConnectorDetailsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import {
useDeleteConnectorMutation,
useUpdateConnectorUrlMutation,
useFetchConnectorDetailsQuery,
useFetchSdDocumentMutation,
} from 'features/connector/connectorApiSlice'
import { Box, Divider, Grid } from '@mui/material'
import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import { useEffect, useState } from 'react'
import { error, success } from 'services/NotifyService'
import EditIcon from '@mui/icons-material/Edit'
import Patterns from 'types/Patterns'
import { useFetchDocumentMutation } from 'features/serviceManagement/apiSlice'
import { download } from 'utils/downloadUtils'
import UserService from 'services/UserService'
import { ROLES } from 'types/Constants'
Expand All @@ -59,7 +59,7 @@ const ConnectorDetailsOverlay = ({
overlayData,
}: DeleteConfirmationOverlayProps) => {
const { t } = useTranslation()
const [fetchDocumentById] = useFetchDocumentMutation()
const [fetchSDDocument] = useFetchSdDocumentMutation()
const {
data: fetchConnectorDetails,
isFetching,
Expand Down Expand Up @@ -135,10 +135,7 @@ const ConnectorDetailsOverlay = ({
const handleDownloadFn = async (documentId: string, documentName: string) => {
if (fetchConnectorDetails?.id) {
try {
const response = await fetchDocumentById({
appId: fetchConnectorDetails.id,
documentId,
}).unwrap()
const response = await fetchSDDocument(documentId).unwrap()

const fileType = response.headers.get('content-type')
const file = response.data
Expand Down Expand Up @@ -600,8 +597,8 @@ const ConnectorDetailsOverlay = ({
null ? (
t('content.edcconnector.details.noDocumentAvailable')
) : (
<>
<ArticleOutlinedIcon sx={{ color: '#9c9c9c' }} />
<Box sx={{ display: 'flex' }}>
<ArticleOutlinedIcon sx={{ color: '#9c9c9c', mr: 1 }} />
<button
className="document-button-link"
onClick={() =>
Expand All @@ -616,7 +613,7 @@ const ConnectorDetailsOverlay = ({
'content.edcconnector.details.selfDescriptionDocument'
)}
</button>
</>
</Box>
)}
</Typography>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { ButtonLabelTypes } from '..'
import RetryOverlay from '../components/RetryOverlay'
import { success, error } from 'services/NotifyService'
import { DocumentTypeId } from 'features/appManagement/apiSlice'
import { PAGES } from 'types/Constants'

type FormDataType = {
title: string
Expand Down Expand Up @@ -520,7 +521,7 @@ export default function OfferCard() {
setServiceCardSnackbar(false)
}}
onBackIconClick={() => {
navigate('/home')
navigate(`/${PAGES.SERVICE_MANAGEMENT}`)
}}
// Add an ESLint exception until there is a solution
// eslint-disable-next-line
Expand Down
10 changes: 10 additions & 0 deletions src/features/connector/connectorApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ export const apiSlice = createApi({
body: data.body,
}),
}),
fetchSdDocument: builder.mutation({
query: (documentId) => ({
url: `/api/administration/documents/selfDescription/${documentId}`,
responseHandler: async (response) => ({
headers: response.headers,
data: await response.blob(),
}),
}),
}),
}),
})

Expand All @@ -186,4 +195,5 @@ export const {
useFetchOfferSubscriptionsQuery,
useFetchDecentralIdentityUrlsQuery,
useUpdateConnectorUrlMutation,
useFetchSdDocumentMutation,
} = apiSlice
Loading