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

[AN-160] Reorganize methods repository files #5155

Merged
merged 28 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cece7e8
Remove unused title option from wrapWorkflows
sam-schu Sep 17, 2024
648bbec
Update top bar title
sam-schu Sep 18, 2024
5ffb222
Update nav paths
sam-schu Sep 20, 2024
60782bf
Merge branch 'dev' into sts_WX-1761_workflows_to_methods
sam-schu Sep 20, 2024
64ade09
Change usages of "workflow" to "method"
sam-schu Sep 24, 2024
331bc3c
Update browser page title for methods list page
sam-schu Sep 24, 2024
189d616
Merge dev into branch
sam-schu Oct 22, 2024
26c25b0
Merge dev into branch
sam-schu Oct 25, 2024
b167e87
Additional test updates
sam-schu Oct 25, 2024
c17da48
Fix incorrect flow typing
sam-schu Oct 28, 2024
a9e73e7
Improve typing for tab keys
sam-schu Oct 29, 2024
c444083
Remove unnecessary duplication of object
sam-schu Oct 29, 2024
3cf550c
Fix WorkflowWrapper test file
sam-schu Oct 29, 2024
3c5442d
Additional test updates
sam-schu Oct 29, 2024
1f72216
Update comment
sam-schu Oct 29, 2024
6c6e88e
Merge branch 'dev' into sts_WX-1761_workflows_to_methods
sam-schu Oct 30, 2024
20aff6c
Merge branch 'sts_WX-1761_workflows_to_methods' into sts_AN-160_reorg…
sam-schu Oct 30, 2024
0c98242
Reorganize files within workflows directories
sam-schu Oct 30, 2024
87ac85e
Move schema type definition into Ajax models file
sam-schu Oct 30, 2024
bb136a5
Add return type for method definitions API call
sam-schu Oct 30, 2024
1a39da6
Reorganize workflows ACL types
sam-schu Nov 1, 2024
f9bb168
Type methods ACL endpoint calls
sam-schu Nov 1, 2024
eff81e7
Rename directories
sam-schu Nov 1, 2024
d505689
Move Snapshot type
sam-schu Nov 1, 2024
42b92db
Merge branch 'dev' into sts_AN-160_reorganize_methods_repo_files
sam-schu Nov 1, 2024
c683cf5
Fix incorrect auto-merge
sam-schu Nov 1, 2024
fb2d760
Combine imports
sam-schu Nov 1, 2024
329a8f5
Change "methods repo" to "methods" in directory paths
sam-schu Nov 4, 2024
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
15 changes: 10 additions & 5 deletions src/libs/ajax/methods/Methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import _ from 'lodash/fp';
import * as qs from 'qs';
import { authOpts } from 'src/auth/auth-session';
import { fetchAgora, fetchOrchestration, fetchRawls } from 'src/libs/ajax/ajax-common';
import { MethodQuery, MethodResponse } from 'src/libs/ajax/methods/methods-models';
import { Snapshot } from 'src/snapshots/Snapshot';
import {
MethodConfigACL,
MethodDefinition,
MethodQuery,
MethodResponse,
Snapshot,
} from 'src/libs/ajax/methods/methods-models';

