From 60b048095b39e1ed00c193406358ab025984569b Mon Sep 17 00:00:00 2001 From: Andrea Tabone Date: Wed, 8 Nov 2023 17:07:06 +0100 Subject: [PATCH 01/58] add content mapping - wip Signed-off-by: at670475 --- .../src/components/DetailPage/DetailPage.jsx | 10 ++++- .../DetailPage/DetailPageContainer.jsx | 1 + .../src/components/ServiceTab/ServiceTab.jsx | 9 ++++ .../components/ServiceTab/VideoWrapper.jsx | 44 +++++++++++++++++++ .../src/utils/educational_contents.json | 34 ++++++++++++++ .../frontend/src/utils/utilFunctions.js | 38 ++++++++++------ 6 files changed, 122 insertions(+), 14 deletions(-) create mode 100644 api-catalog-ui/frontend/src/components/ServiceTab/VideoWrapper.jsx create mode 100644 api-catalog-ui/frontend/src/utils/educational_contents.json diff --git a/api-catalog-ui/frontend/src/components/DetailPage/DetailPage.jsx b/api-catalog-ui/frontend/src/components/DetailPage/DetailPage.jsx index 41db1ecc70..11953b16f4 100644 --- a/api-catalog-ui/frontend/src/components/DetailPage/DetailPage.jsx +++ b/api-catalog-ui/frontend/src/components/DetailPage/DetailPage.jsx @@ -79,6 +79,7 @@ export default class DetailPage extends Component { history, currentTileId, fetchNewTiles, + selectedService, } = this.props; let { tiles } = this.props; const iconBack = ; @@ -102,8 +103,12 @@ export default class DetailPage extends Component { } const apiPortalEnabled = isAPIPortal(); const hasTiles = !fetchTilesError && tiles && tiles.length > 0; - const { useCasesCounter, tutorialsCounter, videosCounter } = countAdditionalContents(services); + // eslint-disable-next-line no-console + console.log(tiles); + const { useCasesCounter, tutorialsCounter, videosCounter, useCases, tutorials, videos } = countAdditionalContents(selectedService); const onlySwaggerPresent = tutorialsCounter === 0 && videosCounter === 0 && useCasesCounter === 0; + // eslint-disable-next-line no-console + console.log(tutorialsCounter); const showSideBar = false; if ( hasTiles && @@ -236,6 +241,9 @@ export default class DetailPage extends Component { render={() => (
({ fetchTilesError: state.tilesReducer.error, selectedTile: state.selectedServiceReducer.selectedTile, selectedServiceId: state.selectedServiceReducer.selectedService.serviceId, + selectedService: state.selectedServiceReducer.selectedService, isLoading: loadingSelector(state), currentTileId: state.tilesReducer.currentTileId, }); diff --git a/api-catalog-ui/frontend/src/components/ServiceTab/ServiceTab.jsx b/api-catalog-ui/frontend/src/components/ServiceTab/ServiceTab.jsx index d70f6173bd..68eeeaf70f 100644 --- a/api-catalog-ui/frontend/src/components/ServiceTab/ServiceTab.jsx +++ b/api-catalog-ui/frontend/src/components/ServiceTab/ServiceTab.jsx @@ -13,6 +13,7 @@ import Shield from '../ErrorBoundary/Shield/Shield'; import SwaggerContainer from '../Swagger/SwaggerContainer'; import ServiceVersionDiffContainer from '../ServiceVersionDiff/ServiceVersionDiffContainer'; import { isAPIPortal } from '../../utils/utilFunctions'; +import VideoWrapper from './VideoWrapper'; export default class ServiceTab extends Component { constructor(props) { @@ -144,6 +145,9 @@ export default class ServiceTab extends Component { }, tiles, selectedService, + useCases, + tutorials, + videos, useCasesCounter, tutorialsCounter, videosCounter, @@ -310,6 +314,10 @@ export default class ServiceTab extends Component { > Use Cases ({useCasesCounter}) + {useCases && + useCases.map((useCase) => ( + {useCase} + ))}


+ {videos && videos.map((url) => )}
)} diff --git a/api-catalog-ui/frontend/src/components/ServiceTab/VideoWrapper.jsx b/api-catalog-ui/frontend/src/components/ServiceTab/VideoWrapper.jsx new file mode 100644 index 0000000000..ba4b63e5bc --- /dev/null +++ b/api-catalog-ui/frontend/src/components/ServiceTab/VideoWrapper.jsx @@ -0,0 +1,44 @@ +/* + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + */ +import React from 'react'; +import PropTypes from 'prop-types'; + +function VideoWrapper({ url }) { + const isValidUrl = () => { + try { + return Boolean(new URL(url)); + } catch (e) { + return false; + } + }; + // eslint-disable-next-line no-console + console.log(url); + if (!isValidUrl()) return null; + return ( +
+