Fix: events sorting with compact=true is broken (#2141)

* fix: use default sorting for <Events/> as on "timeline" (fresh on top)

Signed-off-by: Roman <ixrock@gmail.com>

* responding to comments

Signed-off-by: Roman <ixrock@gmail.com>

* convert comments to jsdoc (table.tsx)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2021-02-18 12:21:41 +02:00
1 parent 4d6cba4741
commit 5029196d15
8 files changed
+101 -61

No files matched your search

+7 -4
View File
@@ -122,12 +122,15 @@ export class KubeObject implements ItemObject {
return this.metadata.namespace || undefined;
}
// todo: refactor with named arguments
getAge(humanize = true, compact = true, fromNow = false) {
getTimeDiffFromNow(): number {
return new Date().getTime() - new Date(this.metadata.creationTimestamp).getTime();
}
getAge(humanize = true, compact = true, fromNow = false): string | number {
if (fromNow) {
return moment(this.metadata.creationTimestamp).fromNow();
return moment(this.metadata.creationTimestamp).fromNow(); // "string", getTimeDiffFromNow() cannot be used
}
const diff = new Date().getTime() - new Date(this.metadata.creationTimestamp).getTime();
const diff = this.getTimeDiffFromNow();
if (humanize) {
return formatDuration(diff, compact);