FEATURE: Display 'last updated' on dashboard, improve release notes link (#7560)

This commit is contained in:
David Taylor 2019-05-17 06:42:45 +01:00 committed by Sam
parent 834c86678f
commit 5666316285
7 changed files with 28 additions and 12 deletions

View File

@ -111,13 +111,6 @@ export default Ember.Controller.extend(PeriodComputationMixin, {
return { startDate, endDate };
},
@computed("model.attributes.updated_at")
updatedTimestamp(updatedAt) {
return moment(updatedAt)
.tz(moment.tz.guess())
.format("LLL");
},
_reportsForPeriodURL(period) {
return Discourse.getURL(`/admin?period=${period}`);
}

View File

@ -1,6 +1,10 @@
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = ["updated_at"];
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link"
];
const AdminDashboard = Discourse.Model.extend({});

View File

@ -115,8 +115,12 @@
<div class="last-dashboard-update">
<div>
<h4>{{i18n "admin.dashboard.last_updated"}} </h4>
<p>{{updatedTimestamp}}</p>
<a rel="noopener" target="_blank" href="https://meta.discourse.org/tags/release-notes" class="btn btn-default">
<p>{{format-date model.attributes.updated_at leaveAgo="true"}}</p>
</div>
<div>
<h4>{{i18n "admin.dashboard.discourse_last_updated"}} </h4>
<p>{{format-date model.attributes.discourse_updated_at leaveAgo="true"}}</p>
<a rel="noopener" target="_blank" href={{model.attributes.release_notes_link}} class="btn btn-default">
{{i18n "admin.dashboard.whats_new_in_discourse"}}
</a>
</div>

View File

@ -249,6 +249,7 @@
.last-dashboard-update {
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
div {
align-self: center;

View File

@ -2,8 +2,11 @@
class AdminDashboardGeneralData < AdminDashboardData
def get_json
days_since_update = ((DateTime.now - Discourse.last_commit_date) / 1.day).to_i
{
updated_at: Time.zone.now.as_json
updated_at: Time.zone.now.as_json,
discourse_updated_at: Discourse.last_commit_date,
release_notes_link: "https://meta.discourse.org/c/feature/announcements?tags=release-notes&before=#{days_since_update}"
}
end

View File

@ -3008,7 +3008,8 @@ en:
dashboard:
title: "Dashboard"
last_updated: "Dashboard last updated:"
last_updated: "Dashboard updated:"
discourse_last_updated: "Discourse updated:"
version: "Version"
up_to_date: "You're up to date!"
critical_available: "A critical update is available."

View File

@ -437,6 +437,16 @@ module Discourse
end
end
def self.last_commit_date
ensure_version_file_loaded
$last_commit_date ||=
begin
git_cmd = 'git log -1 --format="%ct"'
seconds = self.try_git(git_cmd, nil)
seconds.nil? ? nil : DateTime.strptime(seconds, '%s')
end
end
def self.try_git(git_cmd, default_value)
version_value = false