Skip to content

Commit

Permalink
Merge pull request Ferlab-Ste-Justine#389 from Ferlab-Ste-Justine/fix…
Browse files Browse the repository at this point in the history
…/SKFP-895/cavatica-notif

fix(cavatica): SKFP-895 fix cavatica error message
  • Loading branch information
lflangis authored Feb 15, 2024
2 parents d8ad812 + b690a14 commit 6c3379e
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 217 deletions.
3 changes: 3 additions & 0 deletions packages/ui/Release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 9.0.1 2024-02-14
- fix: SKFP-895 fix cavatica error message

### 9.0.0 2024-02-09
- fix: SKFP-924 fix link redirection with react-router v6

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/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/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ferlab/ui",
"version": "9.0.0",
"version": "9.0.1",
"description": "Core components for scientific research data portals",
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const AuthorizedStudiesListItem = ({
<div className={styles.filesCount}>
<Space size={4}>
<span>{dictionary.authorization}</span>
<Link
<a
href={queryProps.to}
onClick={() => {
addQuery({
query: generateQuery({
Expand All @@ -77,14 +78,14 @@ const AuthorizedStudiesListItem = ({
setAsActive: true,
});
}}
to={queryProps.to}
>
<Button className={styles.fileLink} type="link">
<span>{numberWithCommas(authorizedAndUncontrolledFilesCount)}</span>
</Button>
</Link>
</a>
<span className={styles.of}>{dictionary.of}</span>
<Link
<a
href={queryProps.to}
onClick={() => {
addQuery({
query: generateQuery({
Expand All @@ -100,12 +101,11 @@ const AuthorizedStudiesListItem = ({
setAsActive: true,
});
}}
to={queryProps.to}
>
<Button className={styles.fileLink} type="link">
<span>{numberWithCommas(data.total_files_count)}</span>
</Button>
</Link>
</a>
<span>{dictionary.files}</span>
</Space>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,29 @@ describe('Cavatica Analyse', () => {
loading: true,
},
},
createProjectModalProps: {
cavatica: {
billingGroups: {
data: [],
error: true,
loading: false,
},
projects: {
data: [],
error: false,
loading: true,
},
},
fetchBillingGroups: jest.fn(),
fetchProjects: jest.fn(),
handleCloseModal: jest.fn(),
handleErrorModalReset: jest.fn(),
handleSubmit: jest.fn(),
onCancel: jest.fn(),
},
dictionary,
handleBeginAnalyse: jest.fn(),
handleConnection: jest.fn(),
handleCreateProject: jest.fn(),
handleFilesAndFolders: jest.fn(),
handleImportBulkData: jest.fn(),
handleResetErrors: jest.fn(),
Expand Down Expand Up @@ -77,10 +96,29 @@ describe('Cavatica Analyse', () => {
loading: true,
},
},
createProjectModalProps: {
cavatica: {
billingGroups: {
data: [],
error: true,
loading: false,
},
projects: {
data: [],
error: false,
loading: true,
},
},
fetchBillingGroups: jest.fn(),
fetchProjects: jest.fn(),
handleCloseModal: jest.fn(),
handleErrorModalReset: jest.fn(),
handleSubmit: jest.fn(),
onCancel: jest.fn(),
},
dictionary,
handleBeginAnalyse: jest.fn(),
handleConnection: jest.fn(),
handleCreateProject: jest.fn(),
handleFilesAndFolders: jest.fn(),
handleImportBulkData: jest.fn(),
handleResetErrors: jest.fn(),
Expand Down Expand Up @@ -125,10 +163,29 @@ describe('Cavatica Analyse', () => {
loading: true,
},
},
createProjectModalProps: {
cavatica: {
billingGroups: {
data: [],
error: true,
loading: false,
},
projects: {
data: [],
error: false,
loading: true,
},
},
fetchBillingGroups: jest.fn(),
fetchProjects: jest.fn(),
handleCloseModal: jest.fn(),
handleErrorModalReset: jest.fn(),
handleSubmit: jest.fn(),
onCancel: jest.fn(),
},
dictionary,
handleBeginAnalyse: jest.fn(),
handleConnection: jest.fn(),
handleCreateProject: jest.fn(),
handleFilesAndFolders: jest.fn(),
handleImportBulkData: jest.fn(),
handleResetErrors: jest.fn(),
Expand Down
43 changes: 7 additions & 36 deletions packages/ui/src/components/Widgets/Cavatica/CavaticaAnalyse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import CavaticaAnalyseModal, {
ICavaticaTreeNode,
TCavaticaAnalyseModalDictionary,
} from './CavaticaAnalyzeModal';
import CavaticaCreateProjectModal, {
import {
DEFAULT_CAVATICA_CREATE_PROJECT_MODAL_DICTIONARY,
ICavaticaCreateProjectModal,
TCavaticaCreateProjectModalDictionary,
} from './CavaticaCreateProjectModal';
import CavaticaCreateProjectModal from './CavaticaCreateProjectModal';
import {
CAVATICA_ANALYSE_STATUS,
IBillingGroups,
Expand All @@ -28,18 +30,12 @@ enum ModalState {
connection_needed = 'connection_needed',
unauthorized_error = 'unauthorized',
fetch_project_error = 'fetch_project_error',
create_project_error = 'create_project_error',
upload_limit_reached_error = 'upload_limit_reached_error',
billing_groups_error = 'billing_groups_error',
generic_error = 'generic_error',
}

export const DEFAULT_CAVATICA_ANALYSE_DICTIONARY: TCavaticaAnalyseDictionary = {
analyseModal: DEFAULT_CAVATICA_ANALYSE_MODAL_DICTIONARY,
billingGroupsErrorModal: {
description: 'Unable to fetch your cavatica projects.',
title: 'Error',
},
buttonText: 'Analyze in Cavatica',
connectionRequiredModal: {
description:
Expand All @@ -52,10 +48,6 @@ export const DEFAULT_CAVATICA_ANALYSE_DICTIONARY: TCavaticaAnalyseDictionary = {
description: 'Unable to fetch selected files',
title: 'Error',
},
projectCreateErrorModal: {
description: 'Unable to fetch your cavatica projects.',
title: 'Error',
},
projectFetchErrorModal: {
description: 'Unable to fetch your cavatica projects.',
title: 'Error',
Expand Down Expand Up @@ -85,14 +77,6 @@ export type TCavaticaAnalyseDictionary = {
title: string;
description: string;
};
billingGroupsErrorModal: {
title: string;
description: string;
};
projectCreateErrorModal: {
title: string;
description: string;
};
projectFetchErrorModal: {
title: string;
description: string;
Expand All @@ -113,8 +97,8 @@ export interface ICavaticaAnalyse extends BaseButtonProps {
handleFilesAndFolders: (parentId: string, isProject: boolean) => any;
handleConnection: () => void;
setCavaticaBulkImportDataStatus: (status: CAVATICA_ANALYSE_STATUS) => void;
handleCreateProject: (values: any) => void;
handleResetErrors: () => void;
createProjectModalProps: ICavaticaCreateProjectModal;
handleImportBulkData: (value: ICavaticaTreeNode) => void;
cavatica: {
authentification: ICavaticaAuthentification;
Expand All @@ -127,16 +111,6 @@ export interface ICavaticaAnalyse extends BaseButtonProps {

const getErrorModalTileAndDescription = (modalState: ModalState, dictionary: TCavaticaAnalyseDictionary) => {
switch (modalState) {
case ModalState.billing_groups_error:
return {
content: dictionary.billingGroupsErrorModal?.description,
title: dictionary.billingGroupsErrorModal?.title,
};
case ModalState.create_project_error:
return {
content: dictionary.projectCreateErrorModal?.description,
title: dictionary.projectCreateErrorModal?.title,
};
case ModalState.fetch_project_error:
return {
content: dictionary.projectFetchErrorModal?.description,
Expand All @@ -159,10 +133,10 @@ const getErrorModalTileAndDescription = (modalState: ModalState, dictionary: TCa

const CavaticaAnalyse = ({
cavatica,
createProjectModalProps,
dictionary = DEFAULT_CAVATICA_ANALYSE_DICTIONARY,
handleBeginAnalyse,
handleConnection,
handleCreateProject,
handleFilesAndFolders,
handleImportBulkData,
handleResetErrors,
Expand Down Expand Up @@ -268,16 +242,13 @@ const CavaticaAnalyse = ({
/>

<CavaticaCreateProjectModal
billingGroups={cavatica.billingGroups}
dictionary={dictionary.createProjectModal}
handleSubmit={(values) => {
handleCreateProject(values);
setModalState(ModalState.analyse);
}}
handleCloseModal={onResetModal}
onCancel={() => {
setModalState(ModalState.analyse);
}}
open={modalState === ModalState.createProject}
{...createProjectModalProps}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
}
}

.modalSubtitle {
margin-right: 4px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@ import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { fireEvent, getByText, render, screen } from '@testing-library/react';

import CavaticaCreateProjectModal, {
DEFAULT_CAVATICA_CREATE_PROJECT_MODAL_DICTIONARY,
} from './CavaticaCreateProjectModal';
import { DEFAULT_CAVATICA_CREATE_PROJECT_MODAL_DICTIONARY } from './CavaticaCreateProjectModal';
import CavaticaCreateProjectModal from './CavaticaCreateProjectModal';

const dictionary = DEFAULT_CAVATICA_CREATE_PROJECT_MODAL_DICTIONARY;

describe('CavaticaCreateProjectModal', () => {
test('make sure CavaticaCreateProjectModal render correctly with empty billing groups', () => {
const props = {
billingGroups: {
data: [],
loading: false,
cavatica: {
billingGroups: {
data: [],
loading: false,
},
projects: {
data: [],
loading: false,
},
},
dictionary,
fetchBillingGroups: jest.fn(),
fetchProjects: jest.fn(),
handleCloseModal: jest.fn(),
handleErrorModalReset: jest.fn(),
handleSubmit: jest.fn(),
onCancel: jest.fn(),
open: true,
Expand All @@ -35,22 +44,32 @@ describe('CavaticaCreateProjectModal', () => {

test('make sure CavaticaCreateProjectModal render correctly with billing groups', () => {
const props = {
billingGroups: {
data: [
{
href: 'href',
id: 'id',
name: 'Pilot Funds (mock)',
},
{
href: 'href',
id: 'id2',
name: 'Pilot Funds 2 (mock)',
},
],
loading: false,
cavatica: {
billingGroups: {
data: [
{
href: 'href',
id: 'id',
name: 'Pilot Funds (mock)',
},
{
href: 'href',
id: 'id2',
name: 'Pilot Funds 2 (mock)',
},
],
loading: false,
},
projects: {
data: [],
loading: false,
},
},
dictionary,
fetchBillingGroups: jest.fn(),
fetchProjects: jest.fn(),
handleCloseModal: jest.fn(),
handleErrorModalReset: jest.fn(),
handleSubmit: jest.fn(),
open: true,
};
Expand Down
Loading

0 comments on commit 6c3379e

Please sign in to comment.