-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add dataset visuals for when a table is selected #21893
Changes from 4 commits
fa4f6a4
47bac70
ed095c1
f8b8d36
ca3e9a0
d9501c6
eb9a0d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,46 @@ | |
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { t, styled } from '@superset-ui/core'; | ||
import { supersetTheme, t, styled } from '@superset-ui/core'; | ||
import Icons from 'src/components/Icons'; | ||
import { EmptyStateBig } from 'src/components/EmptyState'; | ||
import RefreshLabel from 'src/components/RefreshLabel'; | ||
|
||
type DatasetPanelProps = { | ||
tableName?: string | null | undefined; | ||
}; | ||
|
||
const StyledEmptyStateBig = styled(EmptyStateBig)` | ||
p { | ||
width: ${({ theme }) => theme.gridUnit * 115}px; | ||
} | ||
`; | ||
|
||
const renderDescription = () => ( | ||
const StyledDatasetPanel = styled.div` | ||
padding: ${({ theme }) => theme.gridUnit * 8}px | ||
${({ theme }) => theme.gridUnit * 6}px; | ||
|
||
.table-name { | ||
font-size: ${({ theme }) => theme.gridUnit * 6}px; | ||
font-weight: ${({ theme }) => theme.typography.weights.medium}; | ||
padding-bottom: ${({ theme }) => theme.gridUnit * 20}px; | ||
margin: 0; | ||
|
||
.anticon:first-of-type { | ||
margin-right: ${({ theme }) => theme.gridUnit * 4}px; | ||
} | ||
|
||
.anticon:nth-of-type(2) { | ||
margin-left: ${({ theme }) => theme.gridUnit * 4}px; | ||
} | ||
} | ||
|
||
span { | ||
font-weight: ${({ theme }) => theme.typography.weights.bold}; | ||
} | ||
`; | ||
|
||
const renderEmptyDescription = () => ( | ||
<> | ||
{t( | ||
'Datasets can be created from database tables or SQL queries. Select a database table to the left or ', | ||
|
@@ -44,12 +74,29 @@ const renderDescription = () => ( | |
</> | ||
); | ||
|
||
export default function DatasetPanel() { | ||
return ( | ||
const DatasetPanel = ({ tableName }: DatasetPanelProps) => | ||
tableName ? ( | ||
<StyledDatasetPanel> | ||
<div className="table-name"> | ||
<Icons.Table iconColor={supersetTheme.colors.grayscale.base} /> | ||
{tableName} | ||
<RefreshLabel | ||
onClick={() => { | ||
console.log( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this console log necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not, it was more a flag/placeholder for when the functionality is added into the next ticket. |
||
'This will refresh table columns once the table component is implemented', | ||
); | ||
}} | ||
tooltipContent={t('Refresh table columns')} | ||
/> | ||
</div> | ||
<span>{t('Table columns')}</span> | ||
</StyledDatasetPanel> | ||
) : ( | ||
<StyledEmptyStateBig | ||
image="empty-dataset.svg" | ||
title={t('Select dataset source')} | ||
description={renderDescription()} | ||
description={renderEmptyDescription()} | ||
/> | ||
); | ||
} | ||
|
||
export default DatasetPanel; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,9 @@ export function datasetReducer( | |
} | ||
} | ||
|
||
const prevUrl = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is still temporary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure the status of this URL, I just moved it out so it didn't get lost in the middle of the other components. |
||
'/tablemodelview/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc'; | ||
|
||
export default function AddDataset() { | ||
const [dataset, setDataset] = useReducer< | ||
Reducer<Partial<DatasetObject> | null, DSReducerActionType> | ||
|
@@ -81,8 +84,10 @@ export default function AddDataset() { | |
dbId={dataset?.db?.id} | ||
/> | ||
); | ||
const prevUrl = | ||
'/tablemodelview/list/?pageIndex=0&sortColumn=changed_on_delta_humanized&sortOrder=desc'; | ||
|
||
const DatasetPanelComponent = () => ( | ||
<DatasetPanel tableName={dataset?.table_name} /> | ||
); | ||
|
||
const FooterComponent = () => ( | ||
<Footer url={prevUrl} datasetObject={dataset} /> | ||
|
@@ -92,7 +97,7 @@ export default function AddDataset() { | |
<DatasetLayout | ||
header={HeaderComponent()} | ||
leftPanel={LeftPanelComponent()} | ||
datasetPanel={DatasetPanel()} | ||
datasetPanel={DatasetPanelComponent()} | ||
footer={FooterComponent()} | ||
/> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the
null | undefined
taking into account that the field is optional? Cannot just be :tableName?: string
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah good call! Corrected in
this commit
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this prop is
null
when a table isn't selected so I added it to the type in thiscommit
. Undefined wasn't needed here though, so still a good call, thanks! 😁There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heheh ok ok 😄