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

Am/paste async button #611

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions castle/cms/browser/content/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@
layer="castle.cms.interfaces.ICastleLayer"
/>

<browser:page
for="Products.CMFCore.interfaces._content.IFolderish"
name="fc-paste-async"
class=".fc.PasteAsyncActionView"
permission="cmf.ListFolderContents"
/>

<utility component=".fc.PasteAsyncAction"
provides="plone.app.content.interfaces.IStructureAction"
name="paste-async" />

<browser:page
for="Products.CMFCore.interfaces._content.IFolderish"
name="fc-cut"
Expand Down
47 changes: 47 additions & 0 deletions castle/cms/browser/content/fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from OFS.CopySupport import CopyError
from OFS.Moniker import Moniker
from plone import api
from plone.app.content.browser import actions
from plone.app.content.browser.contents import FolderContentsView as BaseFolderContentsView
from plone.app.content.browser.contents import copy
from plone.app.content.browser.contents import cut
Expand Down Expand Up @@ -156,6 +157,52 @@ def __call__(self):
return super(PasteActionView, self).__call__()


@implementer(IStructureAction)
class PasteAsyncAction(paste.PasteActionView):
template = ViewPageTemplateFile('templates/fc-paste-async.pt')
order = 10

def __init__(self, context, request):
self.context = context
self.request = request

def get_options(self):
return {
'title': 'Paste Async',
'tooltip': 'Paste Asynchronously',
'id': 'paste-async',
'icon': 'paste',
'url': self.context.absolute_url() + '/@@fc-paste-async',
'form': {
'template': self.template(),
'submitText': 'Confirm',
'closeText': 'Cancel',
'title': 'Paste Async',
}
}


class PasteAsyncActionView(actions.ObjectPasteView):

def __call__(self):
try:
paste_data = get_paste_data(self.request)
except CopyError:
return self.copy_error()

tasks.paste_items.delay(
self.request.form['folder'], paste_data['op'],
paste_data['mdatas'])

return self.do_redirect(
self.canonical_object_url,
"""You have selected to paste %i items asynchronously.
This action can take a long time to accomplish. We will email you
when the content is done being moved.""" % paste_data['count'],
'error'
)


class DeleteActionView(delete.DeleteActionView):

delete_warning = """
Expand Down
4 changes: 4 additions & 0 deletions castle/cms/browser/content/templates/fc-paste-async.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>Asynchronous paste actions normally happen when a large number of items are copied.</p>
<p>These processes run in the background as they often take some time to complete.</p>
<p>Selecting this option will help process batches of documents or large documents that contain many tiles.</p>
<p>Would you like to continue?</p>
2 changes: 2 additions & 0 deletions castle/cms/static/patterns/structure/js/views/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ define([
self.pasteAllowed = !!$.cookie('__cp');
if (self.pasteAllowed) {
self.buttons.get('paste').enable();
self.buttons.get('paste-async').enable();
} else {
self.buttons.get('paste').disable();
self.buttons.get('paste-async').disable();
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion castle/cms/static/plone-logged-in-compiled.css.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion castle/cms/static/plone-logged-in-compiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -96827,8 +96827,10 @@ define('castle-url/patterns/structure/js/views/app',[
self.pasteAllowed = !!$.cookie('__cp');
if (self.pasteAllowed) {
self.buttons.get('paste').enable();
self.buttons.get('paste-async').enable();
} else {
self.buttons.get('paste').disable();
self.buttons.get('paste-async').disable();
}
}
},
Expand Down Expand Up @@ -100996,5 +100998,5 @@ require([
}
});

define("/Users/brian.duncan/fbigov-dev-repos/quality-check-backend-url-castle-only/castle/cms/static/plone-logged-in.js", function(){});
define("/opt/castle/src/castle.cms/castle/cms/static/plone-logged-in.js", function(){});

2 changes: 1 addition & 1 deletion castle/cms/static/plone-logged-in-compiled.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion castle/cms/static/plone-logged-in-compiled.min.js.map

Large diffs are not rendered by default.

Loading