-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implemented CMS entry copy features #130
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
@@ -39,6 +39,10 @@ import { isEqual, isNil, mapValues, pickBy } from "lodash"; | |||
import * as React from "react"; | |||
import { Prompt, Route, useHistory, useRouteMatch } from "react-router"; | |||
import { useBeforeUnload, useInterval } from "react-use"; | |||
import { Modal } from "../widgets/Modal"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you set up the pre-commit? It would have automatically formatted imports like this to @/wab/client/widgets/...
<Menu.Item | ||
key="copy" | ||
onClick={() => { | ||
if (row.identifier && row.identifier !== "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this if condition to if (row.identifier)
hasUnpublishedChanges | ||
? "Creates a copy with draft data" | ||
: "Creates an unpublished copy with the published data" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we will be showing a modal, I think we can explain how the operation works in the modal instead of in a tooltip which is less discoverable. So you can remove this tooltip.
content: "Copying...", | ||
duration: 1, | ||
}) | ||
await mutateRow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this mutateRow
for?
<Button | ||
type="primary" | ||
onClick={async () => { | ||
setShowCopyModal(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the modal should stay open until the copyCmsRow
call finishes. While the network request is still processing, disable the form/button. When the network request finishes, show the success notification and redirect to the new CMS entry's URL.
const opts = { | ||
identifier: identifier, | ||
data: null, | ||
draftData: row.draftData ? row.draftData : row.data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified to row.draftData || row.data
// If the original row is being published or had been published before, | ||
// make the copy unpublished or remove the recent published history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this comment makes sense, can you remove or edit it?
if (!this.isUserIdSelf(comment.createdById ?? undefined)) { | ||
if ("body" in data) { | ||
throw new ForbiddenError("Can only do this for self."); | ||
} | ||
await this.checkProjectPerms( | ||
comment.projectId, | ||
"content", | ||
"resolve a comment", | ||
true | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a bad merge
@@ -1724,6 +1724,16 @@ export abstract class SharedApi { | |||
return (await this.put(`/cmse/rows/${rowId}`, opts)) as ApiCmseRow; | |||
} | |||
|
|||
async copyCmsRow(rowId: CmsRowId, copyRowIdentifier: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would copy the updateCmsRow
and use an opts: { identifier: string }
argument instead. That way, it's easier to read what the argument is, since the called is required to write identifier: <something>
. Also, it's easier to add new arguments in the future.
You would also be able to skip the if check below and just pass in opts
directly to post
.
platform/live-frame/yarn.lock
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should not have changed any yarn.lock files. Please revert those.
// runs every 10 minutes | ||
cron.schedule("*/10 * * * *", async () => { | ||
await sendCommentsNotificationEmails(config); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, some bad merge
removed copy API inside addCmsPublicRoutes removed copy API inside addCmsPublicRoutes 'Set title' warning when asked to copy an entry without identifier modal after copy menu clicked, input for new title API connected, front-back, now user input title is used for the new entry removed warning when no identifier prompt default value changed, back api identifier type fixed to the right value(null) new copy is selected after created input selection code removed removed unnecessary comments Modal import fix Changes after code review, for <Menu.Item> button clicked and disabled, success message after network request, small changes in DbMgr.ts copyCmsRow parameter wrapped in 'opts' object backend server - request parameter changes revert yarn.lock file changes revert platform/live-frame/yarn.lock file changes Modal content, message content changed
> | ||
<span>Copy entry</span> | ||
</Menu.Item> | ||
<Menu.Divider /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove divider
Co-authored-by: Jason Long <j@jaslong.com>
This was merged in 7e86bbf Thank you! |
Created 'Copy Entry' menu item.
When a user �mouses over 'Copy Entry',
When a user clicks 'Copy Entry', they see a prompt that asks for the new copy's title.
The default value of the input is
They can copy without a title.
When a user clicks 'Copy' in a prompt, prompt disappears and they see a message 'Copying...',
and after copy is completed, they see a message 'Copied'.
As the message disappears, the new copy is selected in the entry list.