You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/10/11 21:36:12 UTC

[GitHub] [superset] betodealmeida commented on a change in pull request #17063: fix: Owners selection in dataset edit UX

betodealmeida commented on a change in pull request #17063:
URL: https://github.com/apache/superset/pull/17063#discussion_r726579866



##########
File path: superset-frontend/src/datasource/DatasourceEditor.jsx
##########
@@ -374,6 +374,40 @@ const defaultProps = {
   onChange: () => {},
 };
 
+function OwnersSelector({ datasource, onChange }) {
+  const selectedOwners = datasource.owners.map(owner => ({
+    value: owner.id,
+    label: `${owner.first_name} ${owner.last_name}`,
+  }));
+  const loadOptions = useMemo(() => (search = '', page, pageSize) => {
+    const query = rison.encode({ filter: search, page, page_size: pageSize });
+    return SupersetClient.get({
+      endpoint: `/api/v1/chart/related/owners?q=${query}`,
+    }).then(response => ({
+      data: response.json.result.map(item => ({
+        value: item.value,
+        label: item.text,
+      })),
+      totalCount: response.json.count,
+    }));
+  });
+
+  return (
+    <Select
+      ariaLabel={t('Select owners')}
+      mode="multiple"
+      name="owners"
+      value={selectedOwners || []}
+      options={loadOptions}
+      onChange={newOwners => {
+        onChange(newOwners);
+      }}

Review comment:
       Nit:
   
   ```suggestion
         onChange={onChange}
   ```

##########
File path: superset-frontend/src/datasource/DatasourceEditor.jsx
##########
@@ -374,6 +374,40 @@ const defaultProps = {
   onChange: () => {},
 };
 
+function OwnersSelector({ datasource, onChange }) {
+  const selectedOwners = datasource.owners.map(owner => ({
+    value: owner.id,
+    label: `${owner.first_name} ${owner.last_name}`,
+  }));
+  const loadOptions = useMemo(() => (search = '', page, pageSize) => {
+    const query = rison.encode({ filter: search, page, page_size: pageSize });
+    return SupersetClient.get({
+      endpoint: `/api/v1/chart/related/owners?q=${query}`,

Review comment:
       The result is the same, but let's use `dataset` here instead of `chart`:
   
   ```suggestion
         endpoint: `/api/v1/dataset/related/owners?q=${query}`,
   ```




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org