This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch frontend-time-fmt
in repository https://gitbox.apache.org/repos/asf/superset.git

commit acaa0a63830802d1300b3a772140b2fb1bcd6c38
Author: David Aaron Suddjian <[email protected]>
AuthorDate: Tue Feb 16 02:26:31 2021 -0800

    refactor: format times on the frontend
---
 superset-frontend/spec/fixtures/mockSliceEntities.js          | 11 -----------
 superset-frontend/src/dashboard/actions/sliceEntities.js      |  2 --
 superset-frontend/src/dashboard/components/AddSliceCard.jsx   |  3 ++-
 superset-frontend/src/dashboard/components/SliceAdder.jsx     |  2 +-
 .../src/dashboard/components/dnd/AddSliceDragPreview.jsx      |  2 +-
 superset-frontend/src/dashboard/reducers/getInitialState.js   |  1 -
 superset-frontend/src/dashboard/util/propShapes.jsx           |  1 -
 7 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/superset-frontend/spec/fixtures/mockSliceEntities.js 
b/superset-frontend/spec/fixtures/mockSliceEntities.js
index 600c840..7dc2520 100644
--- a/superset-frontend/spec/fixtures/mockSliceEntities.js
+++ b/superset-frontend/spec/fixtures/mockSliceEntities.js
@@ -50,7 +50,6 @@ export const sliceEntitiesForChart = {
       datasource: datasourceId,
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332615,
     },
   },
@@ -83,7 +82,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332615,
     },
     128: {
@@ -96,7 +94,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332628,
     },
     129: {
@@ -109,7 +106,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332637,
     },
     130: {
@@ -122,7 +118,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332645,
     },
     131: {
@@ -135,7 +130,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332654,
     },
     132: {
@@ -148,7 +142,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332663,
     },
     133: {
@@ -161,7 +154,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332673,
     },
     134: {
@@ -174,7 +166,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332680,
     },
     135: {
@@ -187,7 +178,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332688,
     },
     136: {
@@ -200,7 +190,6 @@ export const sliceEntitiesForDashboard = {
       datasource: '2__table',
       description: null,
       description_markeddown: '',
-      modified: '23 hours ago',
       changed_on: 1529453332700,
     },
   },
diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js 
b/superset-frontend/src/dashboard/actions/sliceEntities.js
index 2a344cb..6374ce4 100644
--- a/superset-frontend/src/dashboard/actions/sliceEntities.js
+++ b/superset-frontend/src/dashboard/actions/sliceEntities.js
@@ -97,8 +97,6 @@ export function fetchAllSlices(userId) {
               description: slice.description,
               description_markdown: slice.description_markeddown,
               viz_type: slice.viz_type,
-              modified: slice.changed_on_delta_humanized,
-              changed_on_humanized: slice.changed_on_delta_humanized,
             };
           });
 
diff --git a/superset-frontend/src/dashboard/components/AddSliceCard.jsx 
b/superset-frontend/src/dashboard/components/AddSliceCard.jsx
index 6163943..1d3901f 100644
--- a/superset-frontend/src/dashboard/components/AddSliceCard.jsx
+++ b/superset-frontend/src/dashboard/components/AddSliceCard.jsx
@@ -19,6 +19,7 @@
 import cx from 'classnames';
 import React from 'react';
 import PropTypes from 'prop-types';
+import moment from 'moment';
 import { t } from '@superset-ui/core';
 
 const propTypes = {
@@ -63,7 +64,7 @@ function AddSliceCard({
         <div className="card-body">
           <div className="item">
             <span>{t('Modified')} </span>
-            <span>{lastModified}</span>
+            <span>{moment(lastModified).fromNow()}</span>
           </div>
           <div className="item">
             <span>{t('Visualization')} </span>
diff --git a/superset-frontend/src/dashboard/components/SliceAdder.jsx 
b/superset-frontend/src/dashboard/components/SliceAdder.jsx
index 141ccac..db35427 100644
--- a/superset-frontend/src/dashboard/components/SliceAdder.jsx
+++ b/superset-frontend/src/dashboard/components/SliceAdder.jsx
@@ -191,7 +191,7 @@ class SliceAdder extends React.Component {
             innerRef={dragSourceRef}
             style={style}
             sliceName={cellData.slice_name}
-            lastModified={cellData.changed_on_humanized}
+            lastModified={cellData.changed_on}
             visType={cellData.viz_type}
             datasourceUrl={cellData.datasource_url}
             datasourceName={cellData.datasource_name}
diff --git 
a/superset-frontend/src/dashboard/components/dnd/AddSliceDragPreview.jsx 
b/superset-frontend/src/dashboard/components/dnd/AddSliceDragPreview.jsx
index 404561e..4ae25ac 100644
--- a/superset-frontend/src/dashboard/components/dnd/AddSliceDragPreview.jsx
+++ b/superset-frontend/src/dashboard/components/dnd/AddSliceDragPreview.jsx
@@ -72,7 +72,7 @@ function AddSliceDragPreview({ dragItem, slices, isDragging, 
currentOffset }) {
         transform: `translate(${currentOffset.x}px, ${currentOffset.y}px)`,
       }}
       sliceName={slice.slice_name}
-      lastModified={slice.changed_on_humanized}
+      lastModified={slice.changed_on}
       visType={slice.viz_type}
       datasourceUrl={slice.datasource_url}
       datasourceName={slice.datasource_name}
diff --git a/superset-frontend/src/dashboard/reducers/getInitialState.js 
b/superset-frontend/src/dashboard/reducers/getInitialState.js
index 1157997..460358b 100644
--- a/superset-frontend/src/dashboard/reducers/getInitialState.js
+++ b/superset-frontend/src/dashboard/reducers/getInitialState.js
@@ -133,7 +133,6 @@ export default function getInitialState(bootstrapData) {
       description: slice.description,
       description_markeddown: slice.description_markeddown,
       owners: slice.owners,
-      modified: slice.modified,
       changed_on: new Date(slice.changed_on).getTime(),
     };
 
diff --git a/superset-frontend/src/dashboard/util/propShapes.jsx 
b/superset-frontend/src/dashboard/util/propShapes.jsx
index 78bcf3f..444fae4 100644
--- a/superset-frontend/src/dashboard/util/propShapes.jsx
+++ b/superset-frontend/src/dashboard/util/propShapes.jsx
@@ -64,7 +64,6 @@ export const slicePropShape = PropTypes.shape({
   datasource_name: PropTypes.string,
   datasource_link: PropTypes.string,
   changed_on: PropTypes.number.isRequired,
-  modified: PropTypes.string.isRequired,
   viz_type: PropTypes.string.isRequired,
   description: PropTypes.string,
   description_markeddown: PropTypes.string,

Reply via email to