-
Notifications
You must be signed in to change notification settings - Fork 2
Add Page to view secret details and secret events #2140
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
Changes from 14 commits
7651d10
d303c7f
ab69694
847098a
bda9ce8
9094f05
86b429d
f238ff4
bcf5d3d
0e28f87
bfd506f
310e422
d232d62
1590958
d7c0251
0708b21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DataTable } from '@weaveworks/weave-gitops'; | ||
import moment from 'moment'; | ||
import { Event } from '../../../../cluster-services/cluster_services.pb'; | ||
import { TableWrapper } from '../../../Shared'; | ||
|
||
export const EventsTable = ({ events }: { events: Event[] }) => { | ||
return ( | ||
<TableWrapper id="events-list"> | ||
<DataTable | ||
rows={events} | ||
fields={[ | ||
{ | ||
label: 'Reason', | ||
value: 'reason', | ||
textSearchable: true, | ||
}, | ||
{ | ||
label: 'Message', | ||
value: (e: Event) => ( | ||
<span | ||
style={{ | ||
whiteSpace: 'normal', | ||
}} | ||
> | ||
{e.message} | ||
</span> | ||
), | ||
maxWidth: 600, | ||
}, | ||
{ | ||
label: 'Age', | ||
value: (e: Event) => moment(e.timestamp).fromNow() || '--', | ||
defaultSort: true, | ||
sortValue: (e: Event) => { | ||
const t = e.timestamp && new Date(e.timestamp); | ||
// Invert the timestamp so the default sort shows the most recent first | ||
return e.timestamp ? (Number(t) * -1).toString() : ''; | ||
}, | ||
}, | ||
]} | ||
/> | ||
</TableWrapper> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Alert } from '@material-ui/lab'; | ||
import { LoadingPage } from '@weaveworks/weave-gitops'; | ||
import { ListEventsRequest } from '../../../../cluster-services/cluster_services.pb'; | ||
import { useListEvents } from '../../../../contexts/ProgressiveDelivery'; | ||
import { EventsTable } from './EventsTable'; | ||
|
||
type Props = ListEventsRequest; | ||
|
||
const ListEvents = (props: Props) => { | ||
const { error, data, isLoading } = useListEvents(props); | ||
return ( | ||
<> | ||
{isLoading && <LoadingPage />} | ||
{error && <Alert severity="error">{error.message}</Alert>} | ||
{data?.events && <EventsTable events={data.events} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default ListEvents; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { RouterTab } from '@weaveworks/weave-gitops'; | ||
import { GetExternalSecretResponse } from '../../../cluster-services/cluster_services.pb'; | ||
import styled from 'styled-components'; | ||
import { generateRowHeaders, SectionRowHeader } from '../../RowHeader'; | ||
import { Routes } from '../../../utils/nav'; | ||
import { CustomSubRouterTabs } from '../../Workspaces/WorkspaceStyles'; | ||
import ListEvents from './Events/ListEvents'; | ||
|
||
const ListEventsWrapper = styled.div` | ||
width: 100%; | ||
`; | ||
const DetailsHeadersWrapper = styled.div` | ||
div { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it nested There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes i want to apply the style for the nested div |
||
margin-top: 0px !important; | ||
} | ||
`; | ||
|
||
const SecretDetailsTabs = ({ | ||
clusterName, | ||
namespace, | ||
externalSecretName, | ||
secretDetails, | ||
}: { | ||
clusterName: string; | ||
namespace: string; | ||
externalSecretName: string; | ||
secretDetails: GetExternalSecretResponse; | ||
}) => { | ||
const path = Routes.SecretDetails; | ||
|
||
const secretDetailsHeaders: Array<SectionRowHeader> = [ | ||
{ | ||
rowkey: 'External Secret', | ||
value: externalSecretName, | ||
}, | ||
{ | ||
rowkey: 'K8s Secret', | ||
value: secretDetails.secretName, | ||
}, | ||
{ | ||
rowkey: 'Cluster', | ||
value: clusterName, | ||
}, | ||
{ | ||
rowkey: 'Secret Store', | ||
value: secretDetails.secretStore, | ||
}, | ||
{ | ||
rowkey: 'Secret Store Type', | ||
value: secretDetails.secretStoreType, | ||
}, | ||
{ | ||
rowkey: 'Secret path', | ||
value: secretDetails.secretPath, | ||
}, | ||
{ | ||
rowkey: 'Property', | ||
value: secretDetails.property, | ||
}, | ||
{ | ||
rowkey: 'Version', | ||
value: secretDetails.version, | ||
}, | ||
]; | ||
|
||
return ( | ||
<div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<CustomSubRouterTabs rootPath={`${path}/secretDetails`}> | ||
<RouterTab name="Details" path={`${path}/secretDetails`}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change |
||
<DetailsHeadersWrapper> | ||
{generateRowHeaders(secretDetailsHeaders)} | ||
</DetailsHeadersWrapper> | ||
</RouterTab> | ||
|
||
<RouterTab name="Events" path={`${path}/events`}> | ||
<ListEventsWrapper> | ||
<ListEvents | ||
involvedObject={{ | ||
name: externalSecretName, | ||
namespace: namespace || '', | ||
kind: 'ExternalSecret', | ||
}} | ||
clusterName={clusterName} | ||
/> | ||
</ListEventsWrapper> | ||
</RouterTab> | ||
</CustomSubRouterTabs> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SecretDetailsTabs; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { useGetSecretDetails } from '../../../contexts/Secrets'; | ||
import { Routes } from '../../../utils/nav'; | ||
import { generateRowHeaders, SectionRowHeader } from '../../RowHeader'; | ||
import { ContentWrapper } from '../../Layout/ContentWrapper'; | ||
import { PageTemplate } from '../../Layout/PageTemplate'; | ||
import moment from 'moment'; | ||
import SecretDetailsTabs from './SecretDetailsTabs'; | ||
|
||
const SecretDetails = ({ | ||
externalSecretName, | ||
clusterName, | ||
namespace, | ||
}: { | ||
externalSecretName: string; | ||
clusterName: string; | ||
namespace: string; | ||
}) => { | ||
const { data: secretDetails, isLoading: isSecretDetailsLoading } = | ||
useGetSecretDetails({ | ||
externalSecretName, | ||
clusterName, | ||
namespace, | ||
}); | ||
const defaultHeaders: Array<SectionRowHeader> = [ | ||
{ | ||
rowkey: 'Status', | ||
value: | ||
secretDetails?.status === 'NotReady' | ||
? 'Not Ready' | ||
: secretDetails?.status, | ||
}, | ||
{ | ||
rowkey: 'Last Updated', | ||
value: moment(secretDetails?.timestamp).fromNow(), | ||
}, | ||
]; | ||
|
||
console.log(secretDetails); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return ( | ||
<> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<PageTemplate | ||
documentTitle="Secrets" | ||
path={[ | ||
{ label: 'Secrets', url: Routes.Secrets }, | ||
{ label: secretDetails?.externalSecretName || '' }, | ||
]} | ||
> | ||
<ContentWrapper loading={isSecretDetailsLoading}> | ||
{generateRowHeaders(defaultHeaders)} | ||
<SecretDetailsTabs | ||
externalSecretName={externalSecretName} | ||
clusterName={clusterName} | ||
namespace={namespace} | ||
secretDetails={secretDetails || {}} | ||
/> | ||
</ContentWrapper> | ||
</PageTemplate> | ||
</> | ||
); | ||
}; | ||
|
||
export default SecretDetails; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ export function getKindRoute(k: Kind | string): string { | |
} | ||
} | ||
|
||
|
||
export enum Routes { | ||
Applications = '/applications', | ||
AddApplication = '/applications/create', | ||
|
@@ -59,8 +60,9 @@ export enum Routes { | |
|
||
Templates = '/templates', | ||
|
||
Workspaces= '/workspaces', | ||
WorkspaceDetails= '/workspaces/details', | ||
Workspaces = '/workspaces', | ||
WorkspaceDetails = '/workspaces/details', | ||
|
||
Secrets= '/secrets', | ||
Secrets = '/secrets', | ||
SecretDetails = '/details' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think if we can make use of
WorkspaceTabsWrapper
that we did in workspaces to use it here as well & maybe we can change the name toLoadingWrapper
as it'll save us some duplicate code 🤔 ?