Skip to content

Commit

Permalink
Hide irrelevant columns when Templates is using Explorer
Browse files Browse the repository at this point in the history
Making this closer to parity with the old Applications view
  • Loading branch information
Jordan Pellizzari committed Oct 31, 2023
1 parent f2b0ad1 commit 0bb1480
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions ui/src/components/Templates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import {
IconType,
Link,
} from '@weaveworks/weave-gitops';
import _ from 'lodash';
import { FC, useCallback, useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import styled from 'styled-components';
import { EnabledComponent } from '../../api/query/query.pb';
import { EnabledComponent, Object } from '../../api/query/query.pb';
import { Template } from '../../cluster-services/cluster_services.pb';
import useNotifications, {
NotificationData,
Expand All @@ -32,9 +33,12 @@ const DocsLink = styled(Link)`
padding-left: ${({ theme }) => theme.spacing.xxs};
`;

const TemplatesDashboard: FC<{
type Props = {
className?: string;
location: { state: { notification: NotificationData[] } };
}> = ({ location }) => {
};

const TemplatesDashboard: FC<Props> = ({ location, className }) => {
const isExplorerEnabled = useIsEnabledForComponent(
EnabledComponent.templates,
);
Expand Down Expand Up @@ -72,6 +76,7 @@ const TemplatesDashboard: FC<{
return (
<Page
loading={isLoading}
className={className}
path={[
{
label: 'Templates',
Expand All @@ -86,7 +91,15 @@ const TemplatesDashboard: FC<{
extraColumns={[
{
label: 'Type',
value: 'templateType',
value: o => {
console.log(o);

return _.get(o.parsed, [
'metadata',
'labels',
'weave.works/template-type',
]);
},
sortValue: ({ name }) => name,
},
{
Expand All @@ -102,6 +115,11 @@ const TemplatesDashboard: FC<{
</Button>
),
},
{
label: 'Description',
value: (o: Object) => o.message || '-',
index: 7,
},
]}
linkToObject={false}
/>
Expand Down Expand Up @@ -182,4 +200,16 @@ const TemplatesDashboard: FC<{
);
};

export default TemplatesDashboard;
export default styled(TemplatesDashboard)`
${Explorer} {
/* Hiding Status, Message, and Tenant columns */
table td:nth-child(5),
table th:nth-child(5),
table td:nth-child(6),
table th:nth-child(6),
table td:nth-child(7),
table th:nth-child(7) {
display: none;
}
}
`;

0 comments on commit 0bb1480

Please sign in to comment.