Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEN-1730]: add "describe odigos" to UI #1988

Merged
merged 25 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b21d3c7
feat: add edged node
BenElferink Dec 12, 2024
5a93abf
fix: remove log
BenElferink Dec 12, 2024
af6fac3
feat: add "describe source" to UI
BenElferink Dec 12, 2024
ad1a6db
chore: cleanup
BenElferink Dec 12, 2024
8b0cda6
feat: flatten objects in code component
BenElferink Dec 12, 2024
dd0c394
Merge branch 'gen-2006' of https://github.com/BenElferink/odigos into…
BenElferink Dec 13, 2024
9b60362
feat: add "describe odigos" to UI
BenElferink Dec 13, 2024
caecc50
fix: code wrapping
BenElferink Dec 13, 2024
29add2f
Merge branch 'gen-1729' of https://github.com/BenElferink/odigos into…
BenElferink Dec 13, 2024
3240a68
Merge branch 'main' into gen-1729
BenElferink Dec 13, 2024
77dbdc1
Merge branch 'main' of https://github.com/odigos-io/odigos into gen-1730
BenElferink Dec 13, 2024
c03dd0d
Merge branch 'main' into gen-1729
BenElferink Dec 14, 2024
10f1254
fix: font like in Figma
BenElferink Dec 15, 2024
d195631
fix: polling for describe source
BenElferink Dec 15, 2024
586c943
Merge branch 'gen-1729' of https://github.com/BenElferink/odigos into…
BenElferink Dec 15, 2024
f379f90
feat: polling for describe odigos
BenElferink Dec 15, 2024
ac8a61a
fix: change polling method for metrics
BenElferink Dec 15, 2024
c943e66
fix: code review
BenElferink Dec 15, 2024
a6f9052
fix: code review
BenElferink Dec 15, 2024
7d94a8b
Merge branch 'main' into gen-1729
BenElferink Dec 15, 2024
c3956dd
Merge branch 'main' of https://github.com/odigos-io/odigos into gen-1730
BenElferink Dec 15, 2024
e753030
Merge branch 'gen-1729' of https://github.com/BenElferink/odigos into…
BenElferink Dec 15, 2024
5e594a8
Merge branch 'main' of https://github.com/odigos-io/odigos into gen-1730
BenElferink Dec 15, 2024
96bba91
fix: build error
BenElferink Dec 15, 2024
d024f38
fix: build error
BenElferink Dec 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions frontend/webapp/components/describe-odigos/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Image from 'next/image';
import theme from '@/styles/theme';
import { IconButton } from '@/reuseable-components';
import { DRAWER_OTHER_TYPES, useDrawerStore } from '@/store';

export const DescribeOdigos = () => {
const { setSelectedItem } = useDrawerStore();
const handleClick = () => setSelectedItem({ type: DRAWER_OTHER_TYPES.DESCRIBE_ODIGOS, id: DRAWER_OTHER_TYPES.DESCRIBE_ODIGOS });

return (
<IconButton onClick={handleClick} withPing pingColor={theme.colors.majestic_blue}>
<Image src='/brand/odigos-icon.svg' alt='logo' width={16} height={16} />
</IconButton>
);
};
5 changes: 3 additions & 2 deletions frontend/webapp/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './setup';
export * from './overview';
export * from './common';
export * from './describe-odigos';
export * from './main';
export * from './modals';
export * from './notification';
export * from './overview';
export * from './setup';
3 changes: 2 additions & 1 deletion frontend/webapp/components/main/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PlatformTypes } from '@/types';
import { PlatformTitle } from './cp-title';
import { useConnectionStore } from '@/store';
import { ConnectionStatus } from '@/reuseable-components';
import { NotificationManager } from '@/components/notification';
import { DescribeOdigos, NotificationManager } from '@/components';

interface MainHeaderProps {}

Expand Down Expand Up @@ -42,6 +42,7 @@ export const MainHeader: React.FC<MainHeaderProps> = () => {

<AlignRight>
<NotificationManager />
<DescribeOdigos />
</AlignRight>
</HeaderContainer>
);
Expand Down
31 changes: 3 additions & 28 deletions frontend/webapp/components/notification/notification-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,8 @@ import { useNotificationStore } from '@/store';
import { ACTION, getStatusIcon } from '@/utils';
import { useOnClickOutside, useTimeAgo } from '@/hooks';
import theme, { hexPercentValues } from '@/styles/theme';
import { NoDataFound, Text } from '@/reuseable-components';
import type { Notification, NotificationType } from '@/types';

