-
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.
Merge remote-tracking branch 'origin/corovcam/fe-116-display-requests…
…-on-record-page' into corovcam/fe-116-display-requests-on-record-page
- Loading branch information
Showing
8 changed files
with
92 additions
and
72 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
43 changes: 43 additions & 0 deletions
43
...ets/semantic-ui/js/oarepo_requests_ui/record-requests/components/ModalContentSideInfo.jsx
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,43 @@ | ||
import React from "react"; | ||
|
||
import { i18next } from "@translations/oarepo_requests_ui/i18next"; | ||
import { List } from "semantic-ui-react"; | ||
import _isEmpty from "lodash/isEmpty"; | ||
import _sortBy from "lodash/sortBy"; | ||
|
||
/** | ||
* @typedef {import("../types").Request} Request | ||
* @typedef {import("../types").RequestType} RequestType | ||
*/ | ||
|
||
/** @param {{ request: Request, requestType: RequestType, isSidebar: boolean }} props */ | ||
export const ModalContentSideInfo = ({ request, requestType, isSidebar = false }) => { | ||
return ( | ||
<List divided={isSidebar} relaxed={isSidebar}> | ||
<List.Item> | ||
<List.Content> | ||
<List.Header>{i18next.t("Creator")}</List.Header> | ||
{request.created_by?.link && <a href={request.created_by.link}>{request.created_by.label}</a> || request.created_by?.label} | ||
</List.Content> | ||
</List.Item> | ||
<List.Item> | ||
<List.Content> | ||
<List.Header>{i18next.t("Receiver")}</List.Header> | ||
{request.receiver?.link && <a href={request.receiver?.link}>{request.receiver?.label}</a> || request.receiver?.label} | ||
</List.Content> | ||
</List.Item> | ||
<List.Item> | ||
<List.Content> | ||
<List.Header>{i18next.t("Request type")}</List.Header> | ||
{requestType.name} | ||
</List.Content> | ||
</List.Item> | ||
<List.Item> | ||
<List.Content> | ||
<List.Header>{i18next.t("Created")}</List.Header> | ||
{`${Math.ceil(Math.abs(new Date(request?.created) - new Date()) / 3.6e6)} hours ago`} | ||
</List.Content> | ||
</List.Item> | ||
</List> | ||
) | ||
}; |
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
18 changes: 18 additions & 0 deletions
18
...ts/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/record-requests/utils/isDeepEmpty.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,18 @@ | ||
import _isEmpty from "lodash/isEmpty"; | ||
|
||
export default function isDeepEmpty(input) { | ||
if(_isEmpty(input)) { | ||
return true; | ||
} | ||
if(typeof input === 'object') { | ||
for(const item of Object.values(input)) { | ||
// if item is not undefined and is a primitive, return false | ||
// otherwise dig deeper | ||
if((item !== undefined && typeof item !== 'object') || !isDeepEmpty(item)) { | ||
return false | ||
} | ||
} | ||
return true; | ||
} | ||
return _isEmpty(input); | ||
} |