Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to updated date #1731

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* Added a link to this changelog from the Auspice view. ([#1727](https://github.com/nextstrain/auspice/pull/1727))
* Updated the "Data updated" date under the dataset title to be a relative date. ([#1731](https://github.com/nextstrain/auspice/pull/1731))

## version 2.51.0 - 2023/11/16

Expand Down
2 changes: 1 addition & 1 deletion bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"path": "./dist/auspice.?(chunk.)core-vendors.bundle.*.js",
"maxSize": "220 kB"
"maxSize": "250 kB"
},
{
"path": "./dist/auspice.?(chunk.)other-vendors.bundle.*.js",
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"linspace": "^1.0.0",
"lodash": "^4.17.21",
"lodash-webpack-plugin": "^0.11.6",
"luxon": "^3.4.4",
"marked": "^0.7.0",
"mousetrap": "^1.6.2",
"null-loader": "^4.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/components/framework/fine-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from "react-redux";
import styled from 'styled-components';
import { withTranslation } from "react-i18next";
import { FaDownload } from "react-icons/fa";
import { DateTime } from "luxon";
import { dataFont, medGrey, materialButton } from "../../globalStyles";
import { TRIGGER_DOWNLOAD_MODAL } from "../../actions/types";
import Flex from "./flex";
Expand Down Expand Up @@ -72,7 +73,7 @@ class FinePrint extends React.Component {

getUpdated() {
const { t } = this.props;
if (this.props.metadata.updated) {
if (DateTime.fromISO(this.props.metadata.updated).isValid) {
return (<span>{t("Data updated")} {this.props.metadata.updated}</span>);
}
return null;
Expand Down
13 changes: 8 additions & 5 deletions src/components/info/byline.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { connect } from "react-redux";
import { withTranslation } from 'react-i18next';
import styled from 'styled-components';
import { DateTime } from "luxon";
import { headerFont } from "../../globalStyles";

/**
Expand All @@ -11,7 +12,8 @@ import { headerFont } from "../../globalStyles";
*/
@connect((state) => {
return {
metadata: state.metadata
metadata: state.metadata,
language: state.general.language
};
})
class Byline extends React.Component {
Expand All @@ -22,7 +24,7 @@ class Byline extends React.Component {
{renderAvatar(t, this.props.metadata)}
{renderBuildInfo(t, this.props.metadata)}
{renderMaintainers(t, this.props.metadata)}
{renderDataUpdated(t, this.props.metadata)}
{renderDataUpdated(t, this.props.metadata, this.props.language)}
{renderDataProvenance(t, this.props.metadata)}
</>
);
Expand Down Expand Up @@ -106,11 +108,12 @@ function renderMaintainers(t, metadata) {
* Returns a React component detailing the date the data was last updated.
* Renders a <span> containing "Data updated X", where X derives from `metadata.updated`
*/
function renderDataUpdated(t, metadata) {
if (metadata.updated) {
function renderDataUpdated(t, metadata, language) {
const date = DateTime.fromISO(metadata.updated);
if (date.isValid) {
return (
<span>
{`${t("Data updated")} ${metadata.updated}. `}
{`${t("Data updated")} ${date.toRelativeCalendar({locale: language})}. `}
</span>
);
}
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const generateConfig = ({extensionPath, devMode=false, customOutputPath, analyze
"style-loader",
"@hot-loader/react-dom",
"react(-(redux|select|helmet|i18next))?",
"luxon",
"leaflet",
"redux",
"leaflet(-gesture-handling)?",
Expand Down