1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix: proper sorting resources by age column (#2182 followup) (#2414)

Co-authored-by: Jim Ehrismann <40840436+jim-docker@users.noreply.github.com>
This commit is contained in:
MinJeong Kim 2021-04-15 00:07:15 +09:00 committed by GitHub
parent b6c3ce7d28
commit 4e231e5749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ interface IWarning extends ItemObject {
message: string;
selfLink: string;
age: string | number;
timeDiffFromNow: number;
}
enum sortBy {
@ -37,7 +38,7 @@ 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() {
@ -45,13 +46,14 @@ export class ClusterIssues extends React.Component<Props> {
// 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,
@ -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,