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

Make it possible for users to view their data on Panorama Public #387

Merged
merged 7 commits into from
Jan 21, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
- Code review changes (remove form in MyDataViewAction, use HtmlStrin…
…g.NBSP consistently)

- Use return URL, when available, for rendering the back button in the CatalogEntryWebPart.
vagisha committed Jan 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 0610ae9dc77325c96dd6f4548abdf88efcc55720
Original file line number Diff line number Diff line change
@@ -8953,7 +8953,7 @@ public ModelAndView getView(IdForm form, BindException errors)

ensureCorrectContainer(getContainer(), expAnnotations.getContainer(), getViewContext()); // container check

return new CatalogEntryWebPart(expAnnotations, getUser(), true);
return new CatalogEntryWebPart(expAnnotations, getUser(), form.getReturnActionURL(PageFlowUtil.urlProvider(ProjectUrls.class).getBeginURL(getContainer())));
}

@Override
@@ -9186,7 +9186,7 @@ public ModelAndView getView(Object o, BindException errors)

@RequiresPermission(ReadPermission.class)
@RequiresLogin
public class MyDataViewAction extends SimpleViewAction<MyDataForm>
public class MyDataViewAction extends SimpleViewAction<Object>
{
@Override
public void addNavTrail(NavTree root)
@@ -9195,27 +9195,8 @@ public void addNavTrail(NavTree root)
}

@Override
public ModelAndView getView(MyDataForm form, BindException errors) throws Exception
public ModelAndView getView(Object o, BindException errors) throws Exception
{
if (form.getUserId() == null)
{
errors.addError(new LabKeyError("Did not find a user id in the request"));
return new SimpleErrorView(errors);
}
User user = UserManager.getUser(form.getUserId());
if (user == null)
{
errors.addError(new LabKeyError("Could not find a user for id: " + form.getUserId()));
}
else if (!user.equals(getUser()))
{
errors.addError(new LabKeyError("User did not match. You cannot view datasets for other users"));
}
if (errors.hasErrors())
{
return new SimpleErrorView(errors);
}

QuerySettings settings = new QuerySettings(getViewContext(), MyDataTableInfo.NAME, MyDataTableInfo.NAME);
settings.setContainerFilterName(ContainerFilter.Type.CurrentAndSubfolders.name());
QueryView view = new QueryView(new PanoramaPublicSchema(getUser(), getContainer()), settings, errors);
@@ -9231,21 +9212,6 @@ else if (!user.equals(getUser()))
}
}

public static class MyDataForm
{
private Integer _userId;

public Integer getUserId()
{
return _userId;
}

public void setUserId(Integer userId)
{
_userId = userId;
}
}

// ------------------------------------------------------------------------
// BEGIN Assign PanoramaPublicSubmitterRole to data submitters and lab heads
// ------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -779,15 +779,16 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
String imageUrl = entry != null ? AppProps.getInstance().getContextPath() + "/PanoramaPublic/images/slideshow-icon-green.png"
: AppProps.getInstance().getContextPath() + "/PanoramaPublic/images/slideshow-icon.png";
String imageTitle = entry != null ? "View catalog entry" : "Add catalog entry";
ActionURL catalogEntryLink = entry != null ? PanoramaPublicController.getViewCatalogEntryUrl(expAnnot, entry)
: PanoramaPublicController.getAddCatalogEntryUrl(expAnnot).addReturnURL(ctx.getViewContext().getActionURL().clone());
ActionURL returnUrl = ctx.getViewContext().getActionURL().clone();
ActionURL catalogEntryLink = entry != null ? PanoramaPublicController.getViewCatalogEntryUrl(expAnnot, entry).addReturnURL(returnUrl)
: PanoramaPublicController.getAddCatalogEntryUrl(expAnnot).addReturnURL(returnUrl);
DOM.A(at(href, catalogEntryLink.getLocalURIString(), title, PageFlowUtil.filter(imageTitle)),
DOM.IMG(at(src, imageUrl, height, 22, width, 22)))
.appendTo(out);
return;
}
}
HtmlString.EMPTY_STRING.appendTo(out);
HtmlString.NBSP.appendTo(out);
}
}
}
Original file line number Diff line number Diff line change
@@ -81,7 +81,6 @@ protected void populateButtonBar(DataView view, ButtonBar bb)
if (!view.getViewContext().getUser().isGuest())
{
ActionURL viewMyDataUrl = new ActionURL(PanoramaPublicController.MyDataViewAction.class, getContainer());
viewMyDataUrl.addParameter("userId", view.getViewContext().getUser().getUserId());
ActionButton viewMyDataButton = new ActionButton(viewMyDataUrl, "My Data");
bb.add(viewMyDataButton);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.labkey.panoramapublic.view.publish;

import org.labkey.api.action.UrlProvider;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.portal.ProjectUrls;
import org.labkey.api.security.User;
import org.labkey.api.security.permissions.AdminPermission;
import org.labkey.api.util.Button;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.HtmlView;
@@ -40,10 +38,10 @@ public class CatalogEntryWebPart extends VBox
{
public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user)
{
this(expAnnotations, user, false);
this(expAnnotations, user, null);
}

public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, boolean standalone)
public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, @Nullable ActionURL returnUrl)
{
Container container = expAnnotations.getContainer();
setTitle("Panorama Public Catalog Entry");
@@ -108,9 +106,8 @@ public CatalogEntryWebPart(ExperimentAnnotations expAnnotations, User user, bool
HtmlString.NBSP,
new Button.ButtonBuilder("Delete").href(deleteUrl)
.usePost("Are you sure you want to delete the Panorama Public catalog entry for this experiment?"),
standalone ? DIV(at(style, "margin-top:25px;"),
new Button.ButtonBuilder("Back to Folder").href(PageFlowUtil.urlProvider(ProjectUrls.class).getBeginURL(container)))
: HtmlString.EMPTY_STRING
returnUrl != null ? DIV(at(style, "margin-top:25px;"), new Button.ButtonBuilder("Back").href(returnUrl))
: HtmlString.EMPTY_STRING
)));
}
}
Original file line number Diff line number Diff line change
@@ -484,7 +484,7 @@
if (!LABKEY.user.isGuest)
{
buttonBarItems = [
{text: 'My Data', url: LABKEY.ActionURL.buildURL('panoramapublic', 'myDataView', null, {userId: LABKEY.user.id})},
{text: 'My Data', url: LABKEY.ActionURL.buildURL('panoramapublic', 'myDataView')},
LABKEY.QueryWebPart.standardButtons.views
];
}
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ private void makeDataPublicWithCatalogEntry()
clickButton("View Entry");
assertTextPresent("Pending approval");
assertElementNotPresent("Approve button should be displayed only for site admins.", Locator.lkButton("Approve"));
clickButton("Back to Folder");
clickButton("Back");
}

private void verifyCatalogEntryWebpart(String projectName, String folderName, boolean expectWebpart)
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ private void verifyColumnValues(DataRegionTable table, int catalogEntryCol, int
else
{
// This data is not public. The Catalog Entry column should be blank.
assertEquals("Unexpected value in \"Catalog Entry\" column for row " + row, "", table.getDataAsText(row, catalogEntryCol));
assertEquals("Unexpected value in \"Catalog Entry\" column for row " + row, "", table.getDataAsText(row, catalogEntryCol).trim());
}
}
}