Skip to content

Commit

Permalink
feat: enable transfer details popup when selecting row from transfer …
Browse files Browse the repository at this point in the history
…search page (#57)

* enable transfer details popup when selecting row from transfer search page

* centre spinner for transfer details loading

* adding more transfer detail to popup

* bump minor version for feature add

* add integration test to verify detail popup is triggered on row click

* bump chart versions
  • Loading branch information
bushjames authored Sep 14, 2021
1 parent 7e09869 commit 73639a8
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 19 deletions.
4 changes: 2 additions & 2 deletions helm/finance-portal-v2-ui/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "v2.3.2"
appVersion: "v2.4.0"
description: Mojaloop Finance Portal UI v2
name: finance-portal-v2-ui
version: 2.3.2
version: 2.4.0
2 changes: 1 addition & 1 deletion helm/finance-portal-v2-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: ghcr.io/mojaloop/finance-portal-v2-ui
tag: v2.3.2
tag: v2.4.0
pullPolicy: IfNotPresent

imagePullCredentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Temporal } from '@js-temporal/polyfill';
import { t } from 'testcafe';

export type TransferRow = {
row: Selector,
id: Selector,
}

Expand All @@ -20,7 +21,10 @@ export const FindTransfersPage = {
return Array
.from({ length })
.map((_, i) => ({
row: rows.nth(i),
id: rows.nth(i).findReact('ItemCell').nth(0),
}));
},

getTransferDetailsModal: (transferId: string) => ReactSelector('Modal').withProps({ title: `Transfer Details: ${transferId}` }),
};
22 changes: 22 additions & 0 deletions integration_test/tests/src/tests/FindTransfersPage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,26 @@ test.meta({
}
});

