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

updated metadata display #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
30 changes: 27 additions & 3 deletions src/js/components/admin/form/ProfileForm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react"
import PropTypes from 'prop-types';
import { AgGridReact } from 'ag-grid-react';
import { Button, Card, Col, Form, Row, Tabs, Tab } from 'react-bootstrap';
import { Button, Card, Col, Form, Row, Tabs, Tab, OverlayTrigger, Tooltip } from 'react-bootstrap';
import Select from 'react-select';

import {
Expand Down Expand Up @@ -349,18 +349,42 @@ class ProfileForm extends Component {

renderMetadata(metadata) {
return (
<>
<style type="text/css">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style tag should not be in the html body. It should be in the head instead. Especially if the css part is static and does not have to be changed in the React element dynamically

{`
.tooltip-inner {
max-width: none !important;
}
.div-nowrap {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
`}
</style>
<Card>
<Card.Body>
<Row as="dl">
{Object.keys(metadata).map((key, index) => (
<React.Fragment key={index}>
<Col as="dt" lg={3}>{key}:</Col>
<Col as="dd" lg={9}>{metadata[key] || ' '}</Col>
{key.length > window.innerWidth / 50 ? ( // only show tooltip if key is long (compared on window size)
<OverlayTrigger placement="top-start"
overlay={
<Tooltip id={`tooltip-${index}`}>
{key}
</Tooltip>
}
>
<Col as="dt" lg={5}><div class='div-nowrap'>{key}:</div></Col>
</OverlayTrigger> ) : (<Col as="dt" lg={5}><div class='div-nowrap'>{key}:</div></Col>) }
<Col as="dd" lg={7}>{metadata[key] || ' '}</Col>
</React.Fragment>
))}
</Row>
</Card.Body>
</Card>
</>
)
}

Expand Down