+ {theme.custom.thumbnail.defaultApiImage ? (
+
+ ) : (
+
+ )}
+
+
-
-
- {name}
-
-
-
-
- {sourceType}
+ {name}
+
+
+
+ {sourceType}
+
+
+
+ {apiName}
+
+
+ {apiVersion}
+
+
+
+
+
+
+
+
-
-
- {apiName}
-
-
-
-
-
-
- {apiVersion}
-
-
-
-
-
-
-
- );
- }
-}
+
+
+ );
+};
DocThumbLegacy.propTypes = {
- classes: PropTypes.shape({}).isRequired,
- theme: PropTypes.shape({}).isRequired,
+ doc: PropTypes.shape({
+ name: PropTypes.string,
+ sourceType: PropTypes.string,
+ apiName: PropTypes.string,
+ apiVersion: PropTypes.string,
+ id: PropTypes.string,
+ apiUUID: PropTypes.string,
+ }).isRequired,
};
-DocThumbLegacy.contextType = ApiContext;
-
-function DocThumb(props) {
- const { doc } = props;
- const theme = useTheme();
- return (
-
- );
-}
-
-export default (DocThumb);
+export default DocThumbLegacy;
diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICards/ImageGenerator.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICards/ImageGenerator.jsx
index 3d36ebd907c..7f726845a50 100755
--- a/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICards/ImageGenerator.jsx
+++ b/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICards/ImageGenerator.jsx
@@ -78,6 +78,8 @@ class ImageGeneratorLegacy extends PureComponent {
IconElement = key;
} else if (api.type === 'DOC') {
IconElement = theme.custom.thumbnail.document.icon;
+ } else if (api.type === 'DEFINITION') {
+ IconElement = theme.custom.thumbnail.definition.icon;
} else {
count = MaterialIcons.categories[10].icons.length;
const randomIconIndex = (str.charCodeAt(0) + str.charCodeAt(str.length - 1)) % count;
@@ -87,6 +89,8 @@ class ImageGeneratorLegacy extends PureComponent {
// Obtain or generate background color pair
if (api.type === 'DOC') {
colorPair = theme.custom.thumbnail.document.backgrounds;
+ } else if (api.type === 'DEFINITION') {
+ colorPair = theme.custom.thumbnail.definition.backgrounds;
} else if (backgroundIndex && colorPairs.length > backgroundIndex) {
colorPair = colorPairs[backgroundIndex];
} else {
diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/ApiTableView.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/ApiTableView.jsx
index 3dece98983c..23b3ce57b7c 100644
--- a/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/ApiTableView.jsx
+++ b/portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/ApiTableView.jsx
@@ -44,6 +44,7 @@ import { useTheme } from '@mui/material';
import ImageGenerator from './APICards/ImageGenerator';
import ApiThumb from './ApiThumb';
import DocThumb from './APICards/DocThumb';
+import DefinitionThumb from './APICards/DefThumb';
import { ApiContext } from '../Details/ApiContext';
import NoApi from './NoApi';
@@ -378,6 +379,25 @@ class ApiTableViewLegacy extends React.Component {
);
+ } else if (artifact.type === 'DEFINITION') {
+ return (
+
+
code
+
+
+ {' '}
+
+ {' '}
+ {apiName}
+
+
+ );
}
const strokeColor = theme.palette.getContrastText(theme.custom.listView.tableBodyEvenBackgrund);
return (
@@ -486,7 +506,7 @@ class ApiTableViewLegacy extends React.Component {
if (tableMeta.rowData) {
const artifact = tableViewObj.state.data[tableMeta.rowIndex];
if (artifact) {
- if (artifact.type !== 'DOC') {
+ if (artifact.type !== 'DOC' && artifact.type !== 'DEFINITION') {
const apiId = tableMeta.rowData[0];
const avgRating = tableMeta.rowData[8];
return (
@@ -579,6 +599,8 @@ class ApiTableViewLegacy extends React.Component {
if (artifact) {
if (artifact.type === 'DOC') {
return
|
;
+ } else if (artifact.type === 'DEFINITION') {
+ return
|
;
} else {
return (
diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Base/Header/Search/SearchUtils.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Base/Header/Search/SearchUtils.jsx
index 1dc3b904b44..e3ea4c834a3 100644
--- a/portals/devportal/src/main/webapp/source/src/app/components/Base/Header/Search/SearchUtils.jsx
+++ b/portals/devportal/src/main/webapp/source/src/app/components/Base/Header/Search/SearchUtils.jsx
@@ -32,6 +32,7 @@ import SearchOutlined from '@mui/icons-material/SearchOutlined';
import { Link } from 'react-router-dom';
import APIsIcon from '@mui/icons-material/SettingsApplicationsOutlined';
import DocumentsIcon from '@mui/icons-material/LibraryBooks';
+import CodeIcon from '@mui/icons-material/Code';
import NativeSelect from '@mui/material/NativeSelect';
import { FormattedMessage } from 'react-intl';
import CircularProgress from '@mui/material/CircularProgress';
@@ -168,6 +169,20 @@ function renderInput(inputProps) {
);
}
+/**
+ * Get search result path
+ */
+function getPath(suggestion) {
+ switch (suggestion.type) {
+ case 'API':
+ return `/apis/${suggestion.id}/overview`;
+ case 'DEFINITION':
+ return `/apis/${suggestion.apiUUID}/overview`;
+ default:
+ return `/apis/${suggestion.apiUUID}/documents/${suggestion.id}/details`;
+ }
+}
+
/**
*
* Use your imagination to define how suggestions are rendered.
@@ -178,16 +193,24 @@ function renderInput(inputProps) {
function renderSuggestion(suggestion, { query, isHighlighted }) {
const matches = match(suggestion.name, query);
const parts = parse(suggestion.name, matches);
- const path = suggestion.type === 'API' ? `/apis/${suggestion.id}/overview`
- : `/apis/${suggestion.apiUUID}/documents/${suggestion.id}/details`;
+ const path = getPath(suggestion);
// TODO: Style the version ( and apiName if docs) apearing in the menu item
const suffix = suggestion.type === 'API' ? suggestion.version : (suggestion.apiName + ' ' + suggestion.apiVersion);
+ const getIcon = (type) => {
+ if (type === 'API') {
+ return ;
+ } else if (type === 'DEFINITION') {
+ return ;
+ } else {
+ return ;
+ }
+ };
return (
<>