Fix raw HTML in SliceAdder (#7338)

This commit is contained in:
Maxime Beauchemin 2019-04-24 10:34:24 -07:00 committed by GitHub
parent f58e7b204e
commit fef5b5efb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View File

@ -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,
};
}
});

View File

@ -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}

View File

@ -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(),
}

View File

@ -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):

View File

@ -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)