Skip to content

Move RowHeader to shared component #1365

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

Merged
merged 4 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion ui-cra/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const GlobalStyle = createGlobalStyle`
margin-top: 50px;
}
::-webkit-scrollbar-thumb {
background-color: ${props => props.theme.colors.neutral20};
background-color: ${props => props.theme.colors.neutral30};
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import remarkGfm from 'remark-gfm';
import {
generateRowHeaders,
SectionRowHeader,
} from '../../ProgressiveDelivery/SharedComponent/CanaryRowHeader';
} from '../../RowHeader';
import { useFeatureFlags } from '@weaveworks/weave-gitops';

function HeaderSection({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { darcula } from 'react-syntax-highlighter/dist/esm/styles/prism';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Link } from 'react-router-dom';
import { generateRowHeaders } from '../../ProgressiveDelivery/SharedComponent/CanaryRowHeader';
import { generateRowHeaders } from '../../RowHeader';

interface IViolationDetailsProps {
violation: PolicyValidation | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useState } from 'react';
import { getKindRoute } from '../../../../utils/nav';
import { useCanaryStyle } from '../../CanaryStyles';
import { getDeploymentStrategyIcon } from '../../ListCanaries/Table';
import CanaryRowHeader from '../../SharedComponent/CanaryRowHeader';
import RowHeader from '../../../RowHeader';
import DynamicTable from '../../SharedComponent/DynamicTable';

const DetailsSection = ({
Expand All @@ -29,13 +29,13 @@ const DetailsSection = ({
};
return (
<>
<CanaryRowHeader rowkey="Cluster" value={canary.clusterName} />
<CanaryRowHeader rowkey="Namespace" value={canary.namespace} />
<CanaryRowHeader
<RowHeader rowkey="Cluster" value={canary.clusterName} />
<RowHeader rowkey="Namespace" value={canary.namespace} />
<RowHeader
rowkey="Target"
value={`${canary.targetReference?.kind}/${canary.targetReference?.name}`}
/>
<CanaryRowHeader
<RowHeader
rowkey="Application"
value={
automation?.kind && automation?.name ? (
Expand All @@ -53,15 +53,15 @@ const DetailsSection = ({
)
}
/>
<CanaryRowHeader rowkey="Deployment Strategy" value={undefined}>
<RowHeader rowkey="Deployment Strategy" value={undefined}>
{!!canary.deploymentStrategy && (
<span className={classes.straegyIcon}>
{canary.deploymentStrategy}{' '}
{getDeploymentStrategyIcon(canary.deploymentStrategy)}
</span>
)}
</CanaryRowHeader>
<CanaryRowHeader rowkey="Provider" value={canary.provider} />
</RowHeader>
<RowHeader rowkey="Provider" value={canary.provider} />

<div className={`${classes.sectionHeaderWrapper} ${classes.cardTitle}`}>
STATUS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Size, Table, TableBody } from '@material-ui/core';
import { KeyValueRow } from './CanaryRowHeader';
import { KeyValueRow } from '../../RowHeader';

const DynamicTable = ({
obj,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { normal } = theme.fontSizes;
const { small, xs } = theme.spacing;
const { neutral30, neutral40 } = theme.colors;

const RowHeader = styled.div`
const RowHeaderWrapper = styled.div`
margin: ${small} 0;
display: flex;
justify-content: start;
Expand Down Expand Up @@ -34,9 +34,9 @@ export const generateRowHeaders = (rows: Array<SectionRowHeader>) => {
return rows.map(r => {

return r.hidden === true ? null : (
<CanaryRowHeader rowkey={r.rowkey} value={r.value} key={r.rowkey}>
<RowHeader rowkey={r.rowkey} value={r.value} key={r.rowkey}>
{r.children}
</CanaryRowHeader>
</RowHeader>
);
});
};
Expand Down Expand Up @@ -74,7 +74,7 @@ export function KeyValueRow({
);
}

function CanaryRowHeader({
function RowHeader({
children,
rowkey,
value,
Expand All @@ -84,11 +84,11 @@ function CanaryRowHeader({
value: string | JSX.Element | undefined;
}) {
return (
<RowHeader data-testid={rowkey}>
<RowHeaderWrapper data-testid={rowkey}>
<RowTitle>{rowkey} :</RowTitle>
<RowBody>{children || value || '--'}</RowBody>
</RowHeader>
</RowHeaderWrapper>
);
}

export default CanaryRowHeader;
export default RowHeader;