mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix: compact-mode for Workloads overview -> Events (#2113)
fix: proper event-type column + default sorting by warning events Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
22176219f0
commit
b873ba76bd
@ -28,7 +28,7 @@ export class KubeEvent extends KubeObject {
|
|||||||
firstTimestamp: string;
|
firstTimestamp: string;
|
||||||
lastTimestamp: string;
|
lastTimestamp: string;
|
||||||
count: number;
|
count: number;
|
||||||
type: string;
|
type: "Normal" | "Warning" | string;
|
||||||
eventTime: null;
|
eventTime: null;
|
||||||
reportingComponent: string;
|
reportingComponent: string;
|
||||||
reportingInstance: string;
|
reportingInstance: string;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { Link } from "react-router-dom";
|
|||||||
import { cssNames, IClassName, stopPropagation } from "../../utils";
|
import { cssNames, IClassName, stopPropagation } from "../../utils";
|
||||||
import { Icon } from "../icon";
|
import { Icon } from "../icon";
|
||||||
import { lookupApiLink } from "../../api/kube-api";
|
import { lookupApiLink } from "../../api/kube-api";
|
||||||
|
import { eventsURL } from "./events.route";
|
||||||
|
|
||||||
enum columnId {
|
enum columnId {
|
||||||
message = "message",
|
message = "message",
|
||||||
@ -36,19 +37,45 @@ const defaultProps: Partial<Props> = {
|
|||||||
export class Events extends React.Component<Props> {
|
export class Events extends React.Component<Props> {
|
||||||
static defaultProps = defaultProps as object;
|
static defaultProps = defaultProps as object;
|
||||||
|
|
||||||
|
get store() {
|
||||||
|
return eventStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
get items() {
|
||||||
|
return eventStore.contextItems;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { store, items } = this;
|
||||||
const { compact, compactLimit, className, ...layoutProps } = this.props;
|
const { compact, compactLimit, className, ...layoutProps } = this.props;
|
||||||
|
const visibleItems = compact ? items.slice(0, compactLimit) : items;
|
||||||
|
const allEventsAreShown = visibleItems.length === items.length;
|
||||||
|
|
||||||
|
const compactModeHeader = <>
|
||||||
|
Events <small>({visibleItems.length} of <Link to={eventsURL()}>{items.length}</Link>)</small>
|
||||||
|
</>;
|
||||||
|
|
||||||
const events = (
|
const events = (
|
||||||
<KubeObjectListLayout
|
<KubeObjectListLayout
|
||||||
{...layoutProps}
|
{...layoutProps}
|
||||||
isConfigurable
|
isConfigurable
|
||||||
tableId="events"
|
tableId="events"
|
||||||
|
store={store}
|
||||||
className={cssNames("Events", className, { compact })}
|
className={cssNames("Events", className, { compact })}
|
||||||
store={eventStore}
|
|
||||||
isSelectable={false}
|
isSelectable={false}
|
||||||
|
items={visibleItems}
|
||||||
|
virtual={!compact}
|
||||||
|
renderHeaderTitle={compact && !allEventsAreShown ? compactModeHeader : "Events"}
|
||||||
|
tableProps={{
|
||||||
|
sortSyncWithUrl: false,
|
||||||
|
sortByDefault: {
|
||||||
|
sortBy: columnId.type,
|
||||||
|
orderBy: "desc", // show "Warning" events at the top
|
||||||
|
},
|
||||||
|
}}
|
||||||
sortingCallbacks={{
|
sortingCallbacks={{
|
||||||
[columnId.namespace]: (event: KubeEvent) => event.getNs(),
|
[columnId.namespace]: (event: KubeEvent) => event.getNs(),
|
||||||
[columnId.type]: (event: KubeEvent) => event.involvedObject.kind,
|
[columnId.type]: (event: KubeEvent) => event.type,
|
||||||
[columnId.object]: (event: KubeEvent) => event.involvedObject.name,
|
[columnId.object]: (event: KubeEvent) => event.involvedObject.name,
|
||||||
[columnId.count]: (event: KubeEvent) => event.count,
|
[columnId.count]: (event: KubeEvent) => event.count,
|
||||||
[columnId.age]: (event: KubeEvent) => event.metadata.creationTimestamp,
|
[columnId.age]: (event: KubeEvent) => event.metadata.creationTimestamp,
|
||||||
@ -59,7 +86,6 @@ export class Events extends React.Component<Props> {
|
|||||||
(event: KubeEvent) => event.getSource(),
|
(event: KubeEvent) => event.getSource(),
|
||||||
(event: KubeEvent) => event.involvedObject.name,
|
(event: KubeEvent) => event.involvedObject.name,
|
||||||
]}
|
]}
|
||||||
renderHeaderTitle="Events"
|
|
||||||
customizeHeader={({ title, info }) => (
|
customizeHeader={({ title, info }) => (
|
||||||
compact ? title : ({
|
compact ? title : ({
|
||||||
info: (
|
info: (
|
||||||
@ -69,16 +95,16 @@ export class Events extends React.Component<Props> {
|
|||||||
small
|
small
|
||||||
material="help_outline"
|
material="help_outline"
|
||||||
className="help-icon"
|
className="help-icon"
|
||||||
tooltip={`Limited to ${eventStore.limit}`}
|
tooltip={`Limited to ${store.limit}`}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
renderTableHeader={[
|
renderTableHeader={[
|
||||||
|
{ title: "Type", className: "type", sortBy: columnId.type, id: columnId.type },
|
||||||
{ title: "Message", className: "message", id: columnId.message },
|
{ title: "Message", className: "message", id: columnId.message },
|
||||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||||
{ title: "Type", className: "type", sortBy: columnId.type, id: columnId.type },
|
|
||||||
{ title: "Involved Object", className: "object", sortBy: columnId.object, id: columnId.object },
|
{ title: "Involved Object", className: "object", sortBy: columnId.object, id: columnId.object },
|
||||||
{ title: "Source", className: "source", id: columnId.source },
|
{ title: "Source", className: "source", id: columnId.source },
|
||||||
{ title: "Count", className: "count", sortBy: columnId.count, id: columnId.count },
|
{ title: "Count", className: "count", sortBy: columnId.count, id: columnId.count },
|
||||||
@ -86,12 +112,11 @@ export class Events extends React.Component<Props> {
|
|||||||
]}
|
]}
|
||||||
renderTableContents={(event: KubeEvent) => {
|
renderTableContents={(event: KubeEvent) => {
|
||||||
const { involvedObject, type, message } = event;
|
const { involvedObject, type, message } = event;
|
||||||
const { kind, name } = involvedObject;
|
|
||||||
const tooltipId = `message-${event.getId()}`;
|
const tooltipId = `message-${event.getId()}`;
|
||||||
const isWarning = type === "Warning";
|
const isWarning = event.isWarning();
|
||||||
const detailsUrl = getDetailsUrl(lookupApiLink(involvedObject, event));
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
type, // type of event: "Normal" or "Warning"
|
||||||
{
|
{
|
||||||
className: { warning: isWarning },
|
className: { warning: isWarning },
|
||||||
title: (
|
title: (
|
||||||
@ -104,17 +129,14 @@ export class Events extends React.Component<Props> {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
event.getNs(),
|
event.getNs(),
|
||||||
kind,
|
<Link key="link" to={getDetailsUrl(lookupApiLink(involvedObject, event))} onClick={stopPropagation}>
|
||||||
<Link key="link" to={detailsUrl} title={name} onClick={stopPropagation}>{name}</Link>,
|
{involvedObject.kind}: {involvedObject.name}
|
||||||
|
</Link>,
|
||||||
event.getSource(),
|
event.getSource(),
|
||||||
event.count,
|
event.count,
|
||||||
event.getAge(),
|
event.getAge(),
|
||||||
];
|
];
|
||||||
}}
|
}}
|
||||||
virtual={!compact}
|
|
||||||
filterItems={[
|
|
||||||
items => compact ? items.slice(0, compactLimit) : items,
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -42,13 +42,13 @@ export class KubeObjectListLayout extends React.Component<KubeObjectListLayoutPr
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const items = this.props.store.contextItems;
|
const { className, store, items = store.contextItems, ...layoutProps } = this.props;
|
||||||
const { className, ...layoutProps } = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ItemListLayout
|
<ItemListLayout
|
||||||
{...layoutProps}
|
{...layoutProps}
|
||||||
className={cssNames("KubeObjectListLayout", className)}
|
className={cssNames("KubeObjectListLayout", className)}
|
||||||
|
store={store}
|
||||||
items={items}
|
items={items}
|
||||||
preloadStores={false} // loading handled in kubeWatchApi.subscribeStores()
|
preloadStores={false} // loading handled in kubeWatchApi.subscribeStores()
|
||||||
detailsItem={this.selectedItem}
|
detailsItem={this.selectedItem}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user