test.meta({
ID: '',
STORY: 'MMD-1430',
description:
`Clicking on a transfer row should show a detail popup`,
})('Clicking on transfer row should show detail popup', async (t) => {
// navigate to the find transfers page
await t.click(SideMenu.findTransfersButton);

// click the find transfers button (no filters selected by default)
await t.click(FindTransfersPage.findTransfersButton);

// get all rows found
const rows = await FindTransfersPage.getResultRows();

// click the first found row
await t.click(rows[0].row);
const transferId = await rows[0].id.innerText;

const popup = FindTransfersPage.getTransferDetailsModal(transferId);

await t.expect(popup.exists).ok('Transfer details popup not found in dom');
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "finance-portal-v2-ui",
"version": "2.3.2",
"version": "2.4.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/App/Transfers/TransferDetails/TransferDetails.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.transfers__transferDetails__loader {
height: 100px;
width: 100%;
display: flex;
justify-content: center;
flex-direction: row;
}
105 changes: 95 additions & 10 deletions src/App/Transfers/TransferDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { State, Dispatch } from 'store/types';
import { TransferDetail, QuoteRequest, QuoteResponse, TransferPrepare } from '../types';
import * as actions from '../actions';
import * as selectors from '../selectors';
import './TransferDetails.css';

const stateProps = (state: State) => ({
transferDetails: selectors.getSelectedTransfer(state),
Expand Down Expand Up @@ -33,13 +34,13 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
let content = null;

content = (
<div className="transfers__transfers__loader">
<div className="transfers__transferDetails__loader">
<Spinner size={20} />
</div>
);

if (transferDetails) {
const TransferPartiesTab = (
const QuotePartiesTab = transferDetails.quoteParties.length ? (
<TabPanel>
<Tabs>
<TabList>
Expand All @@ -56,9 +57,28 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
</TabPanels>
</Tabs>
</TabPanel>
);
) : null;

const QuoteErrorsTab = transferDetails.quoteErrors.length ? (
<TabPanel>
<Tabs>
<TabList>
{transferDetails.quoteErrors.map((qe: any) => (
<Tab key={`${qe.quoteId}-${qe.quoteErrorId}`}>{qe.quoteErrorId}</Tab>
))}
</TabList>
<TabPanels>
{transferDetails.quoteErrors.map((qe: any) => (
<TabPanel key={`${qe.quoteId}-${qe.quoteErrorId}`}>
<ScrollBox>{objectToFormInputs(qe.quoteId, qe)}</ScrollBox>
</TabPanel>
))}
</TabPanels>
</Tabs>
</TabPanel>
) : null;

const QuoteRequestsTab = (
const QuoteRequestsTab = transferDetails.quoteRequests.length ? (
<TabPanel>
<Tabs>
<TabList>
Expand All @@ -73,22 +93,24 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
<TabList>
<Tab>Quote Request</Tab>
<Tab>Quote Parties</Tab>
<Tab>Quote Errors</Tab>
</TabList>
<TabPanels>
<TabPanel>
<ScrollBox>{objectToFormInputs(qr.quoteId, qr)}</ScrollBox>
</TabPanel>
{TransferPartiesTab}
<TabPanel>{QuotePartiesTab}</TabPanel>
<TabPanel>{QuoteErrorsTab}</TabPanel>
</TabPanels>
</Tabs>
</TabPanel>
))}
</TabPanels>
</Tabs>
</TabPanel>
);
) : null;

const QuoteResponsesTab = (
const QuoteResponsesTab = transferDetails.quoteResponses.length ? (
<TabPanel>
<Tabs>
<TabList>
Expand All @@ -105,9 +127,9 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
</TabPanels>
</Tabs>
</TabPanel>
);
) : null;

const TransferPreparesTab = (
const TransferPreparesTab = transferDetails.transferPrepares.length ? (
<TabPanel>
<Tabs>
<TabList>
Expand All @@ -124,7 +146,64 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
</TabPanels>
</Tabs>
</TabPanel>
);
) : null;

const TransferParticipantsTab = transferDetails.transferParticipants.length ? (
<TabPanel>
<Tabs>
<TabList>
{transferDetails.transferParticipants.map((tp: any) => (
<Tab key={tp.transferParticipantId}>{tp.transferParticipantId}</Tab>
))}
</TabList>
<TabPanels>
{transferDetails.transferParticipants.map((tp: any) => (
<TabPanel key={tp.transferParticipantId}>
<ScrollBox>{objectToFormInputs(tp.transferParticipantId, tp)}</ScrollBox>
</TabPanel>
))}
</TabPanels>
</Tabs>
</TabPanel>
) : null;

const TransferFulfilmentsTab = transferDetails.transferFulfilments.length ? (
<TabPanel>
<Tabs>
<TabList>
{transferDetails.transferFulfilments.map((tf: any) => (
<Tab key={tf.transferId}>{tf.transferId}</Tab>
))}
</TabList>
<TabPanels>
{transferDetails.transferFulfilments.map((tf: any) => (
<TabPanel key={tf.transferId}>
<ScrollBox>{objectToFormInputs(tf.transferId, tf)}</ScrollBox>
</TabPanel>
))}
</TabPanels>
</Tabs>
</TabPanel>
) : null;

const TransferStateChangesTab = transferDetails.transferStateChanges.length ? (
<TabPanel>
<Tabs>
<TabList>
{transferDetails.transferStateChanges.map((tsc: any) => (
<Tab key={tsc.transferStateChangeId}>{tsc.transferStateChangeId}</Tab>
))}
</TabList>
<TabPanels>
{transferDetails.transferStateChanges.map((tsc: any) => (
<TabPanel key={tsc.transferStateChangeId}>
<ScrollBox>{objectToFormInputs(tsc.transferStateChangeId, tsc)}</ScrollBox>
</TabPanel>
))}
</TabPanels>
</Tabs>
</TabPanel>
) : null;

content = (
<div>
Expand All @@ -133,11 +212,17 @@ const TransferDetails: FC<ConnectorProps> = ({ transferDetails, onModalCloseClic
<Tab>Quote Requests</Tab>
<Tab>Quote Responses</Tab>
<Tab>Transfer Prepares</Tab>
<Tab>Transfer Participants</Tab>
<Tab>Transfer Fulfilments</Tab>
<Tab>Transfer State Changes</Tab>
</TabList>
<TabPanels>
<TabPanel>{QuoteRequestsTab}</TabPanel>
<TabPanel>{QuoteResponsesTab}</TabPanel>
<TabPanel>{TransferPreparesTab}</TabPanel>
<TabPanel>{TransferParticipantsTab}</TabPanel>
<TabPanel>{TransferFulfilmentsTab}</TabPanel>
<TabPanel>{TransferStateChangesTab}</TabPanel>
</TabPanels>
</Tabs>
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/App/Transfers/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const initialState: types.TransfersState = {
to: undefined,
},
isTransfersPending: false,
isTransferDetailsPending: true,
isTransferDetailsPending: false,
};

export default createReducer(initialState, (builder) =>
Expand Down Expand Up @@ -62,10 +62,16 @@ export default createReducer(initialState, (builder) =>
(state: types.TransfersState, action: PayloadAction<types.TransferDetail>) => ({
...state,
selectedTransfer: action.payload,
isTransferDetailsPending: false,
}),
)
.addCase(actions.transferDetailsModalClose, (state: types.TransfersState) => ({
...state,
selectedTransfer: initialState.selectedTransfer,
isTransferDetailsPending: false,
}))
.addCase(actions.selectTransfer, (state: types.TransfersState) => ({
...state,
isTransferDetailsPending: true,
})),
);
1 change: 1 addition & 0 deletions src/App/Transfers/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export const getTransfers = (state: State) => state.subApp.transfers.transfers;
export const getTransfersError = (state: State) => state.subApp.transfers.transfersError;
export const getIsTransfersPending = (state: State) => state.subApp.transfers.isTransfersPending;
export const getTransfersFilter = (state: State) => state.subApp.transfers.transfersFilter;
export const getIsTransferDetailsPending = (state: State) => state.subApp.transfers.isTransferDetailsPending;
15 changes: 11 additions & 4 deletions src/App/Transfers/views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Heading, Button, MessageBox, Spinner, DataList, DatePicker, TextField,
import { connect } from 'react-redux';
import withMount from 'hocs';
import { State, Dispatch } from 'store/types';
import { TransfersFilter, FilterChangeValue, Transfer } from './types';
import { TransfersFilter, FilterChangeValue, Transfer, TransferDetail } from './types';
import * as actions from './actions';
import * as selectors from './selectors';
import './Transfers.css';
Expand Down Expand Up @@ -93,11 +93,12 @@ const IDTypes = [
];

const stateProps = (state: State) => ({
// selectedTransfer: selectors.getSelectedTransfer(state),
selectedTransfer: selectors.getSelectedTransfer(state),
transfers: selectors.getTransfers(state),
transfersError: selectors.getTransfersError(state),
isTransfersPending: selectors.getIsTransfersPending(state),
filtersModel: selectors.getTransfersFilter(state),
isTransferDetailsPending: selectors.getIsTransferDetailsPending(state),
});

const dispatchProps = (dispatch: Dispatch) => ({
Expand All @@ -109,10 +110,11 @@ const dispatchProps = (dispatch: Dispatch) => ({
});

interface ConnectorProps {
// selectedTransfer: TransferDetail | undefined;
selectedTransfer: TransferDetail | undefined;
transfers: Transfer[];
transfersError: string | null;
isTransfersPending: boolean;
isTransferDetailsPending: boolean;
filtersModel: TransfersFilter;
onFindTransfersClick: () => void;
onClearFiltersClick: () => void;
Expand All @@ -121,10 +123,11 @@ interface ConnectorProps {
}

const Transfers: FC<ConnectorProps> = ({
// selectedTransfer,
selectedTransfer,
transfers,
transfersError,
isTransfersPending,
isTransferDetailsPending,
filtersModel,
onFindTransfersClick,
onClearFiltersClick,
Expand Down Expand Up @@ -166,6 +169,10 @@ const Transfers: FC<ConnectorProps> = ({
);
}

if (isTransferDetailsPending || selectedTransfer) {
detailModal = <TransferDetailsModal />;
}

return (
<div className="transfers">
<Heading size="3">Find Transfers</Heading>
Expand Down

0 comments on commit 73639a8

Please sign in to comment.