Disable Wagtail "copy" functionality - wagtail

Is it possible to disable the copy functionality provided in Wagtail?
My team has some logic for a custom page type that is having some issues. We'd like to prevent people from using the copy functionality for a short period of time while we figure out what's going on, and how to fix it.

You could use the before_copy_page hook, e.g. to redirect editors to the listings page with a notification explaining that copying has been temporarily disabled:
https://docs.wagtail.io/en/v2.5/reference/hooks.html#before-copy-page

Related

Admin-on-rest: how to decrease button spacing and how to edit page without ID in url

I started with admin-on-rest recently and I love what it brings. However, I am stuck on 2 issues and I was hoping to get some help:
Question 1
I created a custom theme with custom color pallette etcetera. How can I reduce the spacing around buttons? You can see it on the demo here: https://marmelab.com/admin-on-rest-demo/#/customers/121, the save button has an indent of maybe 20-30 pixels. Can I remove this and align the button with the input fields, title, etcetera?
Question 2
What is the best approach for creating an /#/user/details/ view for example, where users can edit their own account details, re-using the EDIT component? I have now added this resource:
<Resource name="user/details" edit={EditDetails} />
I can edit the account by going to /#/user/details/ID (replacing ID with the actual user ID). But I don't want to expose the ID. Better yet, the SPA doesn't need to know about the ID at all, because the API can understand a PUT request to /user/details/ as a request to update the current user details. So I don't actually need the SPA to send or need this ID. Any ideas on this?
Question 1: https://marmelab.com/admin-on-rest/Theming.html#overriding-a-component-style
Customizing the Toolbar which contain the button will require a bit a of work in versions 1.*.*. You'll have to create a custom Toolbar using the original as a starting point (https://github.com/marmelab/admin-on-rest/blob/master/src/mui/form/Toolbar.js) and use it as the toolbar prop for your form (https://marmelab.com/admin-on-rest/CreateEdit.html#toolbar). This will be a lot easier in v2.
Question 2: this can be achieved using a custom restClient. In a nutshell, intercept calls which target the user resource and build the url yourself, not forgetting to handle the response.
However, for such a thing, I would advise against using the admin-on-rest mechanisms as it seems users are not really a resource but an application concept. As such you might want to handle this in a custom page with fetch by yourself.

Delay in Salesforce sites changes

I'm playing with Salesforce's "Sites" functionality today for the first time, whereby I can expose Salesforce functionality to anonymous users via VisualForce. It's cool, but I'm seeing some weird timing behavior. I've been trying to figure it out, but it's a mystery, so I'll ask here?
When I save my changes to my VisualForce page, I would expect to see the changes right away. Or at least, when I do a "real" save (by hitting "Save"), versus a "Quick Save," which I assume is what happens when I'm using the developer toolbar to edit -- or actually hitting the "Quick Save" button in the main VisualForce section.
At any rate, I save it as much as I possibly can, and I'm able to see the right thing when I go to the VisualForce page itself (not using the force.com URL). But when I go to the force.com URL, I'm seeing an old version of a page. If it's just a matter of waiting long enough, that's one thing. But it's acting like I'm doing something wrong.
During development, it is very helpful to add a cache="false" parameter to the apex:page tag. This should solve the issue.
Reference page for apex:page has other optional parameters as well.

Salesforce: Adding items to 'Personal Setup' and 'Customize'

