forked from inveniosoftware/invenio-app-rdm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dashboard uploads: refactor uploads view
* remove empty content. * create a custom mobile interface. * fix request_items naming. * closes: inveniosoftware#1771
- Loading branch information
Showing
8 changed files
with
332 additions
and
131 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
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
146 changes: 146 additions & 0 deletions
146
.../semantic-ui/js/invenio_app_rdm/user_dashboard/uploads_items/ComputerTabletUploadsItem.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,146 @@ | ||
// This file is part of InvenioRDM | ||
// Copyright (C) 2022 CERN. | ||
// | ||
// Invenio App RDM is free software; you can redistribute it and/or modify it | ||
// under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
import { i18next } from "@translations/invenio_app_rdm/i18next"; | ||
import _get from "lodash/get"; | ||
import _truncate from "lodash/truncate"; | ||
import React from "react"; | ||
import { Button, Icon, Item, Label } from "semantic-ui-react"; | ||
import { SearchItemCreators } from "../../utils"; | ||
|
||
export const ComputerTabletUploadsItem = ({ | ||
result, | ||
index, | ||
editRecord, | ||
statuses, | ||
}) => { | ||
const access_status_id = _get( | ||
result, | ||
"ui.access_status.id", | ||
i18next.t("open") | ||
); | ||
const access_status = _get( | ||
result, | ||
"ui.access_status.title_l10n", | ||
i18next.t("Open") | ||
); | ||
const access_status_icon = _get( | ||
result, | ||
"ui.access_status.icon", | ||
i18next.t("unlock") | ||
); | ||
const description_stripped = _get( | ||
result, | ||
"ui.description_stripped", | ||
i18next.t("No description") | ||
); | ||
const title = _get(result, "metadata.title", i18next.t("No title")); | ||
const creators = _get(result, "ui.creators.creators", []).slice(0, 3); | ||
const subjects = _get(result, "ui.subjects", []); | ||
const publicationDate = _get( | ||
result, | ||
"ui.publication_date_l10n_long", | ||
i18next.t("No publication date found.") | ||
); | ||
const resource_type = _get( | ||
result, | ||
"ui.resource_type.title_l10n", | ||
i18next.t("No resource type") | ||
); | ||
const createdDate = result.ui?.created_date_l10n_long; | ||
const version = result.ui?.version ?? ""; | ||
const is_published = result.is_published; | ||
|
||
const viewLink = is_published | ||
? `/records/${result.id}` | ||
: `/uploads/${result.id}`; | ||
const icon = is_published ? ( | ||
<Icon name="check" color="green" /> | ||
) : ( | ||
<Icon name="upload" color="red" /> | ||
); | ||
|
||
return ( | ||
<Item | ||
key={index} | ||
className="deposits-list-item mb-20 computer tablet only flex" | ||
> | ||
<div className="status-icon mr-10"> | ||
<Item.Content verticalAlign="top"> | ||
<Item.Extra>{icon}</Item.Extra> | ||
</Item.Content> | ||
</div> | ||
<Item.Content style={{ cursor: "default" }}> | ||
<Item.Extra className="labels-actions"> | ||
{result.status in statuses && result.status !== "published" && ( | ||
<Label size="tiny" color={statuses[result.status].color}> | ||
{statuses[result.status].title} | ||
</Label> | ||
)} | ||
<Label size="tiny" color="blue"> | ||
{publicationDate} ({version}) | ||
</Label> | ||
<Label size="tiny" color="grey"> | ||
{resource_type} | ||
</Label> | ||
<Label size="tiny" className={`access-status ${access_status_id}`}> | ||
<i className={`icon ${access_status_icon}`}></i> | ||
{access_status} | ||
</Label> | ||
<Button | ||
compact | ||
size="small" | ||
floated="right" | ||
onClick={() => editRecord()} | ||
> | ||
<Icon name="edit" /> | ||
{i18next.t("Edit")} | ||
</Button> | ||
{is_published && ( | ||
<Button compact size="small" floated="right" href={viewLink}> | ||
<Icon name="eye" /> | ||
{i18next.t("View")} | ||
</Button> | ||
)} | ||
</Item.Extra> | ||
<Item.Header as="h2"> | ||
<a href={viewLink} className="truncate-lines-2"> | ||
{title} | ||
</a> | ||
</Item.Header> | ||
<Item.Meta> | ||
<div className="creatibutors"> | ||
<SearchItemCreators creators={creators} /> | ||
</div> | ||
</Item.Meta> | ||
<Item.Description> | ||
{_truncate(description_stripped, { | ||
length: 350, | ||
})} | ||
</Item.Description> | ||
<Item.Extra> | ||
{subjects.map((subject, index) => ( | ||
<Label key={index} size="tiny"> | ||
{subject.title_l10n} | ||
</Label> | ||
))} | ||
<div> | ||
{} | ||
<small> | ||
{createdDate ? ( | ||
<> | ||
{i18next.t("Uploaded on")} <span>{createdDate}</span> | ||
</> | ||
) : ( | ||
i18next.t("No creation date found.") | ||
)} | ||
</small> | ||
</div> | ||
</Item.Extra> | ||
</Item.Content> | ||
</Item> | ||
); | ||
}; |
Oops, something went wrong.