const BellIcon = styled.div`
position: relative;
width: 36px;
height: 36px;
border-radius: 100%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
&:hover {
background-color: ${({ theme }) => theme.colors.white_opacity['008']};
}
`;

const LiveBadge = styled.div`
position: absolute;
top: 8px;
right: 8px;
width: 6px;
height: 6px;
border-radius: 100%;
background-color: ${({ theme }) => theme.colors.orange_og};
`;
import { IconButton, NoDataFound, Text } from '@/reuseable-components';

const RelativeContainer = styled.div`
position: relative;
Expand Down Expand Up @@ -106,10 +82,9 @@ export const NotificationManager = () => {

return (
<RelativeContainer ref={containerRef}>
<BellIcon onClick={toggleOpen}>
{!!unseenCount && <LiveBadge />}
<IconButton onClick={toggleOpen} withPing={!!unseenCount} pingColor={theme.colors.orange_og}>
<Image src='/icons/common/notification.svg' alt='logo' width={16} height={16} />
</BellIcon>
</IconButton>

{isOpen && (
<AbsoluteContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import styled from 'styled-components';
import { useDescribeOdigos } from '@/hooks';
import { DATA_CARDS, safeJsonStringify } from '@/utils';
import { DataCard, DataCardFieldTypes } from '@/reuseable-components';
import OverviewDrawer from '@/containers/main/overview/overview-drawer';

interface Props {}

const DataContainer = styled.div`
display: flex;
flex-direction: column;
gap: 12px;
`;

export const DescribeDrawer: React.FC<Props> = () => {
const { data: describe } = useDescribeOdigos();

return (
<OverviewDrawer title={DATA_CARDS.DESCRIBE_ODIGOS} titleTooltip='' imageUri='/brand/odigos-icon.svg'>
<DataContainer>
<DataCard
title=''
data={[
{
type: DataCardFieldTypes.CODE,
value: JSON.stringify({ language: 'json', code: safeJsonStringify(describe) }),
},
]}
/>
</DataContainer>
</OverviewDrawer>
);
};
8 changes: 6 additions & 2 deletions frontend/webapp/components/overview/all-drawers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { useDrawerStore } from '@/store';
import { OVERVIEW_ENTITY_TYPES } from '@/types';
import { DescribeDrawer } from './describe-drawer';
import { DRAWER_OTHER_TYPES, useDrawerStore } from '@/store';
import { ActionDrawer, DestinationDrawer, RuleDrawer, SourceDrawer } from '@/containers';

const AllDrawers = () => {
const selected = useDrawerStore(({ selectedItem }) => selectedItem);

if (!selected?.item) return null;
if (!selected?.type) return null;

switch (selected.type) {
case OVERVIEW_ENTITY_TYPES.RULE:
Expand All @@ -21,6 +22,9 @@ const AllDrawers = () => {
case OVERVIEW_ENTITY_TYPES.DESTINATION:
return <DestinationDrawer />;

case DRAWER_OTHER_TYPES.DESCRIBE_ODIGOS:
return <DescribeDrawer />;

default:
return <></>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export interface DrawerHeaderRef {
interface DrawerHeaderProps {
title: string;
titleTooltip?: string;
imageUri: string;
isEdit: boolean;
onEdit: () => void;
imageUri?: string;
isEdit?: boolean;
onEdit?: () => void;
onClose: () => void;
}

Expand All @@ -87,9 +87,12 @@ const DrawerHeader = forwardRef<DrawerHeaderRef, DrawerHeaderProps>(({ title, ti
return (
<HeaderContainer>
<SectionItemsWrapper>
<DrawerItemImageWrapper>
<Image src={imageUri} alt='Drawer Item' width={16} height={16} />
</DrawerItemImageWrapper>
{!!imageUri && (
<DrawerItemImageWrapper>
<Image src={imageUri} alt='Drawer Item' width={16} height={16} />
</DrawerItemImageWrapper>
)}

{!isEdit && (
<Tooltip text={titleTooltip} withIcon>
<Title>{title}</Title>
Expand All @@ -105,12 +108,13 @@ const DrawerHeader = forwardRef<DrawerHeaderRef, DrawerHeaderProps>(({ title, ti
)}

<SectionItemsWrapper $gap={8}>
{!isEdit && (
{!isEdit && !!onEdit && (
<EditButton data-id='drawer-edit' variant='tertiary' onClick={onEdit}>
<Image src='/icons/common/edit.svg' alt='Edit' width={16} height={16} />
<ButtonText>Edit</ButtonText>
</EditButton>
)}

<CloseButton data-id='drawer-close' variant='secondary' onClick={onClose}>
<Image src='/icons/common/x.svg' alt='Close' width={12} height={12} />
</CloseButton>
Expand Down
34 changes: 21 additions & 13 deletions frontend/webapp/containers/main/overview/overview-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ interface Props {
title: string;
titleTooltip?: string;
imageUri: string;
isEdit: boolean;
isFormDirty: boolean;
onEdit: (bool?: boolean) => void;
onSave: (newTitle: string) => void;
onDelete: () => void;
onCancel: () => void;
isEdit?: boolean;
isFormDirty?: boolean;
onEdit?: (bool?: boolean) => void;
onSave?: (newTitle: string) => void;
onDelete?: () => void;
onCancel?: () => void;
}

const DrawerContent = styled.div`
Expand All @@ -34,7 +34,7 @@ const ContentArea = styled.div`
overflow-y: auto;
`;

