Skip to content

Commit 6196803

Browse files
Merge pull request #4037 from JoinColony/feat/16220651-navigation-streaming-payments
Feat/16220651 navigation streaming payments
2 parents c4bb5ec + 213c22d commit 6196803

File tree

7 files changed

+75
-16
lines changed

7 files changed

+75
-16
lines changed

src/components/frame/v5/pages/StreamingPaymentsPage/StreamingPaymentsPage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import StatsCards from './partials/StatsCards/StatsCards.tsx';
1212
const displayName = 'v5.pages.StreamingPaymentsPage';
1313

1414
const StreamingPaymentsPage = () => {
15-
useSetPageHeadingTitle(
16-
formatText({ id: 'navigation.finances.streamingPayments' }),
17-
);
15+
useSetPageHeadingTitle(formatText({ id: 'streamingPaymentsPage.title' }));
1816

1917
const nativeDomainId = useGetSelectedDomainFilter()?.nativeId;
2018

src/components/v5/common/ActionSidebar/partials/PaymentGroup/GroupList.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ArrowsOutLineHorizontal,
88
// @TODO: uncomment when staged payment is ready
99
Steps,
10+
Waves,
1011
type Icon,
1112
} from '@phosphor-icons/react';
1213

@@ -40,16 +41,15 @@ export const GROUP_LIST: GroupListItem[] = [
4041
action: Action.PaymentBuilder,
4142
isNew: true,
4243
},
43-
// @TODO: uncomment when streaming payment is ready
44-
// {
45-
// title: formatText({ id: 'actions.streamingPayment' }),
46-
// description: formatText({
47-
// id: 'actions.description.streamingPayment',
48-
// }),
49-
// Icon: Waves,
50-
// action: Action.StreamingPayment,
51-
// isNew: true,
52-
// },
44+
{
45+
title: formatText({ id: 'actions.streamingPayment' }),
46+
description: formatText({
47+
id: 'actions.description.streamingPayment',
48+
}),
49+
Icon: Waves,
50+
action: Action.StreamingPayment,
51+
isNew: true,
52+
},
5353
{
5454
title: formatText({ id: 'actions.splitPayment' }),
5555
description: formatText({ id: 'actions.description.splitPayment' }),

src/components/v5/shared/Navigation/Sidebar/sidebars/ColonyPageSidebar/consts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
COLONY_INCOMING_ROUTE,
2020
COLONY_PERMISSIONS_ROUTE,
2121
COLONY_TEAMS_ROUTE,
22+
COLONY_STREAMING_PAYMENTS_ROUTE,
2223
} from '~routes';
2324
import { type SidebarRouteItemProps } from '~v5/shared/Navigation/Sidebar/partials/SidebarRouteItem/types.ts';
2425

@@ -51,6 +52,11 @@ export const sidebarNavigationScheme: SidebarRouteItemProps[] = [
5152
path: COLONY_INCOMING_ROUTE,
5253
isColonyRoute: true,
5354
},
55+
{
56+
translation: { id: 'navigation.finances.streamingPayments' },
57+
path: COLONY_STREAMING_PAYMENTS_ROUTE,
58+
isColonyRoute: true,
59+
},
5460
// @TODO: Uncomment once these pages are available
5561
// {
5662
// id: 'streaming',

src/components/v5/shared/Navigation/Sidebar/sidebars/ColonyPageSidebar/partials/SidebarRoutesSection.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import React from 'react';
22

33
import SidebarRouteItem from '~v5/shared/Navigation/Sidebar/partials/SidebarRouteItem/index.ts';
44

5-
import { sidebarNavigationScheme } from '../consts.ts';
5+
import { useSidebarRoutesScheme } from './hooks.ts';
66

