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 authored and Sebastian Malton committed 2021-04-06 10:24:40 -04:00
1 parent 63f6562e0a
commit 79659e569a
1 file changed
+6 -3
@@ -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,