This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new fef5b5e Fix raw HTML in SliceAdder (#7338)
fef5b5e is described below
commit fef5b5efb02986a913d9929d94bb4e90f31f1fe8
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Wed Apr 24 10:34:24 2019 -0700
Fix raw HTML in SliceAdder (#7338)
---
superset/assets/src/dashboard/actions/sliceEntities.js | 1 +
superset/assets/src/dashboard/components/SliceAdder.jsx | 3 +--
superset/models/core.py | 1 +
superset/models/helpers.py | 7 +++++--
superset/views/core.py | 6 ++++--
5 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/superset/assets/src/dashboard/actions/sliceEntities.js
b/superset/assets/src/dashboard/actions/sliceEntities.js
index e98d28b..efee23e 100644
--- a/superset/assets/src/dashboard/actions/sliceEntities.js
+++ b/superset/assets/src/dashboard/actions/sliceEntities.js
@@ -77,6 +77,7 @@ export function fetchAllSlices(userId) {
description_markdown: slice.description_markeddown,
viz_type: slice.viz_type,
modified: slice.modified,
+ changed_on_humanized: slice.changed_on_humanized,
};
}
});
diff --git a/superset/assets/src/dashboard/components/SliceAdder.jsx
b/superset/assets/src/dashboard/components/SliceAdder.jsx
index 9359759..dd6ad56 100644
--- a/superset/assets/src/dashboard/components/SliceAdder.jsx
+++ b/superset/assets/src/dashboard/components/SliceAdder.jsx
@@ -170,7 +170,6 @@ class SliceAdder extends React.Component {
chartId: cellData.slice_id,
sliceName: cellData.slice_name,
};
-
return (
<DragDroppable
key={key}
@@ -202,7 +201,7 @@ class SliceAdder extends React.Component {
innerRef={dragSourceRef}
style={style}
sliceName={cellData.slice_name}
- lastModified={cellData.modified}
+ lastModified={cellData.changed_on_humanized}
visType={cellData.viz_type}
datasourceLink={cellData.datasource_link}
isSelected={isSelected}
diff --git a/superset/models/core.py b/superset/models/core.py
index b848604..f9a2a70 100644
--- a/superset/models/core.py
+++ b/superset/models/core.py
@@ -243,6 +243,7 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
'slice_name': self.slice_name,
'slice_url': self.slice_url,
'modified': self.modified(),
+ 'changed_on_humanized': self.changed_on_humanized,
'changed_on': self.changed_on.isoformat(),
}
diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index a1e9b3c..78b438d 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -288,10 +288,13 @@ class AuditMixinNullable(AuditMixin):
def changed_on_(self):
return Markup(f'<span class="no-wrap">{self.changed_on}</span>')
+ @property
+ def changed_on_humanized(self):
+ return humanize.naturaltime(datetime.now() - self.changed_on)
+
@renders('changed_on')
def modified(self):
- time_str = humanize.naturaltime(datetime.now() - self.changed_on)
- return Markup(f'<span class="no-wrap">{time_str}</span>')
+ return Markup(f'<span
class="no-wrap">{self.changed_on_humanized}</span>')
class QueryResult(object):
diff --git a/superset/views/core.py b/superset/views/core.py
index c599bfe..04fff7b 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -576,7 +576,8 @@ class SliceAsync(SliceModelView): # noqa
route_base = '/sliceasync'
list_columns = [
'id', 'slice_link', 'viz_type', 'slice_name',
- 'creator', 'modified', 'icons']
+ 'creator', 'modified', 'icons', 'changed_on_humanized',
+ ]
label_columns = {
'icons': ' ',
'slice_link': _('Chart'),
@@ -592,7 +593,8 @@ class SliceAddView(SliceModelView): # noqa
'id', 'slice_name', 'slice_url', 'edit_url', 'viz_type', 'params',
'description', 'description_markeddown', 'datasource_id',
'datasource_type',
'datasource_name_text', 'datasource_link',
- 'owners', 'modified', 'changed_on']
+ 'owners', 'modified', 'changed_on', 'changed_on_humanized',
+ ]
appbuilder.add_view_no_menu(SliceAddView)