77
export const SidebarRoutesSection = () => {
8+
const { sidebarScheme: sidebarNavigationScheme } = useSidebarRoutesScheme();
9+
810
return (
911
<section className="flex w-full flex-col gap-0 md:gap-0.5">
1012
{sidebarNavigationScheme.map((scheme) => (
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Extension } from '@colony/colony-js';
2+
3+
import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
4+
import { useSearchActionsQuery } from '~gql';
5+
import useExtensionData from '~hooks/useExtensionData.ts';
6+
import { COLONY_STREAMING_PAYMENTS_ROUTE } from '~routes';
7+
import { isInstalledExtensionData } from '~utils/extensions.ts';
8+
9+
import { sidebarNavigationScheme } from '../consts.ts';
10+
11+
export const useSidebarRoutesScheme = () => {
12+
const { colony } = useColonyContext();
13+
14+
const { colonyAddress } = colony;
15+
16+
const { data } = useSearchActionsQuery({
17+
variables: {
18+
filter: {
19+
colonyId: { eq: colonyAddress },
20+
type: { eq: 'CREATE_STREAMING_PAYMENT' },
21+
},
22+
limit: 5,
23+
},
24+
});
25+
26+
const excludeSubitemsPaths = (subitemsPathsToExclude: string[]) =>
27+
sidebarNavigationScheme.map((item) => {
28+
return {
29+
...item,
30+
subItems: item.subItems?.filter(
31+
(subItem) => !subitemsPathsToExclude.includes(subItem.path),
32+
),
33+
};
34+
});
35+
36+
const hasStreamings = !!data?.searchColonyActions?.items.length;
37+
38+
const { extensionData } = useExtensionData(Extension.StreamingPayments);
39+
const isStreamingPaymentsInstalled =
40+
extensionData && isInstalledExtensionData(extensionData);
41+
42+
const isStreamingsRouteVisible =
43+
isStreamingPaymentsInstalled || hasStreamings;
44+
45+
const sidebarScheme = excludeSubitemsPaths(
46+
isStreamingsRouteVisible ? [] : [COLONY_STREAMING_PAYMENTS_ROUTE],
47+
);
48+
49+
return {
50+
sidebarScheme,
51+
};
52+
};

src/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"navigation.finances.incoming": "Incoming",
3333
"navigation.finances.incomingFunds": "Incoming funds",
3434
"navigation.finances.transactions": "Transactions",
35-
"navigation.finances.streamingPayments": "Streaming payments",
35+
"navigation.finances.streamingPayments": "Streaming",
3636
"navigation.agreements": "Agreements",
3737
"navigation.agreements.title": "Agreements",
3838
"navigation.agreements.description": "The latest decisions and discussions created within the Colony.",
@@ -1965,6 +1965,7 @@
19651965
"form.max": "{fieldName} must be a maximum of {length} characters",
19661966
"multiSig.rejectAction": "Reject action",
19671967
"multiSig.shareAction": "Share action",
1968+
"streamingPaymentsPage.title": "Streaming payments",
19681969
"streamingPayment.description.placeholder": "Streaming Payment to a single recipient by {initiator}",
19691970
"streamingPayment.description.days": "{days} {days, plural, =1 {day} other {days}}",
19701971
"streamingPayment.status.active": "Active",

src/routes/routeConstants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const COLONY_EXTENSION_DETAILS_ROUTE = `${COLONY_EXTENSIONS_ROUTE}/:exten
2525
export const COLONY_INCOMING_ROUTE = `incoming`;
2626
export const COLONY_BALANCES_ROUTE = `balances`;
2727
export const COLONY_FOLLOWERS_ROUTE = `members/followers`;
28-
export const COLONY_STREAMING_PAYMENTS_ROUTE = `streaming-payments`;
28+
export const COLONY_STREAMING_PAYMENTS_ROUTE = `streaming`;
2929
export const COLONY_MEMBERS_ROUTE = `members`;
3030
export const COLONY_MEMBERS_WITH_DOMAIN_ROUTE = `members/:domainId`;
3131
export const COLONY_VERIFIED_ROUTE = `verified`;

0 commit comments

Comments
 (0)