Skip to content

Commit

Permalink
Merge branch 'dev' into tl_ID-1126_migrate_from_bond_to_ecm
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs authored Mar 22, 2024
2 parents 32f7c6e + a5883bb commit 8909179
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 321 deletions.
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"test": "jest",
"test-local": "TERRA_SA_KEY=$(vault read --format=json secret/dsde/firecloud/alpha/common/firecloud-account.json | jq .data) LYLE_SA_KEY=$(vault read --format=json secret/dsde/terra/envs/common/lyle-user-service-account-key | jq .data) TEST_URL=http://localhost:3000 yarn test",
"test-local": "TERRA_SA_KEY=$(vault read --format=json secret/dsde/firecloud/dev/common/firecloud-account.json | jq .data) LYLE_SA_KEY=$(vault read --format=json secret/dsde/terra/envs/common/lyle-user-service-account-key | jq .data) TEST_URL=http://localhost:3000 yarn test",
"test-flakes": "FLAKES=true yarn test-local --runInBand"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/modals/GalaxyModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ export const GalaxyModalBase = withDisplayName('GalaxyModal')(
div({ style: { ...computeStyles.whiteBoxContainer, marginTop: '1rem' } }, [
div([
div({ style: computeStyles.headerText }, ['Application configuration']),
div({ style: { marginTop: '0.5rem' } }, ['Galaxy version 23.1']),
div({ style: { marginTop: '0.5rem' } }, ['Galaxy version 24.0']),
h(Link, { href: 'https://support.terra.bio/hc/en-us/articles/360050566271', ...Utils.newTabLinkProps }, [
'Learn more about Galaxy interactive environments',
icon('pop-out', { size: 12, style: { marginTop: '1rem', marginLeft: '0.25rem' } }),
Expand Down
51 changes: 34 additions & 17 deletions src/dataset-builder/CohortEditor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner } from '@terra-ui-packages/components';
import _ from 'lodash/fp';
import React, { Fragment, useEffect, useState } from 'react';
import React, { Fragment, useEffect, useRef, useState } from 'react';
import { div, h, h2, h3, strong } from 'react-hyperscript-helpers';
import { ButtonOutline, ButtonPrimary, GroupedSelect, Link, Select } from 'src/components/common';
import Slider from 'src/components/common/Slider';
Expand Down Expand Up @@ -56,17 +56,28 @@ export const CriteriaView = (props: CriteriaViewProps) => {

const [criteriaCount, setCriteriaCount] = useLoadedData<DatasetParticipantCountResponse>();

useEffect(() => {
setCriteriaCount(async () =>
DataRepo()
.dataset(datasetId)
.getCounts({
// Create a "cohort" to get the count of participants for this criteria on its own.
cohorts: [{ criteriaGroups: [{ criteria: [criteria], name: '', meetAll: true, mustMeet: true }], name: '' }],
})
);
}, [criteria, datasetId, setCriteriaCount]);
const updateCriteriaCount = useRef(
_.debounce(250, (datasetId, criteria) => {
setCriteriaCount(
async () =>
await DataRepo()
.dataset(datasetId)
.getCounts({
cohorts: [
{
// Create a "cohort" to get the count of participants for this criteria on its own.
criteriaGroups: [{ criteria: [criteria], name: '', meetAll: true, mustMeet: true }],
name: '',
},
],
})
);
})
);

useEffect(() => {
updateCriteriaCount.current(datasetId, criteria);
}, [criteria, datasetId]);
return div(
{
style: {
Expand Down Expand Up @@ -322,13 +333,19 @@ export const CriteriaGroupView: React.FC<CriteriaGroupViewProps> = (props) => {

const [groupParticipantCount, setGroupParticipantCount] = useLoadedData<DatasetParticipantCountResponse>();

const updateGroupParticipantCount = useRef(
_.debounce(250, (dataset, criteriaGroup) =>
setGroupParticipantCount(async () =>
DataRepo()
.dataset(dataset.id)
.getCounts({ cohorts: [{ criteriaGroups: [criteriaGroup], name: '' }] })
)
)
);

useEffect(() => {
setGroupParticipantCount(async () =>
DataRepo()
.dataset(dataset.id)
.getCounts({ cohorts: [{ criteriaGroups: [criteriaGroup], name: '' }] })
);
}, [criteriaGroup, dataset.id, setGroupParticipantCount]);
updateGroupParticipantCount.current(dataset, criteriaGroup);
}, [criteriaGroup, dataset]);

return div(
{
Expand Down
65 changes: 64 additions & 1 deletion src/workflows-app/SubmissionDetails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Ajax } from 'src/libs/ajax';
import { renderWithAppContexts as render, SelectHelper } from 'src/testing/test-utils';
import { metadata as runDetailsMetadata } from 'src/workflows-app/fixtures/test-workflow';
import { BaseSubmissionDetails } from 'src/workflows-app/SubmissionDetails';
import { methodData, mockRunsData, runSetData, simpleRunsData } from 'src/workflows-app/utils/mock-data';
import { methodData, mockRunsData, runSetData, runSetDataWithLiteral, simpleRunsData } from 'src/workflows-app/utils/mock-data';
import { mockAzureApps, mockAzureWorkspace, runSetOutputDef, runSetResponse } from 'src/workflows-app/utils/mock-responses';

const submissionId = 'e8347247-4738-4ad1-a591-56c119f93f58';
Expand Down Expand Up @@ -704,6 +704,69 @@ describe('Submission Details page', () => {
expect(row1cells[4]).toHaveTextContent('foo_name');
});

it('Inputs tab handles literal values', async () => {
// Arrange
const user = userEvent.setup();
const getRuns = jest.fn(() => Promise.resolve(mockRunsData));
const getRunsSets = jest.fn(() => Promise.resolve(runSetDataWithLiteral));
const getMethods = jest.fn(() => Promise.resolve(methodData));
const mockLeoResponse = jest.fn(() => Promise.resolve(mockAzureApps));
Ajax.mockImplementation(() => {
return {
Cbas: {
runs: {
get: getRuns,
},
runSets: {
get: getRunsSets,
},
methods: {
getById: getMethods,
},
},
Apps: {
listAppsV2: mockLeoResponse,
},
Metrics: {
captureEvent,
},
AzureStorage: {
details: jest.fn().mockResolvedValue({ sas: { token: '1234-this-is-a-mock-sas-token-5678' } }),
},
};
});

// Act
await act(async () => {
render(
h(BaseSubmissionDetails, {
name: 'test-azure-ws-name',
namespace: 'test-azure-ws-namespace',
workspace: mockAzureWorkspace,
submissionId,
})
);
});

const workflowsTabButton = screen.getByRole('tab', { name: 'Workflows' });
expect(workflowsTabButton !== undefined);

const inputsTabButton = screen.getByRole('tab', { name: 'Inputs' });
expect(inputsTabButton !== undefined);

// ** ACT **
// user clicks on inputs tab button
await user.click(inputsTabButton);

// Assert
const inputTable = screen.getByRole('table');
const rows = within(inputTable).getAllByRole('row');

const row1cells = within(rows[1]).getAllByRole('cell');
expect(row1cells[3]).toHaveTextContent('literal');
expect(row1cells[4]).toHaveTextContent('foo bar');
});

it('should display outputs on the Outputs tab', async () => {
// Add output definition to temporary runset data variable
const tempRunSetData = runSetData;
Expand Down
6 changes: 5 additions & 1 deletion src/workflows-app/components/SubmissionDetailsInputsTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FlexTable, Sortable, TextCell } from 'src/components/table';
import { WorkflowTableColumnNames } from 'src/libs/workflow-utils';
import { getInputTableData, InputTableData } from 'src/workflows-app/utils/submission-utils';

import { InputDefinition, RecordLookupInputSource } from '../models/submission-models';
import { InputDefinition, LiteralInputSource, RecordLookupInputSource } from '../models/submission-models';
import { tableContainerStyle, tableStyle } from './submission-tables-styles';

const rowWidth = 100;
Expand Down Expand Up @@ -96,6 +96,10 @@ const SubmissionDetailsInputsTable = ({ configuredInputDefinition }: SubmissionD
.source as RecordLookupInputSource;
return h(TextCell, [source.record_attribute]);
}
if (inputTableData[rowIndex].source.type === 'literal') {
const source: LiteralInputSource = inputTableData[rowIndex].source as LiteralInputSource;
return h(TextCell, [source.parameter_value]);
}
return h(TextCell, []);
},
},
Expand Down
45 changes: 40 additions & 5 deletions src/workflows-app/utils/mock-data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WorkflowMethod } from 'src/workflows-app/components/WorkflowCard';

export const workflowParams = [
export const workflowParamsRecordLookup = [
{
input_name: 'wf_hello.hello.addressee',
input_type: {
Expand All @@ -14,6 +14,20 @@ export const workflowParams = [
},
];

export const workflowParamsLiteral = [
{
input_name: 'wf_hello.hello.addressee',
input_type: {
type: 'primitive',
primitive_type: 'String',
},
source: {
type: 'literal',
parameter_value: 'foo bar',
},
},
];

export const mockRunsData = {
runs: [
{
Expand All @@ -23,7 +37,7 @@ export const mockRunsData = {
record_id: 'FOO2',
workflow_url: 'https://xyz.wdl',
state: 'SYSTEM_ERROR',
workflow_params: JSON.stringify(workflowParams),
workflow_params: JSON.stringify(workflowParamsRecordLookup),
workflow_outputs: '[]',
submission_date: '2022-07-14T22:22:15.591Z',
last_modified_timestamp: '2022-07-14T23:14:25.791Z',
Expand All @@ -37,7 +51,7 @@ export const mockRunsData = {
workflow_url:
'https://raw.githubusercontent.com/broadinstitute/cromwell/a40de672c565c4bbd40f57ff96d4ee520dc2b4fc/centaur/src/main/resources/standardTestCases/hello/hello.wdl',
state: 'COMPLETE',
workflow_params: JSON.stringify(workflowParams),
workflow_params: JSON.stringify(workflowParamsRecordLookup),
workflow_outputs: '[]',
submission_date: '2022-12-08T23:29:18.675+00:00',
last_modified_timestamp: '2022-12-08T23:29:55.695+00:00',
Expand All @@ -60,7 +74,28 @@ export const runSetData = {
last_modified_timestamp: '2022-12-09T16:30:50.280+00:00',
run_count: 1,
error_count: 0,
input_definition: JSON.stringify(workflowParams),
input_definition: JSON.stringify(workflowParamsRecordLookup),
output_definition: '[]',
},
],
};

export const runSetDataWithLiteral = {
run_sets: [
{
run_set_id: 'e8347247-4738-4ad1-a591-56c119f93f58',
method_id: '00000000-0000-0000-0000-000000000004',
method_version_id: '20000000-0000-0000-0000-000000000004',
is_template: false,
run_set_name: 'hello world',
run_set_description: 'test',
state: 'COMPLETE',
record_type: 'FOO',
submission_timestamp: '2022-12-08T23:28:50.280+00:00',
last_modified_timestamp: '2022-12-09T16:30:50.280+00:00',
run_count: 1,
error_count: 0,
input_definition: JSON.stringify(workflowParamsLiteral),
output_definition: '[]',
},
],
Expand Down Expand Up @@ -159,7 +194,7 @@ export const simpleRunsData = {
record_id: 'FOO2',
workflow_url: 'https://xyz.wdl',
state: 'RUNNING',
workflow_params: JSON.stringify(workflowParams),
workflow_params: JSON.stringify(workflowParamsRecordLookup),
workflow_outputs: '[]',
submission_date: new Date().toISOString(),
last_modified_timestamp: new Date().toISOString(),
Expand Down
4 changes: 1 addition & 3 deletions src/workspaces/list/NoContentMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import { WorkspaceUserActionsContext } from 'src/workspaces/list/WorkspaceUserAc

interface NoContentMessageProps {
loadingWorkspaces: boolean;
loadingSubmissionStats: boolean;
workspaces: CategorizedWorkspaces;
filters: WorkspaceFilterValues;
}

export const NoContentMessage = (props: NoContentMessageProps): ReactNode => {
const { loadingWorkspaces, loadingSubmissionStats, workspaces, filters } = props;
const { loadingWorkspaces, workspaces, filters } = props;
const { setUserActions } = useContext(WorkspaceUserActionsContext);

return cond(
Expand All @@ -27,7 +26,6 @@ export const NoContentMessage = (props: NoContentMessageProps): ReactNode => {
onClick: () => setUserActions({ creatingNewWorkspace: true }),
}),
],
[!_.isEmpty(filters.submissions) && loadingSubmissionStats, () => h(Fragment, ['Loading submission statuses...'])],
() => div({ style: { fontStyle: 'italic' } }, ['No matching workspaces'])
);
};
9 changes: 2 additions & 7 deletions src/workspaces/list/RecentlyViewedWorkspaceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import Events, { extractWorkspaceDetails } from 'src/libs/events';
import * as Nav from 'src/libs/nav';
import * as Style from 'src/libs/style';
import * as Utils from 'src/libs/utils';
import { WorkspaceSubmissionStatusIcon } from 'src/workspaces/list/WorkspaceSubmissionStatusIcon';
import { getCloudProviderFromWorkspace } from 'src/workspaces/utils';

export const RecentlyViewedWorkspaceCard = ({ workspace, submissionStatus, loadingSubmissionStats, timestamp }) => {
export const RecentlyViewedWorkspaceCard = ({ workspace, timestamp }) => {
const {
workspace: { namespace, name },
} = workspace;
Expand All @@ -36,12 +35,8 @@ export const RecentlyViewedWorkspaceCard = ({ workspace, submissionStatus, loadi
div({ style: { flex: 'none' } }, [
div({ style: { color: colors.accent(), ...Style.noWrapEllipsis, fontSize: 16, marginBottom: 7 } }, name),
div({ style: { display: 'flex', justifyContent: 'space-between' } }, [
div({ style: { ...Style.noWrapEllipsis, whiteSpace: 'pre-wrap', fontStyle: 'italic' } }, `Viewed ${dateViewed}`),
div({ style: { ...Style.noWrapEllipsis, whiteSpace: 'pre-wrap', fontStyle: 'italic' } }, [`Viewed ${dateViewed}`]),
div({ style: { display: 'flex', alignItems: 'center' } }, [
h(WorkspaceSubmissionStatusIcon, {
status: submissionStatus,
loadingSubmissionStats,
}),
h(CloudProviderIcon, { cloudProvider: getCloudProviderFromWorkspace(workspace), style: { marginLeft: 5 } }),
]),
]),
Expand Down
10 changes: 5 additions & 5 deletions src/workspaces/list/RecentlyViewedWorkspaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('The recently viewed workspaces component', () => {
asMockedFn(getLocalPref).mockImplementation(mockgetLocalPref);

// Act
render(h(RecentlyViewedWorkspaces, { workspaces: [defaultAzureWorkspace], loadingSubmissionStats: false }));
render(h(RecentlyViewedWorkspaces, { workspaces: [defaultAzureWorkspace] }));
expect(mockgetLocalPref).toBeCalled();
const renderedAzureWS = screen.getAllByText(defaultAzureWorkspace.workspace.name);
expect(renderedAzureWS).toHaveLength(1);
Expand All @@ -62,7 +62,7 @@ describe('The recently viewed workspaces component', () => {

// Act
const workspaces = [defaultAzureWorkspace];
render(h(RecentlyViewedWorkspaces, { workspaces, loadingSubmissionStats: false }));
render(h(RecentlyViewedWorkspaces, { workspaces }));

// Assert
expect(getLocalPref).toBeCalled();
Expand All @@ -81,7 +81,7 @@ describe('The recently viewed workspaces component', () => {

// Act
const workspaces = [defaultAzureWorkspace];
render(h(RecentlyViewedWorkspaces, { workspaces, loadingSubmissionStats: false }));
render(h(RecentlyViewedWorkspaces, { workspaces }));

// Assert
expect(getLocalPref).toBeCalled();
Expand All @@ -100,7 +100,7 @@ describe('The recently viewed workspaces component', () => {

// Act
const workspaces = [defaultAzureWorkspace, defaultGoogleWorkspace];
render(h(RecentlyViewedWorkspaces, { workspaces, loadingSubmissionStats: false }));
render(h(RecentlyViewedWorkspaces, { workspaces }));

// Assert
const renderedAzureWS = screen.getAllByText(defaultAzureWorkspace.workspace.name);
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('The recently viewed workspaces component', () => {
},
defaultGoogleWorkspace,
];
render(h(RecentlyViewedWorkspaces, { workspaces, loadingSubmissionStats: false }));
render(h(RecentlyViewedWorkspaces, { workspaces }));

// Assert
const renderedAzureWS = screen.queryAllByText(defaultAzureWorkspace.workspace.name);
Expand Down
6 changes: 1 addition & 5 deletions src/workspaces/list/RecentlyViewedWorkspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import { getLocalPref, setLocalPref } from 'src/libs/prefs';
import { recentlyViewedPersistenceId } from 'src/workspaces/common/state/recentlyViewedWorkspaces';
import { RecentlyViewedWorkspaceCard } from 'src/workspaces/list/RecentlyViewedWorkspaceCard';
import { getWorkspace, persistenceId } from 'src/workspaces/list/WorkspacesList';
import { workspaceSubmissionStatus } from 'src/workspaces/list/WorkspaceSubmissionStatusIcon';
import { WorkspaceWrapper as Workspace } from 'src/workspaces/utils';

interface RecentlyViewedWorkspacesProps {
workspaces: Workspace[];
loadingSubmissionStats: boolean;
}

export const RecentlyViewedWorkspaces = (props: RecentlyViewedWorkspacesProps): ReactNode => {
const { workspaces, loadingSubmissionStats } = props;
const { workspaces } = props;
const [recentlyViewedOpen, setRecentlyViewedOpen] = useState<boolean>(() =>
_.defaultTo(true, getLocalPref(persistenceId)?.recentlyViewedOpen)
);
Expand Down Expand Up @@ -51,9 +49,7 @@ export const RecentlyViewedWorkspaces = (props: RecentlyViewedWorkspacesProps):
const workspace = getWorkspace(workspaceId, workspaces);
return h(RecentlyViewedWorkspaceCard, {
workspace,
loadingSubmissionStats,
timestamp,
submissionStatus: workspaceSubmissionStatus(workspace),
});
}, recentlyViewed)
),
Expand Down
Loading

0 comments on commit 8909179

Please sign in to comment.