Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into int
Browse files Browse the repository at this point in the history
  • Loading branch information
finlay-jisc committed Oct 6, 2023
2 parents 6a1825a + 221943c commit d4186d1
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 99 deletions.
199 changes: 102 additions & 97 deletions ui/src/components/Publication/SidebarCard/Actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,112 +144,117 @@ const Actions: React.FC<ActionProps> = (props): React.ReactElement => {
</>
</Components.Modal>

<Components.SectioBreak name="Actions" />

{/** Download options */}
{props.publication.currentStatus === 'LIVE' && (
<div className="flex">
<span className="mr-2 text-sm font-semibold text-grey-800 transition-colors duration-500 dark:text-grey-50">
Download:
</span>
<button
aria-label="Print"
onClick={() => {
window.open(
`${Config.endpoints.publications}/${props.publication.id}/pdf?redirectToPreview=true`,
'_blank'
);
}}
className="mr-4 flex items-center rounded border-transparent text-right text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Image src="/images/pdf.svg" alt="PDF Icon" width={18} height={18} />
<span className="ml-1">pdf</span>
</button>
<button
aria-label="Download JSON"
onClick={() =>
Helpers.blobFileDownload(
`${Config.endpoints.publications}/${props.publication.id}`,
`${props.publication.id}.json`
)
}
className="mr-4 flex items-center rounded border-transparent text-right text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Image src="/images/json.svg" alt="PDF Icon" width={18} height={18} />
<span className="ml-1">json</span>
</button>
</div>
)}
{user && user.email ? (
<>
{/* if the publication is a peer review, no options shall be given to write a linked publication */}
{props.publication.type !== 'PEER_REVIEW' && (
<>
{Helpers.linkedPublicationTypes[
props.publication.type as keyof typeof Helpers.linkedPublicationTypes
].map((item: any) => {
return (
<Components.PublicationSidebarCardActionsButton
label={`Write a linked ${Helpers.formatPublicationType(item)}`}
key={item}
onClick={() => {
router.push({
pathname: `${Config.urls.createPublication.path}`,
query: {
for: props.publication.id,
type: item
}
});
}}
/>
<Components.SectionBreak name="Actions" />
{/** Download options */}
<div className="flex">
<span className="mr-2 text-sm font-semibold text-grey-800 transition-colors duration-500 dark:text-grey-50">
Download:
</span>
<button
aria-label="Print"
onClick={() => {
window.open(
`${Config.endpoints.publications}/${props.publication.id}/pdf?redirectToPreview=true`,
'_blank'
);
})}
{props.publication.user.id !== user.id && (
}}
className="mr-4 flex items-center rounded border-transparent text-right text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Image src="/images/pdf.svg" alt="PDF Icon" width={18} height={18} />
<span className="ml-1">pdf</span>
</button>
<button
aria-label="Download JSON"
onClick={() =>
Helpers.blobFileDownload(
`${Config.endpoints.publications}/${props.publication.id}`,
`${props.publication.id}.json`
)
}
className="mr-4 flex items-center rounded border-transparent text-right text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Image src="/images/json.svg" alt="PDF Icon" width={18} height={18} />
<span className="ml-1">json</span>
</button>
</div>
{user && user.email ? (
<>
{/* if the publication is a peer review, no options shall be given to write a linked publication */}
{props.publication.type !== 'PEER_REVIEW' && (
<>
<Components.PublicationSidebarCardActionsButton
label="Write a review"
onClick={() => {
router.push({
pathname: `${Config.urls.createPublication.path}`,
query: {
for: props.publication.id,
type: 'PEER_REVIEW'
}
});
}}
/>
<Components.PublicationSidebarCardActionsButton
label="Flag a concern with this publication"
onClick={() => setShowRedFlagModel(true)}
/>
{Helpers.linkedPublicationTypes[
props.publication.type as keyof typeof Helpers.linkedPublicationTypes
].map((item: any) => {
return (
<Components.PublicationSidebarCardActionsButton
label={`Write a linked ${Helpers.formatPublicationType(item)}`}
key={item}
onClick={() => {
router.push({
pathname: `${Config.urls.createPublication.path}`,
query: {
for: props.publication.id,
type: item
}
});
}}
/>
);
})}
{props.publication.user.id !== user.id && (
<>
<Components.PublicationSidebarCardActionsButton
label="Write a review"
onClick={() => {
router.push({
pathname: `${Config.urls.createPublication.path}`,
query: {
for: props.publication.id,
type: 'PEER_REVIEW'
}
});
}}
/>
<Components.PublicationSidebarCardActionsButton
label="Flag a concern with this publication"
onClick={() => setShowRedFlagModel(true)}
/>
</>
)}
</>
)}
</>
) : user && !user.email ? (
<>
<Components.Link
href={`${Config.urls.verify.path}?state=${encodeURIComponent(
`${Config.urls.viewPublication.path}/${props.publication.id}`
)}`}
className="flex items-center rounded border-transparent text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
Verify your email for more actions
</Components.Link>
</>
) : (
<>
<Components.Link
href={`${Config.urls.orcidLogin.path}&state=${encodeURIComponent(
`${Config.urls.viewPublication.path}/${props.publication.id}`
)}`}
className="flex items-center rounded border-transparent text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Assets.ORCID
width={25}
height={25}
className="mr-2 rounded-md bg-orcid fill-white-50 p-1"
/>
<span> Sign in for more actions</span>
</Components.Link>
</>
)}
</>
) : user && !user.email ? (
<>
<Components.Link
href={`${Config.urls.verify.path}?state=${encodeURIComponent(
`${Config.urls.viewPublication.path}/${props.publication.id}`
)}`}
className="flex items-center rounded border-transparent text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
Verify your email for more actions
</Components.Link>
</>
) : (
<>
<Components.Link
href={`${Config.urls.orcidLogin.path}&state=${encodeURIComponent(
`${Config.urls.viewPublication.path}/${props.publication.id}`
)}`}
className="flex items-center rounded border-transparent text-sm font-medium text-teal-600 outline-0 transition-colors duration-500 hover:underline focus:overflow-hidden focus:ring-2 focus:ring-yellow-400 dark:text-teal-400"
>
<Assets.ORCID width={25} height={25} className="mr-2 rounded-md bg-orcid fill-white-50 p-1" />
<span> Sign in for more actions</span>
</Components.Link>
</>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Props = {

const Sections: React.FC<Props> = (props): React.ReactElement => (
<>
<Components.SectioBreak name="Sections" />
<Components.SectionBreak name="Sections" />
{!!props.sectionList && (
<div className="space-y-2">
{props.sectionList.map((section) => (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export { default as ScrollToTop } from './ScrollToTop';
export { default as Search } from './SearchToggle';
export { default as SearchDesktop } from './SearchToggle/Desktop';
export { default as SearchMobile } from './SearchToggle/Mobile';
export { default as SectioBreak } from './SectionBreak';
export { default as SectionBreak } from './SectionBreak';
export { default as SurveyWidget } from './SurveyWidget';
export { default as Tabs } from './Tabs';
export { default as TextEditor } from './TextEditor';
Expand Down

0 comments on commit d4186d1

Please sign in to comment.