Skip to content

Commit

Permalink
Update publisher Ui to support search improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Avishka-Shamendra committed Sep 9, 2024
1 parent 60dae19 commit fe9748d
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1625,9 +1625,12 @@
"Apis.Listing.SampleAPIProduct.creator.error": "API is not deployed yet! Please deploy the API before trying out",
"Apis.Listing.SampleAPIProduct.description": "Combine multiple API resources in to a single API",
"Apis.Listing.SampleAPIProduct.onboarding.menu.card.name": "API Product",
"Apis.Listing.TableView.TableView.def.flag": "[Def]",
"Apis.Listing.TableView.TableView.doc.flag": "[Doc]",
"Apis.Listing.TableView.TableView.error.loading": "Error While Loading APIs",
"Apis.Listing.TaskState.generic.error.prefix": "Error while",
"Apis.Listing.components.ImageGenerator.DefThumb.apiName": "API Name",
"Apis.Listing.components.ImageGenerator.DefThumb.apiVersion": "API Version",
"Apis.Listing.components.ImageGenerator.DocThumb.apiName": "API Name",
"Apis.Listing.components.ImageGenerator.DocThumb.apiVersion": "API Version",
"Apis.Listing.components.ImageGenerator.DocThumb.sourceType": "Source Type:",
Expand Down Expand Up @@ -2030,4 +2033,4 @@
"upload.image": "Click or drag the image to upload.",
"upload.image.size.error": "Uploaded File is too large. Maximum file size limit to 1MB",
"upload.image.size.info": "Maximum file size limit to 1MB"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import TopMenu from 'AppComponents/Apis/Listing/components/TopMenu';
import CustomIcon from 'AppComponents/Shared/CustomIcon';
import SampleAPIProduct from 'AppComponents/Apis/Listing/SampleAPI/SampleAPIProduct';
import Alert from 'AppComponents/Shared/Alert';
import DefThumb from '../components/ImageGenerator/DefThumb';

const PREFIX = 'TableView';

Expand Down Expand Up @@ -349,6 +350,23 @@ class TableView extends React.Component {
<span>{apiName}</span>
</Link>
);
} else if (artifact.type === 'DEFINITION') {
const linkTo = artifact.associatedType === 'API'
? `/apis/${artifact.apiUUID}/api-definition`
: `/api-products/${artifact.apiUUID}/api-definition`;
return (
<Link
to={linkTo}
className={classes.apiNameLink}
>
<Icon>code</Icon>
<FormattedMessage
id='Apis.Listing.TableView.TableView.def.flag'
defaultMessage=' [Def]'
/>
<span>{artifact.name}</span>
</Link>
);
}
return (
<Link to={'/apis/' + apiId + '/overview'} className={classes.apiNameLink}>
Expand Down Expand Up @@ -449,6 +467,8 @@ class TableView extends React.Component {
if (artifact) {
if (artifact.type === 'DOC') {
return <DocThumb doc={artifact} />;
} else if (artifact.type === 'DEFINITION') {
return <DefThumb def={artifact} />;
} else if (artifact.type === 'APIPRODUCT') {
artifact.state = 'PUBLISHED';
return <ApiThumb api={artifact} isAPIProduct updateData={this.updateData} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/*
* Copyright (c) 2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.
*/
import React, { useState } from 'react';
import { styled } from '@mui/material/styles';
import { Link as RouterLink } from 'react-router-dom';
import Link from '@mui/material/Link';
import PropTypes from 'prop-types';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
import Grid from '@mui/material/Grid';
import Box from '@mui/material/Box';
import LetterGenerator from 'AppComponents/Apis/Listing/components/ImageGenerator/LetterGenerator';
import Configurations from 'Config';

const PREFIX = 'DefThumb';

const classes = {
card: `${PREFIX}-card`,
thumbHeader: `${PREFIX}-thumbHeader`
};

const StyledLink = styled(Link)((
{
theme
}
) => ({
[`& .${classes.card}`]: {
margin: theme.spacing(3 / 2),
maxWidth: theme.spacing(32),
transition: 'box-shadow 0.3s ease-in-out',
},

[`& .${classes.thumbHeader}`]: {
maxWidth: theme.spacing(16),
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'normal',
wordBreak: 'break-word',
overflowWrap: 'break-word',
},

[`& .${classes.defaultCardContent}`]: {
height: '111px',
},

[`& .${classes.maxCardContent}`]: {
height: '208px',
},

[`& .${classes.minCardContent}`]: {
height: '187px',
},
}));


const DefThumb = (props) => {
const { def } = props;
const [isHover, setIsHover] = useState(false);
const toggleMouseOver = () => setIsHover(!isHover);
const linkTo = def.associatedType === 'API'
? `/apis/${def.apiUUID}/api-definition`
: `/api-products/${def.apiUUID}/api-definition`;

let thumbIcon;
let configValue;
const { tileDisplayInfo } = Configurations.apis;
if (tileDisplayInfo.showBusinessDetails === true && tileDisplayInfo.showTechnicalDetails === true) {
configValue = 2;
} else if (tileDisplayInfo.showBusinessDetails === true || tileDisplayInfo.showTechnicalDetails === true) {
configValue = 1;
}
let cardContentClassName;
if (configValue === 1) {
cardContentClassName = classes.minCardContent;
} else if (configValue === 2) {
cardContentClassName = classes.maxCardContent;
} else {
cardContentClassName = classes.defaultCardContent;
}
return (
<StyledLink
underline='none'
component={RouterLink}
to={linkTo}
aria-hidden='true'
>
<Card
onMouseOver={toggleMouseOver}
onFocus={toggleMouseOver}
onMouseOut={toggleMouseOver}
onBlur={toggleMouseOver}
elevation={isHover ? 4 : 1}
className={classes.card}
>
<CardMedia
width={240}
component={LetterGenerator}
height={140}
title='Thumbnail'
artifact={{ name: 'Def' }}
charLength={3}
ThumbIcon={thumbIcon}
/>
<CardContent className={cardContentClassName}>
<Grid
container
direction='column'
justifyContent='space-evenly'
alignItems='flex-start'
>
<Grid item>
<Box display='flex' alignItems='center' flexDirection='row' fontFamily='fontFamily'>
<Box
className={classes.thumbHeader}
color='text.primary'
fontSize='h4.fontSize'
ml={1}
>
{def.name}
</Box>
</Box>
</Grid>
<Grid item>
<Box mt={3} fontFamily='fontFamily'>
<Box color='primary.main'>
{def.associatedType}
</Box>
<Box color='text.primary' fontSize='h6.fontSize'>
{def.apiName}
</Box>
<Box color='text.secondary' fontSize='body1.fontSize'>
Version:
{' '}
{def.apiVersion}
</Box>
</Box>
</Grid>
</Grid>
</CardContent>
</Card>
</StyledLink>
);
};

DefThumb.propTypes = {
def: PropTypes.shape({
id: PropTypes.string,
name: PropTypes.string,
apiName: PropTypes.string.isRequired,
apiVersion: PropTypes.string.isRequired,
}).isRequired,
};
export default DefThumb;
Loading

0 comments on commit fe9748d

Please sign in to comment.