Skip to content

Commit e05f770

Browse files
authored
Adjust short URL admin UI to match other similar admin pages (#6813)
1 parent 36f7218 commit e05f770

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

core/src/org/labkey/core/admin/AdminController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10397,13 +10397,14 @@ public class ShortURLAdminAction extends AbstractShortURLAdminAction
1039710397
public ModelAndView getView(ShortURLForm form, boolean reshow, BindException errors)
1039810398
{
1039910399
JspView<ShortURLForm> newView = new JspView<>("/org/labkey/core/admin/createNewShortURL.jsp", form, errors);
10400-
newView.setTitle("Create New Short URL");
10400+
boolean isAppAdmin = getUser().hasRootPermission(ApplicationAdminPermission.class);
10401+
newView.setTitle(isAppAdmin ? "Create New Short URL" : "Short URLs");
1040110402
newView.setFrame(WebPartView.FrameType.PORTAL);
1040210403

1040310404
QuerySettings qSettings = new QuerySettings(getViewContext(), "ShortURL", CoreQuerySchema.SHORT_URL_TABLE_NAME);
1040410405
qSettings.setBaseSort(new Sort("-Created"));
1040510406
QueryView existingView = new QueryView(new CoreQuerySchema(getUser(), getContainer()), qSettings, null);
10406-
if (!getUser().hasRootPermission(ApplicationAdminPermission.class))
10407+
if (!isAppAdmin)
1040710408
{
1040810409
existingView.setButtonBarPosition(DataRegion.ButtonBarPosition.NONE);
1040910410
}

core/src/org/labkey/core/admin/createNewShortURL.jsp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,38 @@
2525
ShortURLRecord exampleRecord = new ShortURLRecord();
2626
exampleRecord.setShortURL("SHORT_URL");
2727
String exampleURL = exampleRecord.renderShortURL();
28+
boolean isAppAdmin = getUser().hasRootPermission(ApplicationAdminPermission.class);
2829
%>
30+
<script type="text/javascript" nonce="<%=getScriptNonce()%>">
31+
let _form;
32+
33+
LABKEY.Utils.onReady(function() {
34+
_form = new LABKEY.Form({formElement: 'form-shortUrls'});
35+
});
36+
</script>
2937
<div style="width: 700px">
3038
<p>
3139
Short URLs allow you to create convenient, memorable links to specific content on your server.
3240
They are similar to TinyURL or bit.ly links. Users can access a short URL using a link like <%= h(exampleURL) %>
3341
</p>
42+
<%
43+
if (isAppAdmin)
44+
{
45+
%>
3446
<p>
3547
If the server or port number are incorrect, you can correct the Base Server URL in <a href="<%= h(urlProvider(AdminUrls.class).getCustomizeSiteURL()) %>">Site Settings</a>
3648
</p>
49+
<%
50+
}
51+
%>
3752
</div>
3853

39-
<labkey:form method="post">
54+
<labkey:form id="form-shortUrls" method="post">
4055
<table>
56+
<%
57+
if (isAppAdmin)
58+
{
59+
%>
4160
<tr>
4261
<td class="labkey-form-label"><label for="shortURLTextField">Short URL</label><%= helpPopup("Short URL", "The unique name for this short URL")%></td>
4362
<td><input name="shortURL" id="shortURLTextField" size="40" /></td>
@@ -46,9 +65,16 @@
4665
<td class="labkey-form-label"><label for="targetURLTextField">Target URL</label><%= helpPopup("Target URL", "The URL on this server that will be the redirect target. The server portion of the URL will be stripped off - only the path portion will be retained")%></td>
4766
<td><input name="fullURL" id="targetURLTextField" size="40" /></td>
4867
</tr>
68+
<tr><td>&nbsp;</td></tr>
69+
<%
70+
}
71+
%>
4972
<tr>
50-
<td></td>
51-
<td><%= button("Submit").submit(true).enabled(getUser().hasRootPermission(ApplicationAdminPermission.class)) %></td>
73+
<td colspan="2"><%=isAppAdmin ?
74+
button("Submit").submit(true).onClick("_form.setClean();") :
75+
button("Done").href(urlProvider(AdminUrls.class).getAdminConsoleURL())
76+
%>
77+
</td>
5278
</tr>
5379
</table>
5480
</labkey:form>

core/src/org/labkey/core/admin/existingListValues.jsp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<%@ page import="org.labkey.api.data.Container" %>
2020
<%@ page import="org.labkey.api.security.permissions.ApplicationAdminPermission" %>
2121
<%@ page import="org.labkey.api.util.HtmlString" %>
22-
<%@ page import="org.labkey.api.util.SortHelpers" %>
2322
<%@ page import="org.labkey.api.view.HttpView" %>
2423
<%@ page import="org.labkey.core.admin.AdminController.AllowListForm" %>
2524
<%@ page import="org.labkey.core.admin.AdminController.DeleteAllValuesAction" %>

0 commit comments

Comments
 (0)