Skip to content

Commit

Permalink
fix: proper sorting resources by age column (#2182 followup) (#2414)
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
  • Loading branch information
2 people authored and Nokel81 committed Apr 19, 2021
1 parent 5a72f7a commit 92139d2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/renderer/components/+cluster/cluster-issues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface IWarning extends ItemObject {
message: string;
selfLink: string;
age: string | number;
timeDiffFromNow: number;
}

enum sortBy {
Expand All @@ -37,21 +38,22 @@ export class ClusterIssues extends React.Component<Props> {
private sortCallbacks = {
[sortBy.type]: (warning: IWarning) => warning.kind,
[sortBy.object]: (warning: IWarning) => warning.getName(),
[sortBy.age]: (warning: IWarning) => warning.age || "",
[sortBy.age]: (warning: IWarning) => warning.timeDiffFromNow,
};

@computed get warnings() {
const warnings: IWarning[] = [];

// Node bad conditions
nodesStore.items.forEach(node => {
const { kind, selfLink, getId, getName, getAge } = node;
const { kind, selfLink, getId, getName, getAge, getTimeDiffFromNow } = node;

node.getWarningConditions().forEach(({ message }) => {
warnings.push({
age: getAge(),
getId,
getName,
timeDiffFromNow: getTimeDiffFromNow(),
kind,
message,
selfLink,
Expand All @@ -63,12 +65,13 @@ export class ClusterIssues extends React.Component<Props> {
const events = eventStore.getWarnings();

events.forEach(error => {
const { message, involvedObject, getAge } = error;
const { message, involvedObject, getAge, getTimeDiffFromNow } = error;
const { uid, name, kind } = involvedObject;

warnings.push({
getId: () => uid,
getName: () => name,
timeDiffFromNow: getTimeDiffFromNow(),
age: getAge(),
message,
kind,
Expand Down

0 comments on commit 92139d2

Please sign in to comment.