williaster commented on a change in pull request #5524: A tagging system for
dashboards, charts and queries
URL:
https://github.com/apache/incubator-superset/pull/5524#discussion_r207977741
##########
File path: superset/assets/src/tags.js
##########
@@ -0,0 +1,78 @@
+import 'whatwg-fetch';
+import { getCSRFToken } from './modules/utils';
+
+export function fetchTags(objectType, objectId, includeTypes, callback) {
+ const url = `/tagview/tags/${objectType}/${objectId}/`;
+ window.fetch(url)
+ .then(response => response.json())
+ .then(json => callback(
+ json.filter(tag => tag.name.indexOf(':') === -1 || includeTypes)));
+}
+
+export function fetchSuggestions(includeTypes, callback) {
+ window.fetch('/tagview/tags/suggestions/')
+ .then(response => response.json())
+ .then(json => callback(
+ json.filter(tag => tag.name.indexOf(':') === -1 || includeTypes)));
+}
+
+export function deleteTag(objectType, objectId, tag, callback, error) {
+ const url = `/tagview/tags/${objectType}/${objectId}/`;
+ const CSRF_TOKEN = getCSRFToken();
+ window.fetch(url, {
+ body: JSON.stringify([tag]),
+ headers: {
+ 'content-type': 'application/json',
+ 'X-CSRFToken': CSRF_TOKEN,
+ },
+ credentials: 'same-origin',
+ method: 'DELETE',
+ })
+ .then((response) => {
+ if (response.ok) {
+ callback(response);
+ } else {
+ error(response);
+ }
+ });
+}
+
+export function addTag(objectType, objectId, includeTypes, tag, callback,
error) {
Review comment:
a function with this many arguments should take an object with named keys as
input, this is super error prone.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]