-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from kaleido-io/subscriptions
- Loading branch information
Showing
10 changed files
with
414 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ISubscription } from '../../interfaces'; | ||
import { IDataListItem } from '../../interfaces/lists'; | ||
import { FFCopyButton } from '../Buttons/CopyButton'; | ||
import { FFCircleLoader } from '../Loaders/FFCircleLoader'; | ||
import { FFListItem } from './FFListItem'; | ||
import { FFListText } from './FFListText'; | ||
import { FFListTimestamp } from './FFListTimestamp'; | ||
import { FFSkeletonList } from './FFSkeletonList'; | ||
|
||
interface Props { | ||
sub?: ISubscription; | ||
} | ||
|
||
export const SubList: React.FC<Props> = ({ sub }) => { | ||
const { t } = useTranslation(); | ||
const [dataList, setDataList] = useState<IDataListItem[]>(FFSkeletonList); | ||
|
||
useEffect(() => { | ||
if (sub) { | ||
setDataList([ | ||
{ | ||
label: t('id'), | ||
value: <FFListText color="primary" text={sub.id} />, | ||
button: <FFCopyButton value={sub.id} />, | ||
}, | ||
{ | ||
label: t('transport'), | ||
value: <FFListText color="primary" text={sub.transport} />, | ||
}, | ||
{ | ||
label: t('created'), | ||
value: <FFListTimestamp ts={sub.created} />, | ||
}, | ||
]); | ||
} | ||
}, [sub]); | ||
|
||
return ( | ||
<> | ||
{!sub ? ( | ||
<FFCircleLoader color="warning" /> | ||
) : ( | ||
dataList.map((d, idx) => <FFListItem key={idx} item={d} />) | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright © 2022 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import HexagonIcon from '@mui/icons-material/Hexagon'; | ||
import React, { useContext } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { ApplicationContext } from '../../contexts/ApplicationContext'; | ||
import { FF_NAV_PATHS, INavItem } from '../../interfaces'; | ||
import { NavSection } from './NavSection'; | ||
|
||
export const MyNodeNav = () => { | ||
const { t } = useTranslation(); | ||
const navigate = useNavigate(); | ||
const { selectedNamespace } = useContext(ApplicationContext); | ||
const { pathname } = useLocation(); | ||
|
||
const myNodePath = FF_NAV_PATHS.myNodePath(selectedNamespace); | ||
const myNodeSubscriptionsPath = | ||
FF_NAV_PATHS.myNodeSubscriptionsPath(selectedNamespace); | ||
|
||
const navItems: INavItem[] = [ | ||
{ | ||
name: t('dashboard'), | ||
action: () => navigate(myNodePath), | ||
itemIsActive: pathname === myNodePath, | ||
}, | ||
{ | ||
name: t('subscriptions'), | ||
action: () => navigate(myNodeSubscriptionsPath), | ||
itemIsActive: pathname === myNodeSubscriptionsPath, | ||
}, | ||
]; | ||
|
||
return ( | ||
<NavSection | ||
icon={<HexagonIcon />} | ||
navItems={navItems} | ||
title={t('myNode')} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright © 2022 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Grid } from '@mui/material'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ISubscription } from '../../interfaces'; | ||
import { DEFAULT_PADDING } from '../../theme'; | ||
import { JsonViewAccordion } from '../Accordions/JsonViewerAccordion'; | ||
import { SubList } from '../Lists/SubList'; | ||
import { DisplaySlide } from './DisplaySlide'; | ||
import { SlideHeader } from './SlideHeader'; | ||
|
||
interface Props { | ||
sub: ISubscription; | ||
open: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export const SubscriptionSlide: React.FC<Props> = ({ sub, open, onClose }) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<> | ||
<DisplaySlide open={open} onClose={onClose}> | ||
<Grid container direction="column" p={DEFAULT_PADDING}> | ||
{/* Header */} | ||
<SlideHeader subtitle={t('subscription')} title={sub.name} /> | ||
{/* Data list */} | ||
<Grid container item pb={DEFAULT_PADDING}> | ||
<SubList sub={sub} /> | ||
</Grid> | ||
|
||
{sub.filter && ( | ||
<Grid container item pb={DEFAULT_PADDING}> | ||
<JsonViewAccordion | ||
isOpen | ||
header={t('filter')} | ||
json={sub.filter} | ||
/> | ||
</Grid> | ||
)} | ||
{sub.options && ( | ||
<Grid container item> | ||
<JsonViewAccordion | ||
isOpen | ||
header={t('options')} | ||
json={sub.options} | ||
/> | ||
</Grid> | ||
)} | ||
</Grid> | ||
</DisplaySlide> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.