Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
df62bb0c
Unverified
Commit
df62bb0c
authored
9 months ago
by
Raphael Krut-Landau
Committed by
GitHub
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove dead code (#43603)
parent
e199d76e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/browse/components/LastEdited.tsx
+0
-80
0 additions, 80 deletions
frontend/src/metabase/browse/components/LastEdited.tsx
with
0 additions
and
80 deletions
frontend/src/metabase/browse/components/LastEdited.tsx
deleted
100644 → 0
+
0
−
80
View file @
e199d76e
import
dayjs
from
"
dayjs
"
;
import
relativeTime
from
"
dayjs/plugin/relativeTime
"
;
import
updateLocale
from
"
dayjs/plugin/updateLocale
"
;
import
{
c
,
t
}
from
"
ttag
"
;
import
_
from
"
underscore
"
;
import
{
formatDateTimeWithUnit
}
from
"
metabase/lib/formatting
"
;
import
{
Text
,
Tooltip
}
from
"
metabase/ui
"
;
dayjs
.
extend
(
updateLocale
);
dayjs
.
extend
(
relativeTime
);
const
timeFormattingRules
:
Record
<
string
,
unknown
>
=
{
m
:
t
`
${
1
}
min`
,
mm
:
t
`
${
"
%d
"
}
min`
,
h
:
t
`
${
1
}
h`
,
hh
:
t
`
${
"
%d
"
}
h`
,
d
:
t
`
${
1
}
d`
,
dd
:
t
`
${
"
%d
"
}
d`
,
M
:
t
`
${
1
}
mo`
,
MM
:
t
`
${
"
%d
"
}
mo`
,
y
:
t
`
${
1
}
yr`
,
yy
:
t
`
${
"
%d
"
}
yr`
,
// Display any number of seconds as "1min"
s
:
()
=>
t
`
${
1
}
min`
,
ss
:
()
=>
t
`
${
1
}
min`
,
// Don't use "ago"
past
:
"
%s
"
,
// For the edge case where a model's last-edit date is somehow in the future
future
:
t
`
${
"
%s
"
}
from now`
,
};
const
getTimePassedSince
=
(
timestamp
:
string
)
=>
{
const
date
=
dayjs
(
timestamp
);
if
(
timestamp
&&
date
.
isValid
())
{
const
locale
=
dayjs
.
locale
();
const
cachedRules
=
dayjs
.
Ls
[
locale
].
relativeTime
;
dayjs
.
updateLocale
(
locale
,
{
relativeTime
:
timeFormattingRules
});
const
timePassed
=
date
.
fromNow
();
dayjs
.
updateLocale
(
locale
,
{
relativeTime
:
cachedRules
});
return
timePassed
;
}
else
{
return
t
`(invalid date)`
;
}
};
export
const
LastEdited
=
({
editorFullName
,
timestamp
,
}:
{
editorFullName
:
string
|
null
;
timestamp
:
string
;
})
=>
{
const
timePassed
=
getTimePassedSince
(
timestamp
);
const
timeLabel
=
timestamp
?
timePassed
:
""
;
const
formattedDate
=
formatDateTimeWithUnit
(
timestamp
,
"
day
"
,
{});
const
time
=
(
<
time
key
=
"time"
dateTime
=
{
timestamp
}
>
{
formattedDate
}
</
time
>
);
const
tooltipLabel
=
c
(
"
{0} is the full name (or if this is unavailable, the email address) of the last person who edited a model. {1} is a date
"
,
).
jt
`Last edited by
${
editorFullName
}${(<
br
key
=
"br"
/>)}${
time
}
`
;
return
(
<
Tooltip
label
=
{
tooltipLabel
}
disabled
=
{
!
timeLabel
}
>
<
Text
role
=
"note"
size
=
"small"
>
{
editorFullName
}
{
editorFullName
&&
timePassed
&&
(
<
Text
span
px
=
".33rem"
color
=
"text-light"
>
•
</
Text
>
)
}
{
timePassed
}
</
Text
>
</
Tooltip
>
);
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment