feat: support resubmitting published library items (#5174)

This commit is contained in:
David Luzar 2022-05-11 15:56:11 +02:00 committed by GitHub
parent d2cc76e52e
commit b27ac257e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 8 deletions

View File

@ -172,7 +172,7 @@ const LibraryMenuItems = ({
</ToolButton> </ToolButton>
</> </>
)} )}
{itemsSelected && !isPublished && ( {itemsSelected && (
<Tooltip label={t("hints.publishLibrary")}> <Tooltip label={t("hints.publishLibrary")}>
<ToolButton <ToolButton
type="button" type="button"
@ -199,9 +199,6 @@ const LibraryMenuItems = ({
const referrer = const referrer =
libraryReturnUrl || window.location.origin + window.location.pathname; libraryReturnUrl || window.location.origin + window.location.pathname;
const isPublished = selectedItems.some(
(id) => libraryItems.find((item) => item.id === id)?.status === "published",
);
const [lastSelectedItem, setLastSelectedItem] = useState< const [lastSelectedItem, setLastSelectedItem] = useState<
LibraryItem["id"] | null LibraryItem["id"] | null

View File

@ -82,6 +82,10 @@
} }
} }
&-warning {
color: $oc-red-6;
}
&-note { &-note {
padding: 1em; padding: 1em;
font-style: italic; font-style: italic;

View File

@ -295,6 +295,11 @@ const PublishLibrary = ({
}, [clonedLibItems, onClose, updateItemsInStorage, libraryData]); }, [clonedLibItems, onClose, updateItemsInStorage, libraryData]);
const shouldRenderForm = !!libraryItems.length; const shouldRenderForm = !!libraryItems.length;
const containsPublishedItems = libraryItems.some(
(item) => item.status === "published",
);
return ( return (
<Dialog <Dialog
onCloseRequest={onDialogClose} onCloseRequest={onDialogClose}
@ -329,6 +334,11 @@ const PublishLibrary = ({
<div className="publish-library-note"> <div className="publish-library-note">
{t("publishDialog.noteItems")} {t("publishDialog.noteItems")}
</div> </div>
{containsPublishedItems && (
<span className="publish-library-note publish-library-warning">
{t("publishDialog.republishWarning")}
</span>
)}
{renderLibraryItems()} {renderLibraryItems()}
<div className="publish-library__fields"> <div className="publish-library__fields">
<label> <label>

View File

@ -3,11 +3,24 @@
.excalidraw { .excalidraw {
.single-library-item { .single-library-item {
position: relative; position: relative;
&-status {
position: absolute;
top: 0.3rem;
left: 0.3rem;
font-size: 0.7rem;
color: $oc-red-7;
background: rgba(255, 255, 255, 0.9);
padding: 0.1rem 0.2rem;
border-radius: 0.2rem;
}
&__svg { &__svg {
background-color: $oc-white;
padding: 0.3rem;
width: 7.5rem; width: 7.5rem;
height: 7.5rem; height: 7.5rem;
border: 1px solid var(--button-gray-2); border: 1px solid var(--button-gray-2);
margin: 0.3rem;
svg { svg {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -40,7 +53,7 @@
&--remove { &--remove {
position: absolute; position: absolute;
top: 0.2rem; top: 0.2rem;
right: 1.3rem; right: 1rem;
.ToolIcon__icon { .ToolIcon__icon {
margin: 0; margin: 0;

View File

@ -45,6 +45,11 @@ const SingleLibraryItem = ({
return ( return (
<div className="single-library-item"> <div className="single-library-item">
{libItem.status === "published" && (
<span className="single-library-item-status">
{t("labels.statusPublished")}
</span>
)}
<div ref={svgRef} className="single-library-item__svg" /> <div ref={svgRef} className="single-library-item__svg" />
<ToolButton <ToolButton
aria-label={t("buttons.remove")} aria-label={t("buttons.remove")}

View File

@ -119,7 +119,8 @@
"unlock": "Unlock", "unlock": "Unlock",
"lockAll": "Lock all", "lockAll": "Lock all",
"unlockAll": "Unlock all" "unlockAll": "Unlock all"
} },
"statusPublished": "Published"
}, },
"buttons": { "buttons": {
"clearReset": "Reset the canvas", "clearReset": "Reset the canvas",
@ -341,7 +342,8 @@
"post": "which in short means anyone can use them without restrictions." "post": "which in short means anyone can use them without restrictions."
}, },
"noteItems": "Each library item must have its own name so it's filterable. The following library items will be included:", "noteItems": "Each library item must have its own name so it's filterable. The following library items will be included:",
"atleastOneLibItem": "Please select at least one library item to get started" "atleastOneLibItem": "Please select at least one library item to get started",
"republishWarning": "Note: some of the selected items are marked as already published/submitted. You should only resubmit items when updating an existing library or submission."
}, },
"publishSuccessDialog": { "publishSuccessDialog": {
"title": "Library submitted", "title": "Library submitted",