Skip to content

Add configurable banner setting to landing page #304

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

Merged
merged 11 commits into from
Mar 20, 2024
10 changes: 10 additions & 0 deletions api/src/main/java/com/intuit/tank/vm/settings/TankConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class TankConfig extends BaseCommonsXmlConfig {
private static final String KEY_REPORTING_NODE = "reporting";
private static final String KEY_OIDC_SSO_NODE = "oidc-sso";

private static final String KEY_BANNER_TEXT = "banner-text";

private static String configName = CONFIG_NAME;

static {
Expand Down Expand Up @@ -118,6 +120,14 @@ public String getDataFileStorageDir() {
public boolean isRestSecurityEnabled() {
return config.getBoolean(KEY_REST_SECURITY_ENABLED, false);
}

/**
* @return banner text
*/
public String getTextBanner() {
return config.getString(KEY_BANNER_TEXT, "");
}

/**
* @return true if rest security is enabled
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ public void actionPerformed(ActionEvent event) {
baseURLPanel.setBorder(BorderFactory.createTitledBorder("Intuit/Tank Base URL"));
JPanel tokenPanel = new JPanel();
comboBox.setPreferredSize(new Dimension(375,25));
tokenPanel.setBorder(BorderFactory.createTitledBorder("Intuit/Tank Token"));
tokenPanel.setBorder(BorderFactory.createTitledBorder("Intuit/Tank Token*"));
tokenPanel.setToolTipText("Generate a Tank API token by logging into Tank and going to 'Account Settings' on the upper right to create a token for this specific host. ");
final JTextField tokenField = new JTextField();
tokenField.setPreferredSize(new Dimension(375,25));
baseURLPanel.add(comboBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.Serializable;
import java.util.List;

import com.intuit.tank.vm.settings.TankConfig;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.event.Event;
import jakarta.faces.model.SelectItem;
Expand Down Expand Up @@ -44,6 +45,9 @@ public class ProjectDescriptionBean extends SelectableBean<Project> implements S

private static final long serialVersionUID = 1L;

@Inject
private TankConfig tankConfig;

@Inject
private ProjectLoader projectLoader;

Expand All @@ -70,6 +74,14 @@ public void init() {
tablePrefs.registerListener(userPrefs);
}

public String getBannerMessage() {
return tankConfig.getTextBanner();
}

public boolean isBannerVisible() {
return !tankConfig.getTextBanner().isEmpty();
}

public void deleteSelectedProject() {
if (selectedProject != null) {
delete(selectedProject.getEntity());
Expand Down
12 changes: 12 additions & 0 deletions web/web_ui/src/main/webapp/projects/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
</ts:toolbar>

<div class="vertical-spacer" />

<!-- Section for Banners on project page - configurable via settings file -->

<p:panel id="banner-text"
styleClass="d-flex align-items-center justify-content-between p-3 flex-wrap"
style="background-color: #dfeffc; color: #000; font-size: 0.8rem; font-weight: bold; border-radius: 10px;"
visible="#{projectDescriptionBean.bannerVisible}">
<h:outputText styleClass="mr-8" value="#{projectDescriptionBean.getBannerMessage()}" />
<br/>
<br/>
</p:panel>

<p:growl globalOnly="true" id="messages" autoUpdate="true" />

<pe:remoteCommand id="resizeListener" name="resizeFinished" update="projectTableId" />
Expand Down