Skip to content

Commit

Permalink
Merge branch 'staging' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
monotasker committed Nov 8, 2024
2 parents c93e074 + 535b0b2 commit c4939d1
Show file tree
Hide file tree
Showing 9 changed files with 440 additions and 4 deletions.
3 changes: 2 additions & 1 deletion assets/js/invenio_app_rdm/overridableRegistry/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { PublicMembersResultsItemWithCommunity } from "./collections/members/pub
import { PublisherField } from "./fields/PublisherField";
import { RDMRecordMultipleSearchBarElement } from "./search/RDMRecordMultipleSearchBarElement";
import RecordsResultsListItem from "./search/RecordsResultsListItem";
import { RecordResultsListItemDashboard } from "./search/RecordsResultsListItemDashboard";
import { RequestMetadata } from "./requests/RequestMetadata";
import { RequestsResultsItemTemplateDashboard } from "./user_dashboard/RequestsResultsItemTemplateDashboard";
import { RequestsResultsItemTemplateWithCommunity } from "./collections/members/requests/RequestsResultsItemTemplate";
Expand Down Expand Up @@ -87,7 +88,7 @@ export const overriddenComponents = {
"InvenioAppRdm.DashboardRequests.SearchApp.layout": DashboardRequestsSearchLayoutWithApp,
"InvenioAppRdm.DashboardRequests.ResultsList.item": RequestsResultsItemTemplateDashboard,
"InvenioAppRdm.DashboardUploads.SearchApp.layout": DashboardUploadsSearchLayout,
"InvenioAppRdm.DashboardUploads.ResultsList.item": RecordsResultsListItem,
"InvenioAppRdm.DashboardUploads.ResultsList.item": RecordResultsListItemDashboard,
"InvenioAppRdm.Deposit.AccessRightField.container": AccessRightField,
"InvenioAppRdm.Deposit.CreatorsField.container": CreatibutorsField,
"InvenioAppRdm.Deposit.ContributorsField.container": CreatibutorsField,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* This file is part of Knowledge Commons Works.
* Copyright (C) 2024 Mesh Research.
*
* Knowledge Commons Works is based on InvenioRDM, and
* this file is based on code from InvenioRDM. InvenioRDM is
* Copyright (C) 2020-2024 CERN.
* Copyright (C) 2020-2024 Northwestern University.
* Copyright (C) 2020-2024 T U Wien.
*
* InvenioRDM and Knowledge Commons Works are both free software;
* you can redistribute and/or modify them under the terms of the
* MIT License; see LICENSE file for more details.
*
* FIXME: This should be merged with RecordsResultsListItem.js
*/

import React from "react";
import { ComputerTabletUploadsItem } from "../user_dashboard/uploads_items/ComputerTabletUploadsItem";
import _get from "lodash/get";
import { i18next } from "@translations/invenio_app_rdm/i18next";
import { http } from "react-invenio-forms";
import PropTypes from "prop-types";

const statuses = {
in_review: { color: "warning", title: i18next.t("In review") },
declined: { color: "negative", title: i18next.t("Declined") },
expired: { color: "expired", title: i18next.t("Expired") },
draft_with_review: { color: "neutral", title: i18next.t("Draft") },
draft: { color: "neutral", title: i18next.t("Draft") },
new_version_draft: { color: "neutral", title: i18next.t("New version draft") },
published: { color: "positive", title: i18next.t("Published") },
};

const RecordResultsListItemDashboard = ({ currentQueryState, result, key, appName }) => {
console.log(currentQueryState);
console.log("appName", appName);
const editRecord = () => {
http
.post(
`/api/records/${result.id}/draft`,
{},
{
headers: {
"Content-Type": "application/json",
"Accept": "application/vnd.inveniordm.v1+json",
},
}
)
.then(() => {
window.location = `/uploads/${result.id}`;
})
.catch((error) => {
console.error(error.response.data);
});
};

const filters = currentQueryState && Object.fromEntries(currentQueryState.filters);
const isPublished = result.is_published;
const access = {
accessStatusId: _get(result, "ui.access_status.id", i18next.t("open")),
accessStatus: _get(result, "ui.access_status.title_l10n", i18next.t("Open")),
accessStatusIcon: _get(result, "ui.access_status.icon", i18next.t("unlock")),
};
const versions = _get(result, "versions");
const uiMetadata = {
descriptionStripped: _get(
result,
"ui.description_stripped",
i18next.t("No description")
),
title: _get(result, "metadata.title", i18next.t("No title")),
creators: _get(result, "ui.creators.creators", []).slice(0, 3),
subjects: _get(result, "ui.subjects", []),
publicationDate: _get(
result,
"ui.publication_date_l10n_long",
i18next.t("No publication date found.")
),
resourceType: _get(
result,
"ui.resource_type.title_l10n",
i18next.t("No resource type")
),
createdDate: result.ui?.created_date_l10n_long,
version: result.ui?.version ?? "",
versions: versions,
isPublished: isPublished,
viewLink: isPublished ? `/records/${result.id}` : `/records/${result.id}?preview=1`,
publishingInformation: _get(result, "ui.publishing_information.journal", ""),
allVersionsVisible: filters?.allversions,
numOtherVersions: versions.index - 1,
};


return (
<ComputerTabletUploadsItem
result={result}
editRecord={editRecord}
statuses={statuses}
access={access}
uiMetadata={uiMetadata}
/>
);
};

RecordResultsListItemDashboard.propTypes = {
result: PropTypes.object.isRequired,
};

export { RecordResultsListItemDashboard };
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* This file is part of Knowledge Commons Works.
* Copyright (C) 2024 Mesh Research.
*
* Knowledge Commons Works is based on InvenioRDM, and
* this file is based on code from InvenioRDM. InvenioRDM is
* Copyright (C) 2020-2024 CERN.
* Copyright (C) 2020-2024 Northwestern University.
* Copyright (C) 2020-2024 T U Wien.
*
* InvenioRDM and Knowledge Commons Works are both free software;
* you can redistribute and/or modify them under the terms of the
* MIT License; see LICENSE file for more details.
*/

import { i18next } from "@translations/invenio_app_rdm/i18next";
import React from "react";
import PropTypes from "prop-types";
import _truncate from "lodash/truncate";
import _get from "lodash/get";
import { Button, Grid, Icon, Item, Label } from "semantic-ui-react";
import { SearchItemCreators } from "@js/invenio_app_rdm/utils";
import { CompactStats } from "../../search/records_list_item_components/CompactStats";
import { DisplayPartOfCommunities } from "../../search/records_list_item_components/DisplayPartOfCommunities";

const ComputerTabletUploadsItem = ({
result,
editRecord,
statuses,
access,
uiMetadata,
}) => {
const { accessStatusId, accessStatus, accessStatusIcon } = access;
const {
descriptionStripped,
title,
creators,
subjects,
publicationDate,
resourceType,
createdDate,
version,
versions,
isPublished,
viewLink,
publishingInformation,
filters,
allVersionsVisible,
numOtherVersions,
} = uiMetadata;

const icon = isPublished ? (
<Icon name="check" className="positive" />
) : (
<Icon name="upload" className="negative" />
);
const uniqueViews = _get(result, "stats.all_versions.unique_views", 0);
const uniqueDownloads = _get(result, "stats.all_versions.unique_downloads", 0);

return (
<Item key={result.id} className="search-result flex">
{/* <div className="status-icon mr-10">
<Item.Content verticalAlign="top">
<div className="status-icon mt-5">{icon}</div>
</Item.Content>
</div> */}
<Item.Content>
{/* FIXME: Uncomment to enable themed banner */}
{/* <DisplayVerifiedCommunity communities={result.parent?.communities} /> */}
<Item.Extra className="labels-actions">
{result.status in statuses && (
<Label horizontal size="small" icon={icon} className={statuses[result.status].color}>
{statuses[result.status].title}
</Label>
)}
<span className="status-icon ml-5 mt-5">
{icon}
</span>
<Button
compact
size="small"
floated="right"
onClick={() => editRecord()}
labelPosition="left"
icon="edit"
content={i18next.t("Edit")}
/>
</Item.Extra>
<Item.Header as="h2">
<a href={viewLink}>{title}</a>
</Item.Header>
<Item className="creatibutors">
<Icon name={`${creators.length === 1 ? "user" : "users"}`} /> <SearchItemCreators creators={creators} othersLink={viewLink} />
</Item>
<Item.Description>
{_truncate(descriptionStripped, { length: 350 })}
</Item.Description>
<Item.Extra className="item-footer ui grid">
<Grid.Column mobile={16} tablet={11} computer={11} className="item-footer-left">
{subjects.map((subject) => (
<Label key={subject.title_l10n} size="tiny">
{subject.title_l10n}
</Label>
))}
<p>
<Label horizontal size="small" className="">
{publicationDate} ({version})
</Label>
<Label horizontal size="small" className="">
{resourceType}
</Label>
<Label
horizontal
size="small"
className={`basic access-status ${accessStatusId}`}
>
{accessStatusIcon && <Icon name={accessStatusIcon} />}
{accessStatus}
</Label>
{/* {createdDate && publishingInformation && " | "} */}
</p>

{publishingInformation && (
<p>
{i18next.t("Published in: {{publishInfo}}", {
publishInfo: publishingInformation,
})}
</p>
)}

{!allVersionsVisible && versions.index > 1 && (
<p>
<b>
{i18next.t("{{count}} more versions exist for this record", {
count: numOtherVersions,
})}
</b>
</p>
)}

<DisplayPartOfCommunities communities={result.parent?.communities} />
</Grid.Column>

<Grid.Column mobile={16} tablet={5} computer={5} className="item-footer-right">
<small>
<CompactStats
uniqueViews={uniqueViews}
uniqueDownloads={uniqueDownloads}
/>
</small>
{createdDate && (
<small className="created-date">
{i18next.t("Uploaded on {{uploadDate}}", {
uploadDate: createdDate,
})}
</small>
)}
</Grid.Column>
</Item.Extra>
</Item.Content>
</Item>
);
};

ComputerTabletUploadsItem.propTypes = {
result: PropTypes.object.isRequired,
editRecord: PropTypes.func.isRequired,
statuses: PropTypes.object.isRequired,
access: PropTypes.object.isRequired,
uiMetadata: PropTypes.object.isRequired,
};

export { ComputerTabletUploadsItem };
4 changes: 4 additions & 0 deletions docker/nginx_production/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx:1.19.0-alpine

COPY ./conf.d /etc/nginx/conf.d
COPY ./uwsgi_params /etc/nginx/uwsgi_params
Loading

0 comments on commit c4939d1

Please sign in to comment.