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

Task 107 overview sources card #346

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions frontend/webapp/assets/images/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SOURCES_LOGOS } from "./sources.card/sources.card";
7 changes: 7 additions & 0 deletions frontend/webapp/assets/images/sources.card/sources.card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const SOURCES_LOGOS = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logo of programming languages, not sources

java: "https://odigos-sources.s3.amazonaws.com/java.svg",
go: "https://odigos-sources.s3.amazonaws.com/go.svg",
javascript: "https://odigos-sources.s3.amazonaws.com/nodejs.svg",
python: "https://odigos-sources.s3.amazonaws.com/python.svg",
dotnet: "https://odigos-sources.s3.amazonaws.com/dotnet.svg",
};
1 change: 1 addition & 0 deletions frontend/webapp/components/overview/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { OverviewHeader } from "./overview.header/overview.header";
export { ManageDestination } from "./destination/manage.destination/manage.destination";
export { DestinationsManagedList } from "./destination/destination.list/destinations.managed.list";
export { SourcesManagedList } from "./sources/sources.manage.list/sources.manage.list";
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from "react";
import { KeyvalImage, KeyvalTag, KeyvalText } from "@/design.system";
import { CardWrapper } from "./sources.manage.styled";
import theme from "@/styles/palette";
import { KIND_COLORS } from "@/styles/global";
import { SOURCES_LOGOS } from "@/assets/images";
import { ManagedSource } from "@/types/sources";

const TEXT_STYLE: React.CSSProperties = {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
overflow: "hidden",
width: 224,
textAlign: "center",
};
const LOGO_STYLE: React.CSSProperties = {
padding: 4,
backgroundColor: theme.colors.white,
};
Comment on lines +9 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use styled components instead?


interface SourceManagedCardProps {
item: ManagedSource;
}
const DEPLOYMENT = "deployment";
export default function SourceManagedCard({
item = {} as ManagedSource,
}: SourceManagedCardProps) {
return (
<CardWrapper>
<KeyvalImage
src={SOURCES_LOGOS[item?.languages[0].language || ""]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to always show the first one? what if there are many?

width={56}
height={56}
style={LOGO_STYLE}
alt="source-logo"
/>
<KeyvalText size={18} weight={700} style={TEXT_STYLE}>
{item?.name}
</KeyvalText>
<KeyvalTag
title={item?.kind || ""}
color={KIND_COLORS[item?.kind.toLowerCase() || DEPLOYMENT]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if kind is undefined, this will throw.
You can also optional chining the kind:

item?.kind?.toLowerCase()

/>
<KeyvalText size={14} color={theme.text.light_grey} style={TEXT_STYLE}>
{item?.namespace}
</KeyvalText>
</CardWrapper>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { ManagedListWrapper, EmptyListWrapper } from "./sources.manage.styled";
import Empty from "@/assets/images/empty-list.svg";
import SourceManagedCard from "./sources.manage.card";

export function SourcesManagedList({ data = [1, 1, 1, 1] }) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is [1, 1, 1, 1]? Should we type it as ManagedSource[]?

function renderDestinations() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destinations -> sources

return data.map((source: any) => <SourceManagedCard />);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need a react key prop for this list?

}

return (
<>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant

<ManagedListWrapper>
{data?.length === 0 ? (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id data is undefined this condition will be falsy and we will fallback to render the list which will throw

<EmptyListWrapper>
<Empty />
</EmptyListWrapper>
) : (
renderDestinations()
)}
</ManagedListWrapper>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { styled } from "styled-components";

export const CardWrapper = styled.div`
display: flex;
width: 272px;
height: 152px;
padding-top: 32px;
padding-bottom: 24px;
border-radius: 24px;
border: 1px solid var(--dark-mode-dark-3, #203548);
background: var(--dark-mode-dark-1, #07111a);
align-items: center;
flex-direction: column;
gap: 10px;
cursor: pointer;
&:hover {
background: var(--dark-mode-dark-1, #07111a81);
}
`;

export const EmptyListWrapper = styled.div`
width: 100%;
margin-top: 130px;
display: flex;
justify-content: center;
align-items: center;
`;

export const ManagedListWrapper = styled.div`
width: 100%;
display: flex;
flex-wrap: wrap;
gap: 24px;
overflow-y: scroll;
padding: 0px 36px;
padding-bottom: 50px;
margin-top: 88px;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import {
} from "./source.card.styled";
import Logo from "assets/logos/code-sandbox-logo.svg";
import { SETUP } from "@/utils/constants";

const KIND_COLORS = {
deployment: "#203548",
DaemonSet: "#033869",
};
import { KIND_COLORS } from "@/styles/global";

const TEXT_STYLE = {
textOverflow: "ellipsis",
Expand All @@ -37,7 +33,10 @@ export function SourceCard({ item, onClick, focus }: any) {
{item.name}
</KeyvalText>
</ApplicationNameWrapper>
<KeyvalTag title={item.kind} color={KIND_COLORS[item.kind]} />
<KeyvalTag
title={item.kind}
color={KIND_COLORS[item.kind].toLowerCase()}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current implementation will lower case the color ("#203548".toLowerCase()) and not the kind.

Suggested change
color={KIND_COLORS[item.kind].toLowerCase()}
color={KIND_COLORS[item.kind.toLowerCase()]}

/>
<KeyvalText size={14} weight={400}>
{`${item?.instances} ${SETUP.RUNNING_INSTANCES}`}
</KeyvalText>
Expand Down
3 changes: 2 additions & 1 deletion frontend/webapp/containers/overview/sources/sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KeyvalLoader } from "@/design.system";
import { OVERVIEW, QUERIES } from "@/utils/constants";
import { useQuery } from "react-query";
import { getSources } from "@/services";
import { OverviewHeader } from "@/components/overview";
import { OverviewHeader, SourcesManagedList } from "@/components/overview";
import { SourcesContainerWrapper } from "./sources.styled";

export function SourcesContainer() {
Expand All @@ -21,6 +21,7 @@ export function SourcesContainer() {
return (
<SourcesContainerWrapper>
<OverviewHeader title={OVERVIEW.MENU.SOURCES} />
<SourcesManagedList />
</SourcesContainerWrapper>
);
}
5 changes: 5 additions & 0 deletions frontend/webapp/styles/global.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const KIND_COLORS = {
deployment: "#203548",
daemonSet: "#033869",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
daemonSet: "#033869",
daemonset: "#033869",

statefulset: "#0F2C3F",
};
11 changes: 11 additions & 0 deletions frontend/webapp/types/sources.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface ManagedSource {
kind: string;
name: string;
namespace: string;
languages: [
{
container_name: string;
language: string;
}
];
}