Skip to content

Create queries for custom views, reports and queries#7650

Open
labkey-klum wants to merge 15 commits intodevelopfrom
fb_customView_query
Open

Create queries for custom views, reports and queries#7650
labkey-klum wants to merge 15 commits intodevelopfrom
fb_customView_query

Conversation

@labkey-klum
Copy link
Copy Markdown
Contributor

Rationale

Tracking issue : https://github.com/LabKey/internal-issues/issues/1078

This PR introduces admin-only queries to replace (or create) standard LabKey table infos for : custom views, reports and queries. Details include:

  • New query schema that's available to admins only.
  • query.CustomViews table that exposes that table (shared and private views).
  • query.Queires table that exposes the querydef table.
  • core.Reports table that exposes the reports table, also restricted to admins.
  • For each table, show the "flags" bitmask column as separate boolean columns (inheritable, hidden)
  • Details and edit links should navigate to the standard pages for that object.
    • Reports : details
    • CustomViews : insert, edit
  • Implement bulk delete via checkboxes (no truncate, though).

@labkey-klum labkey-klum marked this pull request as ready for review May 7, 2026 00:16
@labkey-klum labkey-klum requested a review from labkey-adam May 7, 2026 00:16
Copy link
Copy Markdown
Contributor

@labkey-adam labkey-adam left a comment

Choose a reason for hiding this comment

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

See questions about potential cross-container issues

names.add(DOCUMENTS_TABLE_NAME);

if (getContainer().hasPermission(getUser(), AdminPermission.class))
names.add(REPORTS_TABLE_NAME);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Totally fine for now. In the future, we might consider showing non-admins their own reports (and queries and views).

}
}


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yay!

Integer id = (Integer) oldRowMap.get("rowId");
if (id != null)
{
var r = ReportService.get().getReport(container, id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude flagged this as a possible cross-container delete issue. When deleting with a container filter applied, container is the request container, not the report's container, right? Should we change? Do we need to check permissions in the report's container as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we need to use the container from the existing row map to resolve the container and then check the users permissions on that container.

Integer id = (Integer)oldRowMap.get("customViewId");
if (id != null)
{
var view = QueryManager.get().getCustomView(container, id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cross-container issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

protected Map<String, Object> deleteRow(User user, Container container, Map<String, Object> oldRowMap) throws SQLException, QueryUpdateServiceException, InvalidKeyException
{
var queryDef = QueryDefCache.getQueryDefById(container, (Integer)oldRowMap.get("queryDefId"));
if (queryDef != null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cross-container issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, done

@Override
protected Map<String, Object> _update(User user, Container container, Map<String, Object> row, Map<String, Object> oldRow, Object[] keys) throws SQLException, ValidationException
{
Integer id = (Integer) oldRow.get("customViewId");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Get container from old row?

@labkey-adam labkey-adam self-requested a review May 7, 2026 22:12
Copy link
Copy Markdown
Contributor

@labkey-adam labkey-adam left a comment

Choose a reason for hiding this comment

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

Manual testing verifies those cross-container issues are present. For example, apply a folder filter and attempt to delete a report that's outside the request folder.

@labkey-klum
Copy link
Copy Markdown
Contributor Author

Manual testing verifies those cross-container issues are present. For example, apply a folder filter and attempt to delete a report that's outside the request folder.

Give it another try, I think I've addressed all of those cross folder issues.

@labkey-klum labkey-klum requested a review from labkey-adam May 7, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants