Skip to content

Commit

Permalink
PAYARA-1663 Allow support view to be disabled (#1706)
Browse files Browse the repository at this point in the history
* PAYARA-1663 support view can now be disabled

* PAYARA-1663 support view can (dis)enabled from the admin console

* removed debug outputtext
  • Loading branch information
Cousjava authored and smillidge committed Jul 5, 2017
1 parent d65cabf commit 23b2f7b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2017] Payara Foundation and/or affiliates
-->

<!-- appServer/serverInstDomainAttrs.jsf -->
Expand All @@ -59,6 +60,11 @@
setPageSessionAttribute(key="appPropertyEndpoint" value="#{sessionScope.REST_URL}/system-applications/application/__admingui/property.json")
gf.restRequest(endpoint="#{pageSession.appPropertyEndpoint}" method="GET" result="#{requestScope.propList}");
setPageSessionAttribute(key="appPropList" value="#{requestScope.propList.data.extraProperties.properties}");

gf.restRequest(endpoint="#{sessionScope.REST_URL}/configs/config/server-config/zendesk-support-configuration/get-zendesk-support-configuration" method="GET" result="#{requestScope.zenresp}");
if (#{requestScope.zenresp.data.extraProperties.zendeskSupportConfiguration['enabled']}){
setPageSessionAttribute(key="zendeskenabled", value="true");
}
/>
</event>
<sun:form id="propertyForm">
Expand All @@ -75,6 +81,9 @@
//will be null if checkbox is unchecked.
setPageSessionAttribute(key="loadOnStartup" value="false");
}
if(!#{pageSession.zendeskenabled}){
setPageSessionAttribute(key="zendeskenabled" value="false");
}
setAttribute(key="found" value="false");
if('! #{pageSession.loadOnStartup}=#{pageSession.origLoadOnStartup}'){
foreach (var="oneProp" list="#{pageSession.appPropList}") {
Expand All @@ -92,6 +101,10 @@
javaToJSON(obj="#{pageSession.appPropList}" json="#{requestScope.tmpJSON}");
gf.restRequest(endpoint="#{pageSession.appPropertyEndpoint}", method="POST", data="#{requestScope.tmpJSON}");
}
createMap(result="#{pageSession.zenMap}")
mapPut(map="#{pageSession.zenMap}" key="enabled" value="#{pageSession.zendeskenabled}");
gf.updateEntity(endpoint="#{sessionScope.REST_URL}/configs/config/server-config/zendesk-support-configuration/set-zendesk-support-configuration"
attrs="#{pageSession.zenMap}");
prepareSuccessfulMsg();
gf.redirect(page="#{pageSession.selfPage}&alertType=${alertType}&alertSummary=${alertSummary}&alertDetail=${alertDetail}");
/>
Expand All @@ -117,7 +130,11 @@
}
}
/>
</sun:checkbox>
</sun:checkbox>
</sun:property>
<sun:property id="supportEnabled" labelAlign="left" noWrap="#{false}" overlapLabel="#{false}"
label="$resource{i18nc.domain.supportEnabled}" helpText="$resource{i18nc.domain.supportEnabledHelp}">
<sun:checkbox id="supportEnabled" label="$resource{i18n.common.Enabled}" selected="#{pageSession.zendeskenabled}" selectedValue="true" />
</sun:property>
<sun:property id="dummy" >
<sun:staticText id="dummy" text=" " />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2016] [Payara Foundation and/or its affiliates]
# Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates]

## 'server' is the name of the server instance. No Not Translate it.
tree.adminServer=server (Admin Server)
Expand Down Expand Up @@ -849,6 +849,8 @@ domain.loadOnStartupHelp=Load Admin Console after server startup. This may affe
domain.loadOnStartupDefault=Usage Based
domain.loadOnStartupAlways=Always
domain.loadOnStartupNever=Never
domain.supportEnabled=Support View
domain.supportEnabledHelp=Enable support page. The admin console must be reloaded in order to take effect.

configurations.PageTitle=Configurations
configurations.NewPageTitle=New Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
text="$resource{i18nhs.support.tree}"
url="/payara_support/support/support.jsf"
imageURL="/resource/images/support.png"
rendered="#{requestScope.enabled}"
>
<!beforeCreate
setResourceBundle(key="i18nhs" bundle="fish.payara.admingui.support.Strings");
gf.restRequest(endpoint="#{sessionScope.REST_URL}/configs/config/server-config/zendesk-support-configuration/get-zendesk-support-configuration" method="get" result="#{requestScope.resp}");
setAttribute(key="enabled" value="#{requestScope.resp.data.extraProperties.zendeskSupportConfiguration.enabled}");
/>
</sun:treeNode>
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ public void execute(AdminCommandContext acc) {

ActionReport actionReport = acc.getActionReport();

final String[] outputHeaders = {"Email Address"};
final String[] outputHeaders = {"Enabled" , "Email Address"};
ColumnFormatter columnFormatter = new ColumnFormatter(outputHeaders);
Object[] outputValues = {zendeskSupportConfiguration.getEmailAddress()};
Object[] outputValues = {zendeskSupportConfiguration.getEnabled(),zendeskSupportConfiguration.getEmailAddress()};
columnFormatter.addRow(outputValues);
actionReport.appendMessage(columnFormatter.toString());

Map<String, Object> extraPropsMap = new HashMap<>();
extraPropsMap.put("enabled", zendeskSupportConfiguration.getEnabled());
extraPropsMap.put("emailAddress", zendeskSupportConfiguration.getEmailAddress());

Properties extraProps = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
package fish.payara.appserver.zendesk.admin;

import com.google.common.base.Strings;
import com.sun.enterprise.config.serverbeans.Config;
import fish.payara.appserver.zendesk.ZendeskSupportService;
import fish.payara.appserver.zendesk.config.ZendeskSupportConfiguration;
Expand Down Expand Up @@ -78,11 +79,14 @@ public class SetZendeskSupportConfigurationCommand implements AdminCommand {
private Target targetUtil;

@Inject
ZendeskSupportService zendeskSupport;
private ZendeskSupportService zendeskSupport;

@Param(name = "emailAddress", alias = "emailaddress")
@Param(name = "emailAddress", alias = "emailaddress", optional = true)
private String emailAddress;

@Param(name="enabled", optional = true)
private Boolean enabled;

private final String target = "server-config";

@Override
Expand All @@ -98,7 +102,14 @@ public void execute(AdminCommandContext acc) {
ConfigSupport.apply(new SingleConfigCode<ZendeskSupportConfiguration>(){
@Override
public Object run(ZendeskSupportConfiguration config) {
config.setEmailAddress(emailAddress);

if(enabled != null) {
config.setEnabled(enabled);
}
if (!Strings.isNullOrEmpty(emailAddress)){
config.setEmailAddress(emailAddress);
}

return null;
}
}, zendeskSupportConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
package fish.payara.appserver.zendesk.config;

import java.beans.PropertyVetoException;
import org.glassfish.api.admin.config.ConfigExtension;
import org.jvnet.hk2.config.Attribute;
import org.jvnet.hk2.config.ConfigBeanProxy;
Expand All @@ -51,7 +52,11 @@
@Configured(name="zendesk-support-configuration")
public interface ZendeskSupportConfiguration extends ConfigBeanProxy, ConfigExtension {

@Attribute(required = true)
@Attribute
String getEmailAddress();
public void setEmailAddress(String emailAddress);

@Attribute(defaultValue = "true", dataType = Boolean.class)
Boolean getEnabled();
public void setEnabled(Boolean value);
}

0 comments on commit 23b2f7b

Please sign in to comment.