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; message: string;
selfLink: string; selfLink: string;
age: string | number; age: string | number;
timeDiffFromNow: number;
} }
enum sortBy { enum sortBy {
@ -37,7 +38,7 @@ export class ClusterIssues extends React.Component<Props> {
private sortCallbacks = { private sortCallbacks = {
[sortBy.type]: (warning: IWarning) => warning.kind, [sortBy.type]: (warning: IWarning) => warning.kind,
[sortBy.object]: (warning: IWarning) => warning.getName(), [sortBy.object]: (warning: IWarning) => warning.getName(),
[sortBy.age]: (warning: IWarning) => warning.age || "", [sortBy.age]: (warning: IWarning) => warning.timeDiffFromNow,
}; };
@computed get warnings() { @computed get warnings() {
@ -45,13 +46,14 @@ export class ClusterIssues extends React.Component<Props> {
// Node bad conditions // Node bad conditions
nodesStore.items.forEach(node => { nodesStore.items.forEach(node => {
const { kind, selfLink, getId, getName, getAge } = node; const { kind, selfLink, getId, getName, getAge, getTimeDiffFromNow } = node;
node.getWarningConditions().forEach(({ message }) => { node.getWarningConditions().forEach(({ message }) => {
warnings.push({ warnings.push({
age: getAge(), age: getAge(),
getId, getId,
getName, getName,
timeDiffFromNow: getTimeDiffFromNow(),
kind, kind,
message, message,
selfLink, selfLink,
@ -63,12 +65,13 @@ export class ClusterIssues extends React.Component<Props> {
const events = eventStore.getWarnings(); const events = eventStore.getWarnings();
events.forEach(error => { events.forEach(error => {
const { message, involvedObject, getAge } = error; const { message, involvedObject, getAge, getTimeDiffFromNow } = error;
const { uid, name, kind } = involvedObject; const { uid, name, kind } = involvedObject;
warnings.push({ warnings.push({
getId: () => uid, getId: () => uid,
getName: () => name, getName: () => name,
timeDiffFromNow: getTimeDiffFromNow(),
age: getAge(), age: getAge(),
message, message,
kind, kind,