Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit cd6faf1

Browse files
authored
Pending request and process request notifications (#388)
* move requests to notifications * improve typing * hold off on auction requests * add notification menu header * issue with invalid rrequests * limit account operations to owner * clean * clean * clean * compile error * add auction requests * use lodash lib partition function
1 parent e84d5c8 commit cd6faf1

File tree

15 files changed

+509
-303
lines changed

15 files changed

+509
-303
lines changed

ui/src/App.tsx

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { Route, RouteProps, Switch, useLocation, withRouter } from 'react-router-dom';
33
import { SidebarEntry } from './components/Sidebar/SidebarEntry';
4-
import { Requests as CustodyRequests } from './pages/custody/Requests';
54
import { useParty } from '@daml/react';
65
import { Service as CustodyService } from '@daml.js/da-marketplace/lib/Marketplace/Custody/Service/';
76
import { Service as ClearingService } from '@daml.js/da-marketplace/lib/Marketplace/Clearing/Service/';
@@ -14,7 +13,6 @@ import { Role as CustodyRole } from '@daml.js/da-marketplace/lib/Marketplace/Cus
1413
import { Role as ClearingRole } from '@daml.js/da-marketplace/lib/Marketplace/Clearing/Role';
1514

1615
import { Auctions } from './pages/distribution/auction/Auctions';
17-
import { Requests as AuctionRequests } from './pages/distribution/auction/Requests';
1816
import Assets from './pages/custody/Assets';
1917
import { New as NewAuction } from './pages/distribution/auction/New';
2018
import { BiddingAuction } from './pages/distribution/bidding/Auction';
@@ -38,7 +36,6 @@ import {
3836
MegaphoneIcon,
3937
OrdersIcon,
4038
WalletIcon,
41-
IconMailLetter,
4239
} from './icons/icons';
4340
import { Instrument } from './pages/origination/Instrument';
4441
import { ClearingMembers } from './pages/clearing/Members';
@@ -318,16 +315,15 @@ const AppComponent = () => {
318315
],
319316
});
320317

321-
const notifications = useAllNotifications(party);
322-
const notifCount = notifications.reduce((count, { contracts }) => count + contracts.length, 0);
318+
const allNotifications = useAllNotifications(party);
323319

