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

Visualization Embed: Add option to hide timestamp #4491

Merged
merged 1 commit into from
Dec 30, 2019
Merged
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
24 changes: 15 additions & 9 deletions client/app/components/queries/VisualizationEmbed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ VisualizationEmbedHeader.propTypes = {

VisualizationEmbedHeader.defaultProps = { queryDescription: "" };

function VisualizationEmbedFooter({ query, queryResults, updatedAt, refreshStartedAt, queryUrl }) {
function VisualizationEmbedFooter({ query, queryResults, updatedAt, refreshStartedAt, queryUrl, hideTimestamp }) {
const downloadMenu = (
<Menu>
<Menu.Item>
Expand Down Expand Up @@ -76,15 +76,17 @@ function VisualizationEmbedFooter({ query, queryResults, updatedAt, refreshStart

return (
<div className="tile__bottom-control">
<span>
<a className="small hidden-print">
<i className="zmdi zmdi-time-restore" />{" "}
{refreshStartedAt ? <Timer from={refreshStartedAt} /> : <TimeAgo date={updatedAt} />}
</a>
<span className="small visible-print">
<i className="zmdi zmdi-time-restore" /> {formatDateTime(updatedAt)}
{!hideTimestamp && (
<span>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one note: currently this <span> is what moves the buttons to the right side, if you don't want them to be in the left side when there's no timestamp, just keep it empty 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing, but that's inline with the current implementation on SaaS, so safe to keep :)

<a className="small hidden-print">
<i className="zmdi zmdi-time-restore" />{" "}
{refreshStartedAt ? <Timer from={refreshStartedAt} /> : <TimeAgo date={updatedAt} />}
</a>
<span className="small visible-print">
<i className="zmdi zmdi-time-restore" /> {formatDateTime(updatedAt)}
</span>
</span>
</span>
)}
{queryUrl && (
<span className="hidden-print">
<Tooltip title="Open in Redash">
Expand Down Expand Up @@ -112,13 +114,15 @@ VisualizationEmbedFooter.propTypes = {
updatedAt: PropTypes.string,
refreshStartedAt: Moment,
queryUrl: PropTypes.string,
hideTimestamp: PropTypes.bool,
};

VisualizationEmbedFooter.defaultProps = {
queryResults: null,
updatedAt: null,
refreshStartedAt: null,
queryUrl: null,
hideTimestamp: false,
};

function VisualizationEmbed({ query }) {
Expand All @@ -128,6 +132,7 @@ function VisualizationEmbed({ query }) {
const hideHeader = has($location.search(), "hide_header");
const hideParametersUI = has($location.search(), "hide_parameters");
const hideQueryLink = has($location.search(), "hide_link");
const hideTimestamp = has($location.search(), "hide_timestamp");

const showQueryDescription = has($location.search(), "showDescription");
const visualizationId = parseInt($routeParams.visualizationId, 10);
Expand Down Expand Up @@ -185,6 +190,7 @@ function VisualizationEmbed({ query }) {
updatedAt={queryResults ? queryResults.getUpdatedAt() : undefined}
refreshStartedAt={refreshStartedAt}
queryUrl={!hideQueryLink ? query.getUrl() : null}
hideTimestamp={hideTimestamp}
/>
</div>
);
Expand Down