Skip to content
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

Closed
wants to merge 7 commits into from

Conversation

hyunnbunt
Copy link
Contributor

Created 'Copy Entry' menu item.

When a user �mouses over 'Copy Entry',

  • when the entry is published, a tooltip appears with 'Creates an unpublished copy with the published data'.
  • when the entry is unpublished, a tooltip appears with 'Creates a copy with draft data'.

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

  • when the original entry has no title, ''.
  • when the original entry has a title, 'Copy of [title of original entry]'.
    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.

Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plasmic-cms-i18n ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2025 8:31am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
react-email-demo ⬜️ Ignored (Inspect) Jan 25, 2025 8:31am

@@ -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";
Copy link
Contributor

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 !== "") {
Copy link
Contributor

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)

Comment on lines 603 to 605
hasUnpublishedChanges
? "Creates a copy with draft data"
: "Creates an unpublished copy with the published data"
Copy link
Contributor

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();
Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

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

Comment on lines 7352 to 7353
// If the original row is being published or had been published before,
// make the copy unpublished or remove the recent published history.
Copy link
Contributor

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?

Comment on lines 9673 to 9686
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
);
}
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Comment on lines 2123 to 2127
// runs every 10 minutes
cron.schedule("*/10 * * * *", async () => {
await sendCommentsNotificationEmails(config);
});

Copy link
Contributor

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 />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove divider

@jaslong
Copy link
Contributor

jaslong commented Jan 29, 2025

This was merged in 7e86bbf

Thank you!

@jaslong jaslong closed this Jan 29, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2025
@hyunnbunt hyunnbunt deleted the impl-COPY branch February 1, 2025 07:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants