rusackas commented on a change in pull request #11820:
URL: 
https://github.com/apache/incubator-superset/pull/11820#discussion_r532874338



##########
File path: superset-frontend/src/api/dataset.ts
##########
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { SupersetClient, JsonResponse } from '@superset-ui/core';
+import rison from 'rison';
+import Dataset from 'src/types/Dataset';
+
+const returnResult = async (endpoint: string) => {
+  const {
+    json: {
+      json: { result },
+    },
+  } = await SupersetClient.get({
+    endpoint,
+  });
+  return result;
+};
+
+export const importDataset = async (datasetFile: File) => {
+  const endpoint = encodeURI(`/api/v1/dataset/import/`);
+  const formData = new FormData();
+  formData.append('formData', datasetFile);
+  const response: JsonResponse = await SupersetClient.post({
+    endpoint,
+    body: formData,
+  });
+  return Promise.resolve(response);
+};
+
+export const get = async () => {
+  const queryParams = rison.encode({
+    order_column: 'changed_on_delta_humanized',
+    order_direction: 'desc',
+    page: 0,
+    page_size: 10,
+  });
+  const endpoint = `/api/v1/dataset?q=${queryParams}`;
+  const result = await returnResult(endpoint);
+  return Promise.resolve(result);
+};
+
+export const show = async (id: number) => {
+  const endpoint = `/api/v1/dataset${id}`;
+  const result = await returnResult(endpoint);
+  return Promise.resolve(result);
+};
+
+export const getRelated = async (id: number) => {
+  const endpoint = `/api/v1/dataset/${id}/related_objects`;
+  const result = await returnResult(endpoint);
+  return Promise.resolve(result);
+};
+
+export const destroy = async (id: number) => {

Review comment:
       I'm generally a fan of both consistency and explicitness. I think 
`deleteDataset` scratches both itches. Also, if you needed to `import` a 
`delete` function from multiple files/models, you'd probably wind up doing 
`import {delete as deleteDataset} ...` or something similar anyway. This would 
force the pattern up front, which I think is good.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to