export const Methods = (signal?: AbortSignal) => ({
list: async (params): Promise<Snapshot[]> => {
const res = await fetchAgora(`methods?${qs.stringify(params)}`, _.merge(authOpts(), { signal }));
return res.json();
},

definitions: async () => {
definitions: async (): Promise<MethodDefinition[]> => {
const res = await fetchAgora('methods/definitions', _.merge(authOpts(), { signal }));
return res.json();
},
Expand Down Expand Up @@ -60,12 +65,12 @@ export const Methods = (signal?: AbortSignal) => ({
return res.json();
},

permissions: async () => {
permissions: async (): Promise<MethodConfigACL> => {
const res = await fetchOrchestration(`api/${root}/permissions`, _.merge(authOpts(), { signal }));
return res.json();
},

setPermissions: async (payload) => {
setPermissions: async (payload: MethodConfigACL): Promise<MethodConfigACL> => {
const res = await fetchOrchestration(
`api/${root}/permissions`,
_.mergeAll([authOpts(), jsonBody(payload), { signal, method: 'POST' }])
Expand Down
44 changes: 44 additions & 0 deletions src/libs/ajax/methods/methods-models.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/**
* Type for Agora's MethodDefinition schema.
*/
export interface MethodDefinition {
namespace: string;
name: string;
synopsis: string;
managers: string[];
public: boolean;
numConfigurations: number;
numSnapshots: number;
entityType: string;
}

/**
* Corresponds to Agora's MethodResponse schema. Represents information about
* a method snapshot in the Broad Methods Repository.
*/
export interface Snapshot {
managers: string[];
name: string;
createDate: string;
documentation?: string;
entityType: string;
snapshotComment: string;
snapshotId: number;
namespace: string;
payload: string;
url: string;
public: boolean | undefined;
synopsis: string;
}

/**
* Type for Orchestration's MethodQuery schema.
*
Expand Down Expand Up @@ -35,3 +68,14 @@ export interface MethodResponse {
payload?: string;
entityType?: string;
}

export type WorkflowAccessLevel = 'NO ACCESS' | 'READER' | 'OWNER';
export interface WorkflowUserPermissions {
user: string;
role: WorkflowAccessLevel;
}

/**
* Type for Orchestration's MethodConfigACL schema.
*/
export type MethodConfigACL = WorkflowUserPermissions[];
6 changes: 3 additions & 3 deletions src/libs/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import * as DatasetBuilder from 'src/pages/library/dataset-builder/DatasetBuilde
import * as Datasets from 'src/pages/library/Datasets';
import * as DataExplorer from 'src/pages/library/datasets/DataExplorer';
import * as Showcase from 'src/pages/library/Showcase';
import * as WorkflowDetails from 'src/pages/methods/workflow-details/WorkflowSummary';
import * as WorkflowWdl from 'src/pages/methods/workflow-details/WorkflowWdl';
import * as WorkflowList from 'src/pages/methods/WorkflowList';
import * as NotFound from 'src/pages/NotFound';
import * as Profile from 'src/pages/ProfilePage';
import * as Support from 'src/pages/SupportPage';
import * as UploadData from 'src/pages/UploadDataPage';
import * as WorkflowDetails from 'src/pages/workflows/workflow/WorkflowSummary';
import * as WorkflowWdl from 'src/pages/workflows/workflow/WorkflowWdl';
import * as WorkflowList from 'src/pages/workflows/WorkflowList';
import * as WorkspaceList from 'src/pages/workspaces/List';
import * as WorkspaceFiles from 'src/pages/workspaces/workspace/Files';
import * as JobHistory from 'src/pages/workspaces/workspace/JobHistory';
Expand Down
2 changes: 1 addition & 1 deletion src/libs/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { AuthTokenState } from 'src/auth/auth';
import { OidcUser } from 'src/auth/oidc-broker';
import { Dataset } from 'src/libs/ajax/Catalog';
import { EcmLinkAccountResponse } from 'src/libs/ajax/ExternalCredentials';
import { Snapshot } from 'src/libs/ajax/methods/methods-models';
import { OidcConfig } from 'src/libs/ajax/OAuth2';
import { SamTermsOfServiceConfig } from 'src/libs/ajax/TermsOfService';
import { NihDatasetPermission, SamUserAllowances, SamUserAttributes, SamUserResponse } from 'src/libs/ajax/User';
import { getLocalStorage, getSessionStorage, staticStorageSlot } from 'src/libs/browser-storage';
import { Snapshot } from 'src/snapshots/Snapshot';
import type { WorkspaceInfo, WorkspaceWrapper } from 'src/workspaces/utils';

export const routeHandlersStore = atom<unknown[]>([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import React from 'react';
import { Ajax, AjaxContract } from 'src/libs/ajax';
import { MethodsAjaxContract } from 'src/libs/ajax/methods/Methods';
import { MethodResponse } from 'src/libs/ajax/methods/methods-models';
import { MethodDefinition } from 'src/libs/ajax/methods/methods-models';
import { createMethodProvider } from 'src/libs/ajax/methods/providers/CreateMethodProvider';
import * as Nav from 'src/libs/nav';
import { getLink } from 'src/libs/nav';
import { notify } from 'src/libs/notifications';
import { TerraUser, TerraUserState, userStore } from 'src/libs/state';
import { MethodDefinition } from 'src/pages/workflows/workflow-utils';
import { WorkflowList } from 'src/pages/workflows/WorkflowList';
import { WorkflowList } from 'src/pages/methods/WorkflowList';
import { asMockedFn, renderWithAppContexts as render } from 'src/testing/test-utils';

jest.mock('src/libs/ajax');
Expand All @@ -23,9 +23,9 @@ jest.mock('src/libs/nav', () => ({
goToPath: jest.fn(),
}));

type WDLEditorExports = typeof import('src/pages/workflows/common/WDLEditor');
jest.mock('src/pages/workflows/common/WDLEditor', (): WDLEditorExports => {
const mockWDLEditorModule = jest.requireActual('src/pages/workflows/common/WDLEditor.mock');
type WDLEditorExports = typeof import('src/workflows/methods/WDLEditor');
jest.mock('src/workflows/methods/WDLEditor', (): WDLEditorExports => {
const mockWDLEditorModule = jest.requireActual('src/workflows/methods/WDLEditor.mock');
return {
WDLEditor: mockWDLEditorModule.MockWDLEditor,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { TabBar } from 'src/components/tabBars';
import { FlexTable, HeaderCell, Paginator, Sortable, TooltipCell } from 'src/components/table';
import { TopBar } from 'src/components/TopBar';
import { Ajax } from 'src/libs/ajax';
import { MethodDefinition } from 'src/libs/ajax/methods/methods-models';
import { createMethodProvider } from 'src/libs/ajax/methods/providers/CreateMethodProvider';
import * as Nav from 'src/libs/nav';
import { notify } from 'src/libs/notifications';
import { useCancellation, useOnMount } from 'src/libs/react-utils';
import { getTerraUser } from 'src/libs/state';
import * as Utils from 'src/libs/utils';
import { withBusyState } from 'src/libs/utils';
import { WorkflowModal } from 'src/pages/workflows/workflow/common/WorkflowModal';
import { MethodDefinition } from 'src/pages/workflows/workflow-utils';
import { WorkflowModal } from 'src/workflows/methods/modals/WorkflowModal';

// Note: The first tab key in this array will determine the default tab selected
// if the tab query parameter is not present or has an invalid value (and when
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fireEvent, screen } from '@testing-library/react';
import { h } from 'react-hyperscript-helpers';
import { snapshotStore } from 'src/libs/state';
import { BaseWorkflowSummary } from 'src/pages/workflows/workflow/WorkflowSummary';
import { BaseWorkflowSummary } from 'src/pages/methods/workflow-details/WorkflowSummary';
import { renderWithAppContexts } from 'src/testing/test-utils';

jest.mock('src/libs/notifications');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { withErrorReporting } from 'src/libs/error';
import { forwardRefWithName, useStore } from 'src/libs/react-utils';
import { snapshotStore } from 'src/libs/state';
import * as Style from 'src/libs/style';
import { WorkflowRightBoxSection } from 'src/pages/workflows/components/WorkflowRightBoxSection';
import { wrapWorkflows } from 'src/pages/workflows/workflow/WorkflowWrapper';
import { wrapWorkflows } from 'src/pages/methods/workflow-details/WorkflowWrapper';
import { WorkflowRightBoxSection } from 'src/workflows/methods/WorkflowRightBoxSection';
import { InfoRow } from 'src/workspaces/dashboard/InfoRow';

export const BaseWorkflowSummary = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { screen } from '@testing-library/react';
import { h } from 'react-hyperscript-helpers';
import { snapshotStore } from 'src/libs/state';
import { BaseWorkflowWdl } from 'src/pages/workflows/workflow/WorkflowWdl';
import { BaseWorkflowWdl } from 'src/pages/methods/workflow-details/WorkflowWdl';
import { renderWithAppContexts } from 'src/testing/test-utils';

jest.mock('src/libs/ajax');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as breadcrumbs from 'src/components/breadcrumbs';
import WDLViewer from 'src/components/WDLViewer';
import { forwardRefWithName } from 'src/libs/react-utils';
import { snapshotStore } from 'src/libs/state';
import { wrapWorkflows } from 'src/pages/workflows/workflow/WorkflowWrapper';
import { wrapWorkflows } from 'src/pages/methods/workflow-details/WorkflowWrapper';

export const BaseWorkflowWdl = () => {
const { name, snapshotId, payload } = useStore(snapshotStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import React from 'react';
import * as breadcrumbs from 'src/components/breadcrumbs';
import { Ajax, AjaxContract } from 'src/libs/ajax';
import { MethodsAjaxContract } from 'src/libs/ajax/methods/Methods';
import { Snapshot } from 'src/libs/ajax/methods/methods-models';
import * as ExportWorkflowToWorkspaceProvider from 'src/libs/ajax/workspaces/providers/ExportWorkflowToWorkspaceProvider';
import { errorWatcher } from 'src/libs/error.mock';
import { goToPath } from 'src/libs/nav';
import { forwardRefWithName } from 'src/libs/react-utils';
import { snapshotsListStore, snapshotStore, TerraUser, TerraUserState, userStore } from 'src/libs/state';
import { WorkflowsContainer, wrapWorkflows } from 'src/pages/workflows/workflow/WorkflowWrapper';
import { Snapshot } from 'src/snapshots/Snapshot';
import { WorkflowsContainer, wrapWorkflows } from 'src/pages/methods/workflow-details/WorkflowWrapper';
import { asMockedFn, partial, renderWithAppContexts as render, SelectHelper } from 'src/testing/test-utils';
import { useWorkspaces } from 'src/workspaces/common/state/useWorkspaces';
import { AzureContext, WorkspaceInfo, WorkspaceWrapper } from 'src/workspaces/utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import FooterWrapper from 'src/components/FooterWrapper';
import { TabBar } from 'src/components/tabBars';
import { TopBar } from 'src/components/TopBar';
import { Ajax } from 'src/libs/ajax';
import { Snapshot } from 'src/libs/ajax/methods/methods-models';
import { makeExportWorkflowFromMethodsRepoProvider } from 'src/libs/ajax/workspaces/providers/ExportWorkflowToWorkspaceProvider';
import { ErrorCallback, withErrorReporting } from 'src/libs/error';
import * as Nav from 'src/libs/nav';
Expand All @@ -16,11 +17,10 @@ import { getTerraUser, snapshotsListStore, snapshotStore } from 'src/libs/state'
import * as Style from 'src/libs/style';
import * as Utils from 'src/libs/utils';
import { withBusyState } from 'src/libs/utils';
import { PermissionsModal } from 'src/pages/workflows/workflow/common/PermissionsModal';
import { Snapshot } from 'src/snapshots/Snapshot';
import DeleteSnapshotModal from 'src/workflows/modals/DeleteSnapshotModal';
import DeleteSnapshotModal from 'src/workflows/methods/modals/DeleteSnapshotModal';
import { PermissionsModal } from 'src/workflows/methods/modals/PermissionsModal';
import SnapshotActionMenu from 'src/workflows/methods/SnapshotActionMenu';
import ExportWorkflowModal from 'src/workflows/modals/ExportWorkflowModal';
import SnapshotActionMenu from 'src/workflows/SnapshotActionMenu';
import { isGoogleWorkspace, WorkspaceInfo, WorkspaceWrapper } from 'src/workspaces/utils';
import * as WorkspaceUtils from 'src/workspaces/utils';

Expand Down
14 changes: 0 additions & 14 deletions src/pages/workflows/workflow-utils.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/pages/workflows/workflow/workflows-acl-utils.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/snapshots/Snapshot.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { act, screen } from '@testing-library/react';
import userEvent, { UserEvent } from '@testing-library/user-event';
import React from 'react';
import { renderWithAppContexts as render } from 'src/testing/test-utils';
import SnapshotActionMenu from 'src/workflows/SnapshotActionMenu';
import SnapshotActionMenu from 'src/workflows/methods/SnapshotActionMenu';

const mockOnDelete = jest.fn();
const mockOnEditPermissions = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { WDLEditor } from 'src/pages/workflows/common/WDLEditor';
import { WDLEditor } from 'src/workflows/methods/WDLEditor';

describe('WDLEditor', () => {
it('renders the editor', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { act, screen, within } from '@testing-library/react';
import userEvent, { UserEvent } from '@testing-library/user-event';
import React from 'react';
import { renderWithAppContexts as render } from 'src/testing/test-utils';
import DeleteSnapshotModal from 'src/workflows/modals/DeleteSnapshotModal';
import DeleteSnapshotModal from 'src/workflows/methods/modals/DeleteSnapshotModal';

const mockOnConfirm = jest.fn();
const mockOnDismiss = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import userEvent, { UserEvent } from '@testing-library/user-event';
import React from 'react';
import { Ajax, AjaxContract } from 'src/libs/ajax';
import { reportError } from 'src/libs/error';
import { PermissionsModal } from 'src/pages/workflows/workflow/common/PermissionsModal';
import { WorkflowsPermissions } from 'src/pages/workflows/workflow/workflows-acl-utils';
import { asMockedFn, renderWithAppContexts, SelectHelper } from 'src/testing/test-utils';
import { PermissionsModal } from 'src/workflows/methods/modals/PermissionsModal';
import { WorkflowsPermissions } from 'src/workflows/methods/workflows-acl-utils';

jest.mock('src/libs/ajax');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
WorkflowAccessLevel,
WorkflowsPermissions,
WorkflowUserPermissions,
} from 'src/pages/workflows/workflow/workflows-acl-utils';
} from 'src/workflows/methods/workflows-acl-utils';
import validate from 'validate.js';

type WorkflowPermissionsModalProps = {
Expand Down Expand Up @@ -214,9 +214,13 @@ export const PermissionsModal = (props: WorkflowPermissionsModalProps) => {
};

const save = withBusyState(setWorking, async () => {
const toBeDeleted = _.remove((entry) => userEmails.includes(entry.user), originalPermissions);
const toBeDeleted: WorkflowsPermissions = _.remove((entry) => userEmails.includes(entry.user), originalPermissions);
const toBeDeletedPermissionUpdates: WorkflowsPermissions = _.map(
({ user }) => ({ user, role: 'NO ACCESS' }),
toBeDeleted
);

const permissionUpdates = [...permissions, ..._.map(({ user }) => ({ user, role: 'NO ACCESS' }), toBeDeleted)];
const permissionUpdates: WorkflowsPermissions = [...permissions, ...toBeDeletedPermissionUpdates];

try {
await Ajax(signal).Methods.method(namespace, name, selectedSnapshot).setPermissions(permissionUpdates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import _ from 'lodash/fp';
import React from 'react';
import { MethodResponse } from 'src/libs/ajax/methods/methods-models';
import { CreateMethodProvider } from 'src/libs/ajax/methods/providers/CreateMethodProvider';
import { WorkflowModal } from 'src/pages/workflows/workflow/common/WorkflowModal';
import { renderWithAppContexts as render } from 'src/testing/test-utils';
import { WorkflowModal } from 'src/workflows/methods/modals/WorkflowModal';

type WDLEditorExports = typeof import('src/pages/workflows/common/WDLEditor');
jest.mock('src/pages/workflows/common/WDLEditor', (): WDLEditorExports => {
const mockWDLEditorModule = jest.requireActual('src/pages/workflows/common/WDLEditor.mock');
type WDLEditorExports = typeof import('src/workflows/methods/WDLEditor');
jest.mock('src/workflows/methods/WDLEditor', (): WDLEditorExports => {
const mockWDLEditorModule = jest.requireActual('src/workflows/methods/WDLEditor.mock');
return {
WDLEditor: mockWDLEditorModule.MockWDLEditor,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import colors from 'src/libs/colors';
import { FormLabel } from 'src/libs/forms';
import * as Utils from 'src/libs/utils';
import { withBusyState } from 'src/libs/utils';
import { WDLEditor } from 'src/pages/workflows/common/WDLEditor';
import { WDLEditor } from 'src/workflows/methods/WDLEditor';
import validate from 'validate.js';

export interface WorkflowModalProps {
Expand Down
9 changes: 9 additions & 0 deletions src/workflows/methods/workflows-acl-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WorkflowUserPermissions } from 'src/libs/ajax/methods/methods-models';

export type {
WorkflowAccessLevel,
WorkflowUserPermissions,
MethodConfigACL as WorkflowsPermissions,
} from 'src/libs/ajax/methods/methods-models';

export const publicUser = ({ user }: WorkflowUserPermissions): boolean => user === 'public';
Loading