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

Fix raw HTML in SliceAdder #7338

Merged
merged 1 commit into from
Apr 24, 2019
Merged
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 superset/assets/src/dashboard/actions/sliceEntities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
});
Expand Down
3 changes: 1 addition & 2 deletions superset/assets/src/dashboard/components/SliceAdder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class SliceAdder extends React.Component {
chartId: cellData.slice_id,
sliceName: cellData.slice_name,
};

return (
<DragDroppable
key={key}
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def data(self):
'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(),
}

Expand Down
7 changes: 5 additions & 2 deletions superset/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,13 @@ def changed_by_(self):
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):
Expand Down
6 changes: 4 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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)
Expand Down