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

GPII-4489 Site Config Option to enable/disable capture tool. #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions siteconfig.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
// `true` if the button should be hidden and `false` otherwise.
hideQssSaveButton: false,

// Whether to hide the Capture Tool buttons.
// These "buttons" are actually currently right click menu items on the task tray.
hideCaptureToolButton: false,

// Configuration options for the QSS window
qss: {
// Whether a user can open Settings pages and Control Panels of the operating system
Expand Down
32 changes: 28 additions & 4 deletions src/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ fluid.defaults("gpii.app.menu", {
target: "showCaptureTool",
singleTransform: {
type: "fluid.transforms.free",
func: "gpii.app.menu.getSimpleMenuItem",
args: ["Capture Tool", "onCaptureTool"]
func: "gpii.app.menu.getOptionalMenuItem",
args: ["{siteConfigurationHandler}.options.siteConfig.hideCaptureToolButton", "Capture Tool", "onCaptureTool"]
},
forward: {
excludeSource: "init"
Expand All @@ -417,8 +417,8 @@ fluid.defaults("gpii.app.menu", {
target: "showCaptureDiagnostics",
singleTransform: {
type: "fluid.transforms.free",
func: "gpii.app.menu.getSimpleMenuItem",
args: ["Capture Tool Diagnostics", "onCaptureDiagnostics"]
func: "gpii.app.menu.getOptionalMenuItem",
args: ["{siteConfigurationHandler}.options.siteConfig.hideCaptureToolButton", "Capture Tool Diagnostics", "onCaptureDiagnostics"]
},
forward: {
excludeSource: "init"
Expand Down Expand Up @@ -563,6 +563,30 @@ gpii.app.menu.getSimpleMenuItem = function (label, event, payload) {
};
};

/**
* Generates an object that represents a selectable menu item. Similar to getSimpleMenuItem,
* but respects an initial boolean which could be a setting from the siteConfig determining
* whether to display this item or not.
* @param {Boolean} hideItem - If true, this menu item will not be displayed. (ie. this function
* will not return the usual menu structure).
* @param {String} label - The label of the item.
* @param {String} event - The event to be triggered on click.
* @param {Object} [payload] - The payload that is to be supplied with the on click event.
* @return {ElectronMenuItem} A simple selectable Electron menu item.
Copy link
Member

Choose a reason for hiding this comment

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

Declare that the return is optional - e.g. {ElectronMenuItem|Undefined}

*/
gpii.app.menu.getOptionalMenuItem = function (hideItem, label, event, payload) {
if (hideItem) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a religious fanatic, but single (and explicit) return-ism is slightly preferable - how about

return hideItem ? undefined : {
            label: label,
            click: event,
            args: payload || {}
        };

return;
}
else {
return {
label: label,
click: event,
args: payload || {}
};
}
};

/**
* Generates a simple Electron context menu separator item.
* @return {Object} The separator menu item.
Expand Down