I am writing a simple salesforce app that requires app-level and user-level configuration. I have created custom objects for these settings, but cannot figure out how to add links to the Setup page (Personal Setup and Customize) so that the settings can be managed.
Quite a lot of research, and a question on a salesforce board, have left me none the wiser. I have seen a couple of scripts on the web that hack the setup sidebar with javascript (eg http://userscripts.org/scripts/show/95361) ... but this can't be the right way to do it surely?
Thanks
Jim
You are unable to do this without hacking because Salesforce want it so that you don't require over-explicit setup of any app you create - they want you to make it data-independent and in fact it may fail a security review if it is data dependent. It will also likely cause you headaches in correctly unit testing the app.
My suggestion would be to have a set of custom pages which are linked to on the home page for a user which display if they have no current values (so the first thing they see on the home page when they login for the first time is a "Hey, before you use this app you need to do some configuration through this handy wizard" and then block access to other areas of the app (i.e. display warning messages on other pages) if the app has not had this data setup.
That way you are not hacking and are providing a nice user experience around the extra setup.
Paul
DO you just want to add a new TAB on the top menu that links to the Edit page for your new sObject?
If so:
Goto setup https://cs3.salesforce.com/ui/setup/Setup
Click on 'Create' > 'Tab'
Pick the sObject you want the tab edit, the click next until you save the new tab.
There is no supported way to augment the Setup menu.
You should probably be using Custom Settings for what you are describing - they were designed for app-level and user-level configuration, and are available from Setup.
Otherwise, if it really is custom setup that requires fancier logic / UI / etc, you may want to do what many SFDC ISV's do and ship your app with its own configuration tab that's hidden, and/or custom VF page that manages app settings.

Liferay Change theme for mobile device

I need to change the theme (let's say default theme = classic) to the iphone theme (or whatever) when the user has navigated to the liferay portal using a mobile device.
I thought to go about it like this:
- create a hook to gets triggered on a user login event
- check for the device using the User-Agent request header attribute
- if required, set the theme to iphone using LayoutServiceUtil
Probably there is a better approach to implement such a requirement so feel free to offer alternatives.
I'm quite new to liferay so that is probably the reason I could not get this to work.
a. First of all I'm very confused about how themes are handled in liferay; there seem to be various related model objects which are hard to distinguish: Theme, ThemeDisplay, Layout, LayoutSet, ColorScheme, ... . Can someone explain this or know where this is explained?
b. apparently you need to get the ThemeDisplay from the request in order to set a theme on it. However, when the user logs in, the theme attribute (THEME_DISPLAY) has not been set yet (neither in the pre nor post event; it is set when I check during a logout event). Setting the theme during login is an absolute minimum, I was actually hoping I could set the theme before the user logs in but since the attribute is not even known after user logs in...
c. when using LayoutServiceUtil.updateLookAndFeel, you need to give the groupId, themeId, colorSchemeId, css, ... . I was expecting it would be simply telling liferay which theme (name) to use no matter what groupId, ... . Is this not possible?
thanks a lot for any help,
Stijn
P.S. I'm using liferay 6.0.5.
I haven't tried this myself but I'm planning on looking into it:
Milen Dyankov's extensions seem to have a way of letting you select themes based on the user agent all configured in the control panel. You can read his blog about it here.
I could be mistaken but I'm pretty sure the switching happens automatically.
Question a: are you developing your own theme or do you just want to customize it?
Question b: why not set the default themes correctly? Just set it in the settings pannel => layout => dropdown at the bottom
Edit:
I would be wary of using a login.pre hook. While this will update it when you login it means that untill the user actually logs in they may see the wrong theme. I would check it in the default render mode of a portlet on the main page or find a hook that is used on first visiting the page.
A possibility seems to be: servlet.service.events.pre
That way it will be checked every http request. There may be better options. (I am not that familiar with liferay)
And to get the groupId etc you can just use: long groupId = ParamUtil.getLong(actionRequest, "groupId");

How can I disable the Publish button in EPiServer's content editor?

I have an EPiServer project which is using the sequential workflow to validate content changes. This works fine, however we have a slight issue where content reviewers are just clicking Publish when they are happy with an editor's work. What they should be doing is using the workflow task window and indicating their approval through that.
To enforce this behaviour I would like to disable the Publish button in the content editor under certain circumstances (i.e. when there is an outstanding workflow task linked to the current page).
Does anyone have any ideas how I can do this, or even an alternative solution to the problem altogether?
Actually, I think you may want to revisit your workflow logic.
If a user with publishing rights publishes a page: that should be considered an approval. You could easily hook up to the Published event to see if the page is part of a currently running workflow.

Resources