eschutho commented on code in PR #20281: URL: https://github.com/apache/superset/pull/20281#discussion_r918197919
########## superset-frontend/src/explore/components/controls/DatasourceControl/index.jsx: ########## @@ -122,24 +126,62 @@ const EDIT_DATASET = 'edit_dataset'; const QUERY_PREVIEW = 'query_preview'; const SAVE_AS_DATASET = 'save_as_dataset'; +// If the string is longer than this value's number characters we add +// a tooltip for user can see the full name by hovering over the visually truncated string in UI +const VISIBLE_TITLE_LENGTH = 25; + +// 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" />, +}; + +// Render title for datasource with tooltip only if text is longer than VISIBLE_TITLE_LENGTH +export const renderDatasourceTitle = (displayString, tooltip) => + displayString.length > VISIBLE_TITLE_LENGTH ? ( + // Add a tooltip only for long names that will be visually truncated + <Tooltip title={tooltip}> + <span className="title-select">{displayString}</span> + </Tooltip> + ) : ( + <span title={tooltip} className="title-select"> + {displayString} + </span> + ); + +// Different data source types use different attributes for the display title +export const getDatasourceTitle = datasource => + datasource?.sql ?? datasource?.name ?? ''; + +// When this is a Query with SQL, we wnt the SQL to be the tooltip +export const getTooltip = datasource => + datasource?.sql ?? datasource?.name ?? ''; Review Comment: this is the same as get title? -- 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-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org