GitHub user qingshan007 added a comment to the discussion: On the chart editing 
screen, the icon of dataset should be similar to those used on the “Dataset” 
screen.

**Problem Investigation:**

After investigation, it was found that the rendering type was incorrect
Create a chart type that is always table
datasource type: table

On the chart construction page, switch datasets (virtual or physical):

datasource type: virtual
datasource type: physical

Without modifying or destroying the original logic of the newly created dataset:
Locate to: 
superset-frontend\src\explore\components\controls\DatasourceControl\index.jsx

1. Add judgment logic, where the physical dataset SQL field is always='', and 
the virtual one is the SQL during construction:
````
const dynamicDatasourceType = datasource?.sql
      ? DatasourceType.Query
      : DatasourceType.Table;
````

2. Use a new judgment:
```
{/* {datasourceIconLookup[datasource?.type]} */}
↓
{datasourceIconLookup[dynamicDatasourceType]}
```

3. Modify the icon:

```
// Assign icon for each DatasourceType.   If no icon assingment is found in the 
lookup, no icon will render
// export const datasourceIconLookup = {
//   [DatasourceType.Query]: (
//     <Icons. ConsoleSqlOutlined className="datasource-svg" />
//   ),
//   [DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" 
/>,
// };
↓
export const datasourceIconLookup = {
[DatasourceType.Query]: <Icons.DatasetVirtual className="datasource-svg" />,
[DatasourceType.Table]: <Icons.DatasetPhysical className="datasource-svg" />,
};
```

4. Result:
Switch datasets and display icons of corresponding types
Create a regular chart OR by entering it from the dataset page and displaying 
the corresponding type of icon

GitHub link: 
https://github.com/apache/superset/discussions/33366#discussioncomment-13045006

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


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

Reply via email to