Skip to content
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

chore: Help user to find the input fields in the dataset editor #17824

Merged
merged 3 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions superset-frontend/src/components/Datasource/DatasourceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ const StyledLabelWrapper = styled.div`
}
`;

const StyledColumnsTabWrapper = styled.div`
.table > tbody > tr > td {
vertical-align: middle;
}

.ant-tag {
margin-top: ${({ theme }) => theme.gridUnit}px;
}
`;

const checkboxGenerator = (d, onChange) => (
<CheckboxControl value={d} onChange={onChange} />
);
Expand Down Expand Up @@ -297,7 +307,7 @@ function ColumnCollectionTable({
details={record.certification_details}
/>
)}
<EditableTitle canEdit title={v} onSaveTitle={onItemChange} />
<TextControl value={v} onChange={onItemChange} />
</StyledLabelWrapper>
) : (
<StyledLabelWrapper>
Expand Down Expand Up @@ -1040,11 +1050,6 @@ class DatasourceEditor extends React.PureComponent {
expandFieldset={
<FormContainer>
<Fieldset compact>
<Field
fieldKey="verbose_name"
label={t('Label')}
control={<TextControl controlId="verbose_name" />}
/>
<Field
fieldKey="description"
label={t('Description')}
Expand Down Expand Up @@ -1127,15 +1132,17 @@ class DatasourceEditor extends React.PureComponent {
</FlexRowContainer>
),
verbose_name: (v, onChange) => (
<EditableTitle canEdit title={v} onSaveTitle={onChange} />
<TextControl canEdit value={v} onChange={onChange} />
),
expression: (v, onChange) => (
<EditableTitle
<TextAreaControl
canEdit
title={v}
onSaveTitle={onChange}
initialValue={v}
onChange={onChange}
extraClasses={['datasource-sql-expression']}
multiLine
language="sql"
offerEditInModal={false}
minLines={5}
/>
),
description: (v, onChange, label) => (
Expand Down Expand Up @@ -1209,7 +1216,7 @@ class DatasourceEditor extends React.PureComponent {
}
key={2}
>
<div>
<StyledColumnsTabWrapper>
<ColumnButtonWrapper>
<span className="m-t-10 m-r-10">
<Button
Expand All @@ -1226,13 +1233,14 @@ class DatasourceEditor extends React.PureComponent {
</ColumnButtonWrapper>
<ColumnCollectionTable
className="columns-table"
editableColumnName
columns={this.state.databaseColumns}
onChange={databaseColumns =>
this.setColumns({ databaseColumns })
}
/>
{this.state.metadataLoading && <Loading />}
</div>
</StyledColumnsTabWrapper>
</Tabs.TabPane>
<Tabs.TabPane
tab={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('DatasourceEditor', () => {
});
userEvent.click(getToggles[0]);
const getTextboxes = screen.getAllByRole('textbox');
expect(getTextboxes.length).toEqual(5);
expect(getTextboxes.length).toEqual(12);

const inputLabel = screen.getByPlaceholderText('Label');
const inputDescription = screen.getByPlaceholderText('Description');
Expand Down Expand Up @@ -122,10 +122,9 @@ describe('DatasourceEditor', () => {
});
expect(addBtn).toBeInTheDocument();
userEvent.click(addBtn);
const newColumn = screen.getByRole('button', {
name: /<new column>/i,
});
expect(newColumn).toBeInTheDocument();
// newColumn (Column name) is the first textbox in the tab
const newColumn = screen.getAllByRole('textbox', { name: '' })[0];
expect(newColumn).toHaveValue('<new column>');
});

it('renders isSqla fields', () => {
Expand Down