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)

sorting resources by age in cluster-issues is broken (previously sorted by iso-string timestamp)

Signed-off-by: MinJeong Kim <min7859@gmail.com>
This commit is contained in:
MinJeong Kim 2021-03-30 20:10:11 +09:00 committed by Sebastian Malton
parent 63f6562e0a
commit 79659e569a

View File

@ -24,6 +24,7 @@ interface IWarning extends ItemObject {
message: string;
selfLink: string;
age: string | number;
getTimeDiffFromNow(): 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.getTimeDiffFromNow(),
};
@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,
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,
getTimeDiffFromNow,
age: getAge(),
message,
kind,