324320
entries.push({
325321
displayEntry: () => true,
326322
sidebar: [],
327323
additionalRoutes: [
328324
{
329325
path: paths.app.notifications,
330-
render: () => <Notifications notifications={notifications} />,
326+
render: () => <Notifications notifications={allNotifications} />,
331327
},
332328
{
333329
path: paths.app.identity,
@@ -428,25 +424,6 @@ const AppComponent = () => {
428424
],
429425
});
430426

431-
entries.push({
432-
displayEntry: () => custodyService.length > 0 || auctionCustomer.length > 0,
433-
sidebar: [
434-
{
435-
label: 'Requests',
436-
groupBy: 'Manage',
437-
path: paths.app.requests,
438-
render: () => (
439-
<>
440-
{custodyService.length > 0 && <CustodyRequests services={custodyService} />}
441-
{auctionCustomer.length > 0 && <AuctionRequests services={auctionService} />}
442-
</>
443-
),
444-
icon: <IconMailLetter />,
445-
children: [],
446-
},
447-
],
448-
});
449-
450427
const entriesToDisplay = entries.filter(e => e.displayEntry()).flatMap(e => e.sidebar);
451428
const additionRouting: RouteProps[] = _.compact(
452429
entries.filter(e => e.displayEntry()).flatMap(e => e.additionalRoutes)
@@ -476,7 +453,6 @@ const AppComponent = () => {
476453
)
477454
}
478455
topMenuButtons={currentEntry && currentEntry.topMenuButtons}
479-
showNotificationAlert={notifCount > 0}
480456
>
481457
{servicesLoading ? (
482458
<div className="page-loading">

ui/src/components/Form/ModalFormErrorHandled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ const ModalFormErrorHandled: (props: Props) => React.ReactElement = ({
7979
)}
8080
</Modal.Content>
8181
<Modal.Actions>
82+
<Button className="ghost" disabled={disabled} content="Submit" loading={loading} />
8283
<Button className="ghost warning" onClick={() => setOpen(false)}>
8384
Cancel
8485
</Button>
85-
<Button className="ghost" disabled={disabled} content="Submit" loading={loading} />
8686
</Modal.Actions>
8787
</Modal>
8888
);

ui/src/pages/QuickSetup/AccountSelectionModal.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ const AccountSelectionModal: React.FC<Props> = ({
156156
)}
157157
</Modal.Content>
158158
<Modal.Actions>
159+
<Button
160+
disabled={disabled}
161+
content="Submit"
162+
labelPosition="right"
163+
icon="checkmark"
164+
type="submit"
165+
positive
166+
/>
159167
<Button
160168
className="ghost warning"
161169
color="black"
@@ -166,14 +174,6 @@ const AccountSelectionModal: React.FC<Props> = ({
166174
>
167175
Cancel
168176
</Button>
169-
<Button
170-
disabled={disabled}
171-
content="Submit"
172-
labelPosition="right"
173-
icon="checkmark"
174-
type="submit"
175-
positive
176-
/>
177177
</Modal.Actions>
178178
</Modal>
179179
);

ui/src/pages/custody/Account.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
p.p2 {
6363
margin: $spacing-s $spacing-m 0 0;
6464
}
65+
66+
.close-request {
67+
margin-left: auto;
68+
}
6569
}
6670
}
6771
}

ui/src/pages/custody/Account.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { AssetDeposit } from '@daml.js/da-marketplace/lib/DA/Finance/Asset';
77
import { Account as AccountContract } from '@daml.js/da-marketplace/lib/DA/Finance/Types';
88
import { CreateEvent } from '@daml/ledger';
99
import { Service } from '@daml.js/da-marketplace/lib/Marketplace/Custody/Service';
10+
import { CloseAccountRequest } from '@daml.js/da-marketplace/lib/Marketplace/Custody/Model';
11+
1012
import { InputDialog, InputDialogProps } from '../../components/InputDialog/InputDialog';
1113
import { usePartyName } from '../../config';
1214
import Tile from '../../components/Tile/Tile';
@@ -37,6 +39,9 @@ const Account: React.FC<ServicePageProps<Service> & AccountProps> = ({
3739
const { contracts: allocatedAccounts, loading: allocatedAccountsLoading } =
3840
useStreamQueries(AllocationAccountRule);
3941
const { contracts: deposits, loading: depositsLoading } = useStreamQueries(AssetDeposit);
42+
const existingCloseRequest = !!useStreamQueries(CloseAccountRequest).contracts.find(
43+
c => c.payload.accountId.label === targetAccount.account.id.label
44+
);
4045

4146
const defaultTransferRequestDialogProps: InputDialogProps<any> = {
4247
open: false,
@@ -137,14 +142,20 @@ const Account: React.FC<ServicePageProps<Service> & AccountProps> = ({
137142
<div className="account-details">
138143
<div className="account-data">
139144
<h4> {targetAccount.account.id.label} </h4>
140-
{normalAccount && (
141-
<OverflowMenu>
142-
<OverflowMenuEntry
143-
label={'Close Account'}
144-
onClick={() => requestCloseAccount(normalAccount)}
145-
/>
146-
</OverflowMenu>
147-
)}
145+
{normalAccount &&
146+
targetAccount.account.owner === party &&
147+
(existingCloseRequest ? (
148+
<p className="close-request">
149+
<i> close request pending</i>
150+
</p>
151+
) : (
152+
<OverflowMenu>
153+
<OverflowMenuEntry
154+
label={'Close Account'}
155+
onClick={() => requestCloseAccount(normalAccount)}
156+
/>
157+
</OverflowMenu>
158+
))}
148159
</div>
149160
<div className="account-data body">
150161
<p className="p2">Type: {normalAccount ? 'Normal' : 'Allocation'} </p>

ui/src/pages/custody/Assets.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const Assets: React.FC<ServicePageProps<Service>> = ({ services }: ServicePagePr
8282
<div className="page-section-row">
8383
<div>
8484
{allAccounts.map(a => (
85-
<Account targetAccount={a} services={services} key={a.contractId} />
85+
<Account key={a.contractId} targetAccount={a} services={services} />
8686
))}
8787
</div>
8888

@@ -91,9 +91,14 @@ const Assets: React.FC<ServicePageProps<Service>> = ({ services }: ServicePagePr
9191
<FormErrorHandled onSubmit={() => onRequestCredit()}>
9292
<Form.Select
9393
label="Account"
94-
options={allAccounts.map(a => {
95-
return { text: a.account.id.label, value: a.contractId };
96-
})}
94+
options={accounts
95+
.filter(a => a.payload.account.owner === party)
96+
.map(a => {
97+
return {
98+
text: a.payload.account.id.label,
99+
value: a.contractId.replace('#', '_'),
100+
};
101+
})}
97102
value={selectedAccount}
98103
onChange={(_, data) => setSelectedAccount(data.value as string)}
99104
/>

0 commit comments

Comments
 (0)