const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title, titleTooltip, imageUri, isEdit, isFormDirty, onEdit, onSave, onDelete, onCancel }) => {
const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title, titleTooltip, imageUri, isEdit = false, isFormDirty = false, onEdit, onSave, onDelete, onCancel }) => {
const { selectedItem, setSelectedItem } = useDrawerStore();

useKeyDown({ key: 'Enter', active: !!selectedItem }, () => (isEdit ? clickSave() : closeDrawer()));
Expand All @@ -52,7 +52,7 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,

const closeDrawer = () => {
setSelectedItem(null);
onEdit(false);
if (onEdit) onEdit(false);
setIsDeleteModalOpen(false);
setIsCancelModalOpen(false);
};
Expand All @@ -64,7 +64,7 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,

const handleCancel = () => {
titleRef.current?.clearTitle();
onCancel();
if (onCancel) onCancel();
closeWarningModals();
};

Expand All @@ -78,7 +78,7 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,
};

const handleDelete = () => {
onDelete();
if (onDelete) onDelete();
closeWarningModals();
};

Expand All @@ -87,7 +87,7 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,
};

const clickSave = () => {
onSave(titleRef.current?.getTitle() || '');
if (onSave) onSave(titleRef.current?.getTitle() || '');
};

const isLastItem = () => {
Expand All @@ -103,7 +103,15 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,
<>
<Drawer isOpen onClose={isEdit ? clickCancel : closeDrawer} width={DRAWER_WIDTH} closeOnEscape={!isDeleteModalOpen && !isCancelModalOpen}>
<DrawerContent>
<DrawerHeader ref={titleRef} title={title} titleTooltip={titleTooltip} imageUri={imageUri} isEdit={isEdit} onEdit={() => onEdit(true)} onClose={isEdit ? clickCancel : closeDrawer} />
<DrawerHeader
ref={titleRef}
title={title}
titleTooltip={titleTooltip}
imageUri={imageUri}
isEdit={isEdit}
onEdit={onEdit ? () => onEdit(true) : undefined}
onClose={isEdit ? clickCancel : closeDrawer}
/>
<ContentArea>{children}</ContentArea>
<DrawerFooter isOpen={isEdit} onSave={clickSave} onCancel={clickCancel} onDelete={clickDelete} deleteLabel={isSource ? 'Uninstrument' : undefined} />
</DrawerContent>
Expand All @@ -113,7 +121,7 @@ const OverviewDrawer: React.FC<Props & PropsWithChildren> = ({ children, title,
isOpen={isDeleteModalOpen}
noOverlay
name={`${selectedItem?.type}${title ? ` (${title})` : ''}`}
type={selectedItem?.type}
type={selectedItem?.type as OVERVIEW_ENTITY_TYPES}
isLastItem={isLastItem()}
onApprove={handleDelete}
onDeny={closeWarningModals}
Expand Down
Loading
Loading