-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add details view for publications (#3994)
* first mock up * removed console logging * refined publication details view * fixed screenshot tests and adjusted icons * applied feedback: renaming, shortening and beautifying
- Loading branch information
1 parent
51b2721
commit 2f97e47
Showing
6 changed files
with
134 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
frontend/javascripts/dashboard/publication_details_view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// @flow | ||
import * as React from "react"; | ||
import { Layout, Icon, Spin, Tooltip } from "antd"; | ||
|
||
import { getDatasets } from "admin/admin_rest_api"; | ||
import type { APIDataset, APIMaybeUnimportedDataset } from "admin/api_flow_types"; | ||
import PublicationCard from "dashboard/publication_card"; | ||
import { handleGenericError } from "libs/error_handling"; | ||
import { SimpleHeader } from "dashboard/spotlight_view"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const { Content } = Layout; | ||
|
||
type Props = { | ||
publicationId: string, | ||
}; | ||
|
||
type State = { | ||
datasets: Array<APIMaybeUnimportedDataset>, | ||
isLoading: boolean, | ||
}; | ||
|
||
class PublicationDetailView extends React.PureComponent<Props, State> { | ||
state = { | ||
datasets: [], | ||
isLoading: true, | ||
}; | ||
|
||
componentDidMount() { | ||
this.fetchData(); | ||
} | ||
|
||
async fetchData(): Promise<void> { | ||
try { | ||
this.setState({ isLoading: true }); | ||
const datasets = await getDatasets(); | ||
this.setState({ datasets }); | ||
} catch (error) { | ||
handleGenericError(error); | ||
} finally { | ||
this.setState({ isLoading: false }); | ||
} | ||
} | ||
|
||
render() { | ||
const { isLoading, datasets } = this.state; | ||
const datasetsOfPublication = ((datasets.filter( | ||
ds => ds.isActive && ds.publication != null && ds.publication.id === this.props.publicationId, | ||
): any): Array<APIDataset>); | ||
return ( | ||
<Layout> | ||
<SimpleHeader /> | ||
<Content className="centered-content"> | ||
<Spin size="large" spinning={isLoading}> | ||
{datasetsOfPublication.length > 0 ? ( | ||
<React.Fragment> | ||
<Link to="/"> | ||
<Tooltip title="Back to the frontpage."> | ||
<Icon | ||
type="arrow-left" | ||
style={{ fontSize: 24, color: "#555", marginBottom: 18 }} | ||
/> | ||
</Tooltip> | ||
</Link> | ||
<div style={{ display: "inline-block", verticalAlign: "top" }}>Back</div> | ||
<PublicationCard | ||
className="dataset-panel" | ||
datasets={datasetsOfPublication} | ||
showDetailedLink={false} | ||
/> | ||
</React.Fragment> | ||
) : null} | ||
{!isLoading && datasetsOfPublication.length === 0 ? ( | ||
<p style={{ textAlign: "center" }}>There are not datasets for this publication.</p> | ||
) : null} | ||
</Spin> | ||
</Content> | ||
</Layout> | ||
); | ||
} | ||
} | ||
|
||
export default PublicationDetailView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters