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

Add moveRows to Query module in @labkey/api #1372

Merged
merged 16 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
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
18 changes: 9 additions & 9 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labkey/components",
"version": "2.399.0",
"version": "2.399.0-fb-moveRowsJSAPI.3",
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
"sideEffects": false,
"files": [
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"homepage": "https://github.com/LabKey/labkey-ui-components#readme",
"dependencies": {
"@labkey/api": "1.27.0",
"@labkey/api": "1.27.1-fb-moveRowsJSAPI.4",
"@testing-library/jest-dom": "~5.17.0",
"@testing-library/react": "~12.1.5",
"@testing-library/user-event": "~12.8.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/components/releaseNotes/components.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# @labkey/components
Components, models, actions, and utility functions for LabKey applications and pages.

### version TBD
*Released*: TBD
- Update @labkey/api and use moveRows() function
- Include fix for Issue 49164: Datepicker in editable grid needs to account for the sticky footer when at the bottom of the grid

### version 2.399.0
*Released*: 15 December 2023
- Consolidate move entities to MoveRowsAction in query controller
Expand Down
17 changes: 3 additions & 14 deletions packages/components/src/internal/components/entities/APIWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { List, Map } from 'immutable';
import { Query } from '@labkey/api';

import { GetNameExpressionOptionsResponse, loadNameExpressionOptions } from '../settings/actions';

import { QueryInfo } from '../../../public/QueryInfo';

import { InsertOptions } from '../../query/api';

import { Container } from '../base/models/Container';

import {
getDataOperationConfirmationData,
getDeleteConfirmationData,
Expand All @@ -17,6 +16,7 @@ import {
handleEntityFileImport,
moveEntities,
initParentOptionsSelects,
MoveEntitiesOptions,
} from './actions';
import { DataOperation } from './constants';
import {
Expand All @@ -26,7 +26,6 @@ import {
IEntityTypeOption,
IParentAlias,
IParentOption,
MoveEntitiesResult,
OperationConfirmationData,
} from './models';

Expand Down Expand Up @@ -90,17 +89,7 @@ export interface EntityAPIWrapper {
parentOptions: IParentOption[];
}>;
loadNameExpressionOptions: (containerPath?: string) => Promise<GetNameExpressionOptionsResponse>;
moveEntities: (
sourceContainer: Container,
targetContainer: string,
entityDataType: EntityDataType,
schemaName: string,
queryName: string,
rowIds?: number[],
selectionKey?: string,
useSnapshotSelection?: boolean,
auditUserComment?: string
) => Promise<MoveEntitiesResult>;
moveEntities: (options: MoveEntitiesOptions) => Promise<Query.MoveRowsResponse>;
}

export class EntityServerAPIWrapper implements EntityAPIWrapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC, memo, useCallback, useEffect, useState } from 'react';

import { ActionURL } from '@labkey/api';
import { ActionURL, AuditBehaviorTypes } from '@labkey/api';

import { Progress } from '../base/Progress';
import { ConfirmModal } from '../base/ConfirmModal';
Expand Down Expand Up @@ -117,17 +117,18 @@ export const EntityMoveModal: FC<EntityMoveModalProps> = memo(props => {
const useSnapshotSelection = useSelected && movingAll && queryModel.filterArray.length > 0;

try {
await api.entity.moveEntities(
currentContainer,
await api.entity.moveEntities({
containerPath: currentContainer?.path,
targetContainerPath,
entityDataType,
queryModel.schemaName,
queryModel.queryName,
rowIds_,
selectionKey,
schemaName: queryModel.schemaName,
queryName: queryModel.queryName,
rowIds: rowIds_,
dataRegionSelectionKey: selectionKey,
useSnapshotSelection,
auditUserComment
);
auditBehavior: AuditBehaviorTypes.DETAILED,
auditUserComment,
});

let projectUrl = buildURL(
getPrimaryAppProperties()?.productId,
Expand Down
55 changes: 17 additions & 38 deletions packages/components/src/internal/components/entities/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionURL, Ajax, AuditBehaviorTypes, Filter, getServerContext, Query, Utils } from '@labkey/api';
import { ActionURL, Ajax, Filter, getServerContext, Query, Utils } from '@labkey/api';
import { List, Map } from 'immutable';

import { getSelectedData, getSelected, setSnapshotSelections } from '../../actions';
Expand All @@ -20,8 +20,6 @@ import { Row, selectRows, SelectRowsResponse } from '../../query/selectRows';

import { ViewInfo } from '../../ViewInfo';

import { Container } from '../base/models/Container';

import { getProjectDataExclusion, hasModule } from '../../app/utils';

import { resolveErrorMessage } from '../../util/messaging';
Expand Down Expand Up @@ -51,7 +49,6 @@ import {
IEntityTypeOption,
IParentAlias,
IParentOption,
MoveEntitiesResult,
OperationConfirmationData,
ProjectConfigurableDataType,
RemappedKeyValues,
Expand Down Expand Up @@ -818,54 +815,36 @@ export function getMoveConfirmationData(
);
}

export function moveEntities(
sourceContainer: Container,
targetContainer: string,
entityDataType: EntityDataType,
schemaName: string,
queryName: string,
rowIds?: number[],
selectionKey?: string,
useSnapshotSelection?: boolean,
userComment?: string
): Promise<MoveEntitiesResult> {
export interface MoveEntitiesOptions extends Omit<Query.MoveRowsOptions, 'rows' | 'success' | 'failure' | 'scope'> {
entityDataType: EntityDataType;
rowIds?: number[];
}

export function moveEntities(options: MoveEntitiesOptions): Promise<Query.MoveRowsResponse> {
return new Promise((resolve, reject) => {
const params = {
auditBehavior: AuditBehaviorTypes.DETAILED,
auditUserComment: userComment,
targetContainerPath: targetContainer,
schemaName,
queryName,
};
const { entityDataType, rowIds, ...rest} = options;
const params = Object.assign({}, rest);
if (rowIds) {
params['rows'] = rowIds.reduce((prev, curr) => {
prev.push({ rowId: curr });
return prev;
}, []);
}
if (selectionKey) {
params['dataRegionSelectionKey'] = selectionKey;
params['useSnapshotSelection'] = useSnapshotSelection;
}

return Ajax.request({
url: buildURL('query', 'moveRows.api', undefined, {
container: sourceContainer?.path,
}),
method: 'POST',
jsonData: params,
success: Utils.getCallbackWrapper(response => {
Query.moveRows({
...params,
success: (response: Query.MoveRowsResponse) => {
if (response.success) {
resolve(response);
} else {
console.error('Error moving ' + entityDataType.nounPlural, response);
reject(response?.error ?? 'Unknown error moving ' + entityDataType.nounPlural + '.');
}
}),
failure: Utils.getCallbackWrapper(response => {
console.error('Error moving ' + entityDataType.nounPlural, response);
reject(response?.exception ?? 'Unknown error moving ' + entityDataType.nounPlural + '.');
}),
},
failure: reason => {
console.error('Error moving ' + entityDataType.nounPlural, reason);
reject(reason?.exception ?? 'Unknown error moving ' + entityDataType.nounPlural + '.');
},
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,6 @@ export interface IParentAlias {
parentValue: IParentOption;
}

export interface MoveEntitiesResult {
containerPath: string;
success: boolean;
updateCounts: Record<string, number>;
}

export interface DataTypeEntity {
description?: string;
label: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/theme/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ div.react-datepicker__current-month {
.react-datepicker-popper {
// The default z-index is 1, but bootstrap sets the z-index for form inputs to 2, which means all form inputs render
// on top of the date-picker by default, which makes it hard to use in some situations.
z-index: 10;
// Issue 49164: set z-index greater than the sticky footer (which is 10)
z-index: 11;
}
.add-control--error-message {
padding-top: 5px;
Expand Down
4 changes: 2 additions & 2 deletions packages/themes/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/themes/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@labkey/themes",
"version": "1.3.2",
"version": "1.3.2-fb-moveRowsJSAPI.1",
"description": "Themes that come bundled with LabKey Server",
"files": [
"dist/"
Expand Down
10 changes: 7 additions & 3 deletions packages/themes/styles/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@
// Show a better error to the user than just a generic Unauthorized dialog
if (response.status === 401) {
document.getElementById(id).innerHTML = '<div style="padding: 5px">You do not have permission to view this data. You have likely been logged out.'
+ (this.loginUrl != null ? ' Please <a href="' + this.loginUrl + '">log in</a> again.' : ' Please <a href="#" onclick="location.reload();">reload</a> the page.') + "</div>";
+ (this.loginUrl != null ? ' Please <a href="' + this.loginUrl + '">log in</a> again.' : ' Please <a href="#" id="' + id + '-reload">reload</a> the page.') + "</div>";

document.getElementById(id + '-reload').addEventListener('click', function() {
location.reload();
});
}
else {
if (window.console && window.console.log) {
Expand Down Expand Up @@ -364,7 +368,7 @@
if (menu.length === 0) {
return;
}

var offset = menu.offset();
var win = $(window);

Expand Down Expand Up @@ -671,4 +675,4 @@
onScroll();
}
});
}(jQuery);
}(jQuery);