mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
1 parent
4d6cba4741
commit
5029196d15
8 files changed
+101
-61
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user