Skip to content

Commit

Permalink
redirect icons to detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjeevani vishaka committed Nov 20, 2019
1 parent 911cfc4 commit 9c4ba0a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/components/search-result/search-result.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@
}
}

.expandableIcon {
font-size: 15px;
margin-right: 5px;
cursor: pointer
}

.redirectIcons {
float: right;
}
float: right;
}

.redirectIcons a {
padding: 8px;
color: #666;
}
6 changes: 3 additions & 3 deletions src/components/search-result/search-result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ const SearchResult: React.FC<Props> = (props) => {
return (
<div style={{width: '100%'}}>
<div className={styles.title} onClick={() => showTableEntityProperties()}>
<Icon style={{fontSize: '15px', marginRight: '5px'}} type='right' rotate={show ? 90 : undefined}/>
<Icon className={styles.expandableIcon} type='right' rotate={show ? 90 : undefined}/>
<div className={styles.redirectIcons}>
<Link to={{pathname: `/detail/${primaryKeyValue}/${uri}`}} data-cy='primary-key'>
<Link to={{pathname: `/detail/${primaryKeyValue}/${uri}`,state: {selectedValue:'instance'}}} data-cy='primary-key'>
<FontAwesomeIcon icon={faExternalLinkAlt} size="sm" />
</Link>
<Link to={{pathname: `/detail/${primaryKeyValue}/${uri}`}} data-cy='primary-key'>
<Link to={{pathname: `/detail/${primaryKeyValue}/${uri}`,state: {selectedValue:'source'}}} data-cy='primary-key'>
<FontAwesomeIcon icon={faCode} size="sm" />
</Link>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Props extends RouteComponentProps<any> {
}

const Browse: React.FC<Props> = ({ location }) => {

const { Content, Sider } = Layout;
const componentIsMounted = useRef(true);
const { user, handleError } = useContext(AuthContext);
Expand Down
16 changes: 11 additions & 5 deletions src/pages/Detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ interface Props extends RouteComponentProps<any> { }
const { Content } = Layout;

const Detail: React.FC<Props> = ({ history, location }) => {
//console.log(history)

const { user, handleError } = useContext(AuthContext);
const uriSplit = location.pathname.replace('/detail/', '');
const pkValue = uriSplit.split('/')[0] === '-' ? '' : decodeURIComponent(uriSplit.split('/')[0]);
const uri = decodeURIComponent(uriSplit.split('/')[1]).replace(/ /g, "%2520");
const docUri = uri.replace(/%25/g, "%");
const [selected, setSelected] = useState('instance');
const [selected, setSelected] = useState();
const [data, setData] = useState();
const [isLoading, setIsLoading] = useState(false);
const [contentType, setContentType] = useState();
Expand Down Expand Up @@ -53,7 +53,12 @@ const Detail: React.FC<Props> = ({ history, location }) => {
setData(xmlParser(decodedXml).Document);
setXml(xmlDecoder(decodedXml));
}

if(location.state.selectedValue === 'instance') {
setSelected('instance')
}
else{
setSelected('full')
}
setIsLoading(false);
}

Expand All @@ -72,6 +77,7 @@ const Detail: React.FC<Props> = ({ history, location }) => {

}, []);


const handleClick = (event) => {
setSelected(event.key);
}
Expand Down Expand Up @@ -99,11 +105,11 @@ const Detail: React.FC<Props> = ({ history, location }) => {
</div>
<div>
{
isLoading || user.error.type === 'ALERT' ? <div style={{ marginTop: '40px' }}>
isLoading || user.error.type === 'ALERT' ? <div style={{ marginTop: '40px' }}>
<AsyncLoader />
</div>
:
contentType === 'json' ?
contentType === 'json' ?
selected === 'instance' ? (data && <TableView document={data} contentType={contentType} />) : (data && <JsonView document={data} />)
:
selected === 'instance' ? (data && <TableView document={data} contentType={contentType} />) : (data && <XmlView document={xml} />)
Expand Down

0 comments on commit 9c4ba0a

Please sign in to comment.