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

feat: Database Connection UI #14881

Merged
merged 176 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
05a1bb7
split db modal file
eschutho Apr 21, 2021
a8afce9
split db modal file
eschutho Apr 21, 2021
b69bf16
hook up available databases
eschutho Apr 28, 2021
6eae68c
add comment
eschutho May 18, 2021
e8cd4f4
split db modal file
eschutho Apr 21, 2021
95917e4
hook up available databases
eschutho Apr 28, 2021
e764072
use new validation component
eschutho May 21, 2021
842f856
first draft
AAfghahi May 25, 2021
7cb4098
use new validation component
eschutho May 21, 2021
253053b
first draft
AAfghahi May 26, 2021
a47d52d
first draft
AAfghahi May 26, 2021
8cec32b
merge
AAfghahi May 26, 2021
5a785d7
Merge branch 'master' of https://github.com/apache/superset into pexd…
hughhhh May 27, 2021
92d81b9
using paxdax feature branch
AAfghahi May 28, 2021
6d0c45f
Creating IconButton
lyndsiWilliams May 19, 2021
b0cdaba
Changed naming: logo is now icon
lyndsiWilliams Jun 1, 2021
8d96434
Hard-coded inset values for ellipses
lyndsiWilliams Jun 1, 2021
3eea36d
Removed default SVG
lyndsiWilliams Jun 1, 2021
b0ab2da
Fixed test
lyndsiWilliams Jun 1, 2021
19a4c3a
get tests passing
AAfghahi Jun 1, 2021
c8b148e
Removed logo from test
lyndsiWilliams Jun 1, 2021
e7f0dbb
split db modal file
eschutho Apr 21, 2021
b57d090
hook up available databases
eschutho Apr 28, 2021
271c6e9
use new validation component
eschutho May 21, 2021
ef63e3c
feat(db-connection-ui): Allow users to pick engine (#14884)
hughhhh Jun 1, 2021
013674b
Merge branch 'pexdax/db-connection-ui' into ch6732_editDBModal
AAfghahi Jun 1, 2021
8907bc1
Merge branch 'lyndsi/create-icon-button' of https://github.com/preset…
hughhhh Jun 1, 2021
96a87d8
saving for now
hughhhh Jun 1, 2021
9246710
revisions
AAfghahi Jun 1, 2021
0457bfe
fix conflicts
hughhhh Jun 1, 2021
502abec
fix package-lock.json
hughhhh Jun 1, 2021
717c9ab
update styles
hughhhh Jun 2, 2021
e299bfa
save
hughhhh Jun 2, 2021
25b435b
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi Jun 1, 2021
29a899d
# This is a combination of 6 commits.
eschutho Jun 1, 2021
f45cae2
fix test for db modal
hughhhh Jun 2, 2021
1aae834
feat(db-connection-ui): Allow users to pick engine (#14884)
hughhhh Jun 1, 2021
a380629
Merge branch 'master' into pexdax/db-connection-ui
hughhhh Jun 2, 2021
c4125fb
pulling feature branch
AAfghahi Jun 2, 2021
95c7f66
more revisions
AAfghahi Jun 2, 2021
8cfa0d8
create 1 function for setting the DB
hughhhh Jun 2, 2021
7c610d5
add function to preferred section
hughhhh Jun 2, 2021
dcf8144
small refactor and added styling
hughhhh Jun 2, 2021
e539834
used db.backend
AAfghahi Jun 2, 2021
ef23e53
add new footer buttons
hughhhh Jun 2, 2021
2602827
add finsh buttong
hughhhh Jun 2, 2021
530150e
refactor db modal render
hughhhh Jun 2, 2021
508a6b9
fix comments issue
hughhhh Jun 2, 2021
47c30cb
added engine to model
AAfghahi Jun 2, 2021
9fac1eb
elizabeth revisions
AAfghahi Jun 2, 2021
607e01a
add header
hughhhh Jun 3, 2021
b343ca4
add bottom footer to sqlalchemy form
hughhhh Jun 3, 2021
145b947
# This is a combination of 6 commits.
eschutho Jun 1, 2021
cea7b6c
fix test for db modal
hughhhh Jun 2, 2021
d5c5167
feat(db-connection-ui): Allow users to pick engine (#14884)
hughhhh Jun 1, 2021
78d7edb
elizabeth revisions
AAfghahi Jun 3, 2021
0df0cab
add back headers
hughhhh Jun 3, 2021
0d3c31d
fix merge conflicts
hughhhh Jun 3, 2021
c21987f
add step
hughhhh Jun 3, 2021
fc6d5d9
Merge branch 'pexdax/db-connection-ui' into ch6732_editDBModal
AAfghahi Jun 3, 2021
b8e6687
feat: Dynamic Form for edit DB Modal (#14845)
AAfghahi Jun 3, 2021
9d2b36e
address comments
hughhhh Jun 4, 2021
6c9fc9c
fix merge conflicts
hughhhh Jun 4, 2021
4aa2428
oops
hughhhh Jun 4, 2021
c0a8c74
# This is a combination of 6 commits.
eschutho Jun 1, 2021
907165f
fix test for db modal
hughhhh Jun 2, 2021
e3a87b9
feat(db-connection-ui): Allow users to pick engine (#14884)
hughhhh Jun 1, 2021
2cbe31e
working edit db dynamic modal
hughhhh Jun 4, 2021
514ec63
working preferred branch
hughhhh Jun 4, 2021
5a604e3
remove merge conflicts
hughhhh Jun 4, 2021
120866c
small fix on blocking creating
hughhhh Jun 4, 2021
298f660
feat(db-connection-ui): Big Query Add Database Form (#14829)
hughhhh Jun 5, 2021
860efef
feat: adding SSL Toggle to Create Database Modal (#14976)
AAfghahi Jun 5, 2021
07d619e
Merge branch 'master' of https://github.com/apache/superset into pexd…
hughhhh Jun 7, 2021
f2b8b04
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh Jun 7, 2021
addb946
pull from master
hughhhh Jun 9, 2021
a9eda01
feat(database-connection-ui) Allow configuration of Database Images f…
hughhhh Jun 9, 2021
c2213fc
fix bug
hughhhh Jun 9, 2021
a95e416
additional params to the DatabaseConnectionForm (#15071)
hughhhh Jun 9, 2021
cbbb257
feat: Added Steps and centralized Headers (#15041)
AAfghahi Jun 10, 2021
5eea4f3
Merge branch 'master' of https://github.com/apache/superset into pexd…
hughhhh Jun 10, 2021
c66a853
fix superset_text issue (#15095)
hughhhh Jun 10, 2021
3105020
fix edit issue by returning parameters properly (#15101)
hughhhh Jun 10, 2021
5cb4871
feat: added alerts (#15103)
AAfghahi Jun 11, 2021
91e1045
fix: add icons (#15122)
AAfghahi Jun 11, 2021
8fe2ec8
Update superset-frontend/src/views/CRUD/data/database/DatabaseModal/i…
hughhhh Jun 11, 2021
461f64b
fix: fixing api tests for database connections (#15124)
AAfghahi Jun 11, 2021
ad706d2
fix(db-connection-ui): Additional Query Parameters render (#15150)
hughhhh Jun 14, 2021
9443344
feat(db-connection-ui): Move fields from Extra section and split engi…
hughhhh Jun 15, 2021
3c5ce99
style: Database connect UI Polish - Step 1 (#15119)
lyndsiWilliams Jun 15, 2021
4512228
fix app from merge
hughhhh Jun 15, 2021
bd05f95
fix merge conflicts
hughhhh Jun 15, 2021
3076179
fix tslint issues
hughhhh Jun 15, 2021
0f38996
fix all tslint issue on feature branch
hughhhh Jun 15, 2021
e773c8a
catch errors for dialects with no driver set
hughhhh Jun 15, 2021
2aacd79
fix dremio issue
hughhhh Jun 15, 2021
2052234
fix dialect issue without driver attr
hughhhh Jun 15, 2021
4c74998
Styled step 3 (#15187)
lyndsiWilliams Jun 16, 2021
7089580
feat: adding server-side validation and unmasked password on create (…
AAfghahi Jun 16, 2021
1a954ff
feat: add Close/Finish buttons to DBModal on Edit (#15199)
AAfghahi Jun 16, 2021
f452789
fix(db-connection-ui): Allow Dynamic Big Query Edits (#15185)
hughhhh Jun 16, 2021
a03ad40
fix: Connect on DB Connection wasn't working (#15201)
AAfghahi Jun 16, 2021
9efb2d2
make available alphabetically sort
hughhhh Jun 16, 2021
dee8b24
make available alphabetically sort II
hughhhh Jun 16, 2021
4bfc64b
fix selection
hughhhh Jun 16, 2021
f1ff72f
remove console.log
hughhhh Jun 16, 2021
7b4ae58
fix styling
hughhhh Jun 16, 2021
52f9658
fix: fix api_test and typeScript error (#15202)
AAfghahi Jun 16, 2021
301eb51
fix big query issue
hughhhh Jun 16, 2021
cbbcf1b
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh Jun 16, 2021
c32a387
allow for query params
hughhhh Jun 17, 2021
9cecb8b
feat: Added Dynamic form link to SQL Alchemy Form (#15208)
AAfghahi Jun 17, 2021
0b306a4
Merge branch 'master' into pexdax/db-connection-ui
hughhhh Jun 17, 2021
f8acc5f
fix: fix api tests for test_available (#15210)
AAfghahi Jun 17, 2021
0a517a0
feat: added Spinner to DB Modal (#15229)
AAfghahi Jun 17, 2021
ad3bbfb
Made header sticky (#15204)
lyndsiWilliams Jun 17, 2021
7505601
fix: make Edit DB modal look similar to create Modal (#15231)
AAfghahi Jun 17, 2021
7270d26
fix: DB Connection UI R2 Fixes (#15232)
hughhhh Jun 17, 2021
b557935
small fixes on bigquery edit
hughhhh Jun 17, 2021
65b0241
only wrap encrypted with bigquery
hughhhh Jun 17, 2021
8ff4f7b
specific conditions for wrapping big query items
hughhhh Jun 17, 2021
1570642
dix additional params
hughhhh Jun 17, 2021
243af7f
Merge branch 'master' of https://github.com/apache/superset into pexd…
hughhhh Jun 17, 2021
7ff8777
fix allow display name in sqlalchemy form
hughhhh Jun 17, 2021
4dfa544
backend before engine
hughhhh Jun 17, 2021
c1a0fc9
fix: do not use Marshmallow validation in partial params validation (…
betodealmeida Jun 17, 2021
27efb29
make display name required
hughhhh Jun 17, 2021
9d9b681
reset validation errors onClose (#15243)
hughhhh Jun 18, 2021
b9ffd41
fix: Edit for all dynamic forms (#15244)
hughhhh Jun 18, 2021
1f45607
wrap configuration method (#15274)
hughhhh Jun 19, 2021
19dd302
add more specific engine elastic search (#15287)
hughhhh Jun 22, 2021
d9d863b
do a deep copy of obj before POST (#15298)
hughhhh Jun 22, 2021
e7f71f3
feat: add Back button to extra options (#15300)
AAfghahi Jun 22, 2021
b6138cf
chore: Add tooltips and button to Connect Postgresql DB Modal Form (#…
andrewbastian Jun 22, 2021
a64f1e7
style: Database Modal UI Polish (#15234)
lyndsiWilliams Jun 22, 2021
7c42a7c
feat: allow editing (#15308)
AAfghahi Jun 22, 2021
5de931a
feat: Added error alert for DB connection Modal (#15242)
AAfghahi Jun 22, 2021
725f406
fix: validation on edit (#15310)
hughhhh Jun 22, 2021
c64ad88
fix: Big Query Error messaging (#15334)
hughhhh Jun 23, 2021
c283be6
update styles
hughhhh Jun 23, 2021
bc727f4
feat: big Query using back button (#15338)
AAfghahi Jun 23, 2021
913b29c
fix: password errors on validation (#15372)
hughhhh Jun 24, 2021
56480ea
feat: updated Error Alert (#15377)
AAfghahi Jun 25, 2021
df46a25
Updated styling (#15379)
lyndsiWilliams Jun 25, 2021
d9b743d
fix password error filter
hughhhh Jun 25, 2021
7b5e468
feat: Arash/password field error (#15388)
AAfghahi Jun 25, 2021
08318fc
fix: Back Button on Create for DB conncetion (#15389)
AAfghahi Jun 25, 2021
4db07e2
fix doc (#15393)
hughhhh Jun 25, 2021
dd47bde
style: Database Connection Modal UI Polish R5 (#15412)
lyndsiWilliams Jun 28, 2021
ef0b393
make alerts configurable (#15404)
hughhhh Jun 28, 2021
4b46a17
fix: Allow users to override database connection docs (#15434)
hughhhh Jun 28, 2021
74ce6e6
fix: Error Icon not showing up on errored input fieds on validation …
andrewbastian Jun 29, 2021
c3193a8
test: RTL testing on DatabaseModal (#15394)
lyndsiWilliams Jun 29, 2021
bb396a7
test: Add e2e testing (#15376)
hughhhh Jun 29, 2021
5873784
fix merge conflicts
hughhhh Jun 29, 2021
2db0f25
Fixed "connetion" typo (#15458)
lyndsiWilliams Jun 29, 2021
3eb6db8
fix: Database connection modal touch up (#15463)
lyndsiWilliams Jun 29, 2021
26a411d
Update modal.test.ts
hughhhh Jun 29, 2021
47644d5
fix: Showing errors for SQLA forms (#15462)
hughhhh Jun 29, 2021
44504f5
Merge branch 'master' of https://github.com/apache/superset into pexd…
hughhhh Jun 29, 2021
1ce8104
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh Jun 29, 2021
5bfbfff
fix: Update Invalid Port SIP-40 Reference (#15464)
hughhhh Jun 29, 2021
4cae8cd
Merge branch 'master' into pexdax/db-connection-ui
hughhhh Jun 30, 2021
f8da689
fix: Edit Modal not saving properly (#15468)
AAfghahi Jun 30, 2021
ea48784
fix: merge conflict (#15479)
betodealmeida Jun 30, 2021
ea45822
fix print on additional params
hughhhh Jun 30, 2021
5639c51
Merge branch 'master' into pexdax/db-connection-ui
hughhhh Jun 30, 2021
7d81622
Merge branch 'master' into pexdax/db-connection-ui
betodealmeida Jun 30, 2021
bcfcdba
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh Jul 1, 2021
a673ab6
address comments
hughhhh Jul 1, 2021
b749d6d
fix merge conflicts
hughhhh Jul 1, 2021
0a4ad16
fix pre-commit
hughhhh Jul 1, 2021
46621fc
fix linting
hughhhh Jul 1, 2021
1a16c49
fix: error mapping in database connection (#15504)
AAfghahi Jul 1, 2021
4fc5589
fix: RTL for Database Connections (#15513)
AAfghahi Jul 1, 2021
b20882f
fix: Allow for updates on Step 3 (#15512)
hughhhh Jul 1, 2021
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
8 changes: 8 additions & 0 deletions docs/src/pages/docs/Miscellaneous/issue_codes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ The results stored in the backend were stored in a different format, and no long

The query results were stored in a format that is no longer supported. Please re-run your query.

## Issue 1034

```
The database port provided is invalid.
```

Please check that the provided database port is an integer between 0 and 65535 (inclusive).

## Issue 1035

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,71 +21,50 @@ import { DATABASE_LIST } from './helper';
describe('Add database', () => {
beforeEach(() => {
cy.login();
});

it('should keep create modal open when error', () => {
cy.visit(DATABASE_LIST);

// open modal
cy.wait(3000);
cy.get('[data-test="btn-create-database"]').click();
});

// values should be blank
cy.get('[data-test="database-modal"] input[name="database_name"]').should(
'have.value',
'',
);
cy.get('[data-test="database-modal"] input[name="sqlalchemy_uri"]').should(
'have.value',
'',
);

// type values
cy.get('[data-test="database-modal"] input[name="database_name"]')
.focus()
.type('cypress');
cy.get('[data-test="database-modal"] input[name="sqlalchemy_uri"]')
.focus()
.type('bad_db_uri');

// click save
cy.get('[data-test="modal-confirm-button"]:not(:disabled)').click();

// should show error alerts and keep modal open
cy.get('.toast').contains('error');
cy.wait(1000); // wait for potential (incorrect) closing annimation
cy.get('[data-test="database-modal"]').should('be.visible');
it('should open dynamic form', () => {
// click postgres dynamic form
cy.get('.preferred > :nth-child(1)').click();

// should be able to close modal
cy.get('[data-test="modal-cancel-button"]').click();
cy.get('[data-test="database-modal"]').should('not.be.visible');
// make sure all the fields are rendering
cy.get('input[name="host"]').should('have.value', '');
cy.get('input[name="port"]').should('have.value', '');
cy.get('input[name="database"]').should('have.value', '');
cy.get('input[name="password"]').should('have.value', '');
cy.get('input[name="database_name"]').should('have.value', '');
});

it('should keep update modal open when error', () => {
// open modal
cy.get('[data-test="database-edit"]:last').click();

// it should show saved values
cy.get('[data-test="database-modal"]:last input[name="sqlalchemy_uri"]')
.invoke('val')
.should('not.be.empty');
cy.get('[data-test="database-modal"] input[name="database_name"]')
.invoke('val')
.should('not.be.empty');
it('should open sqlalchemy form', () => {
// click postgres dynamic form
cy.get('.preferred > :nth-child(1)').click();

cy.get('[data-test="database-modal"]:last input[name="sqlalchemy_uri"]')
.focus()
.dblclick()
.type('{selectall}{backspace}bad_uri');
cy.get('[data-test="sqla-connect-btn"]').click();

// click save
cy.get('[data-test="modal-confirm-button"]:not(:disabled)').click();
// check if the sqlalchemy form is showing up
cy.get('[data-test=database-name-input]').should('be.visible');
cy.get('[data-test="sqlalchemy-uri-input"]').should('be.visible');
});

// should show error alerts
// TODO(hugh): Update this test
// cy.get('.toast').contains('error').should('be.visible');
it('show error alerts on dynamic form for bad host', () => {
// click postgres dynamic form
cy.get('.preferred > :nth-child(1)').click();
cy.get('input[name="host"]').focus().type('badhost');
cy.get('input[name="port"]').focus().type('5432');
cy.get('.ant-form-item-explain-error').contains(
"The hostname provided can't be resolved",
);
});

// modal should still be open
// cy.wait(1000); // wait for potential (incorrect) closing annimation
// cy.get('[data-test="database-modal"]').should('be.visible');
it('show error alerts on dynamic form for bad port', () => {
// click postgres dynamic form
cy.get('.preferred > :nth-child(1)').click();
cy.get('input[name="host"]').focus().type('localhost');
cy.get('input[name="port"]').focus().type('123');
cy.get('input[name="database"]').focus();
cy.get('.ant-form-item-explain-error').contains('The port is closed');
});
});
21 changes: 21 additions & 0 deletions superset-frontend/images/icons/default_db_image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"react-js-cron": "^1.2.0",
"react-json-tree": "^0.11.2",
"react-jsonschema-form": "^1.2.0",
"react-lines-ellipsis": "^0.15.0",
"react-loadable": "^5.5.0",
"react-markdown": "^4.3.1",
"react-redux": "^7.2.0",
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/components/ErrorMessage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const ErrorTypeEnum = {
CONNECTION_INVALID_PASSWORD_ERROR: 'CONNECTION_INVALID_PASSWORD_ERROR',
CONNECTION_INVALID_HOSTNAME_ERROR: 'CONNECTION_INVALID_HOSTNAME_ERROR',
CONNECTION_PORT_CLOSED_ERROR: 'CONNECTION_PORT_CLOSED_ERROR',
CONNECTION_INVALID_PORT_ERROR: 'CONNECTION_INVALID_PORT_ERROR',
CONNECTION_HOST_DOWN_ERROR: 'CONNECTION_HOST_DOWN_ERROR',
CONNECTION_ACCESS_DENIED_ERROR: 'CONNECTION_ACCESS_DENIED_ERROR',
CONNECTION_UNKNOWN_DATABASE_ERROR: 'CONNECTION_UNKNOWN_DATABASE_ERROR',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const InteractiveLabeledErrorBoundInput = ({
placeholder,
type,
id,
tooltipText,
}: LabeledErrorBoundInputProps) => {
const [currentValue, setCurrentValue] = useState(value);

Expand All @@ -58,6 +59,8 @@ export const InteractiveLabeledErrorBoundInput = ({
placeholder={placeholder}
type={type}
required
hasTooltip
tooltipText={tooltipText}
/>
);
};
Expand All @@ -66,6 +69,7 @@ InteractiveLabeledErrorBoundInput.args = {
name: 'Username',
placeholder: 'Example placeholder text...',
id: 1,
tooltipText: 'This is a tooltip',
};

InteractiveLabeledErrorBoundInput.argTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import { render, fireEvent, screen } from 'spec/helpers/testing-library';
import LabeledErrorBoundInput from 'src/components/Form/LabeledErrorBoundInput';

const defaultProps = {
Expand All @@ -27,6 +27,8 @@ const defaultProps = {
validationMethods: () => {},
errorMessage: '',
helpText: 'This is a line of example help text',
hasTooltip: false,
tooltipText: 'This is a tooltip',
value: '',
placeholder: 'Example placeholder text...',
type: 'textbox',
Expand Down Expand Up @@ -58,4 +60,19 @@ describe('LabeledErrorBoundInput', () => {
expect(textboxInput).toBeVisible();
expect(errorText).toBeVisible();
});
it('renders a LabledErrorBoundInput with a InfoTooltip', async () => {
defaultProps.hasTooltip = true;
render(<LabeledErrorBoundInput {...defaultProps} />);

const label = screen.getByText(/username/i);
const textboxInput = screen.getByRole('textbox');
const tooltipIcon = screen.getByRole('img');

fireEvent.mouseOver(tooltipIcon);

expect(tooltipIcon).toBeVisible();
expect(label).toBeVisible();
expect(textboxInput).toBeVisible();
expect(await screen.findByText('This is a tooltip')).toBeInTheDocument();
});
});
35 changes: 30 additions & 5 deletions superset-frontend/src/components/Form/LabeledErrorBoundInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import React from 'react';
import { Input } from 'antd';
import { styled, css, SupersetTheme } from '@superset-ui/core';
import InfoTooltip from 'src/components/InfoTooltip';
import errorIcon from 'images/icons/error.svg';
import FormItem from './FormItem';
import FormLabel from './FormLabel';

Expand All @@ -30,6 +32,8 @@ export interface LabeledErrorBoundInputProps {
errorMessage: string | null;
helpText?: string;
required?: boolean;
hasTooltip?: boolean;
tooltipText?: string | null;
id?: string;
classname?: string;
[x: string]: any;
Expand All @@ -46,42 +50,63 @@ const alertIconStyles = (theme: SupersetTheme, hasError: boolean) => css`
${hasError &&
`.ant-form-item-control-input-content {
position: relative;

&:after {
content: ' ';
display: inline-block;
background: ${theme.colors.error.base};
mask: url('/images/icons/error.svg');
mask: url(${errorIcon});
mask-size: cover;
width: ${theme.gridUnit * 4}px;
height: ${theme.gridUnit * 4}px;
position: absolute;
right: 7px;
top: 15px;
right: ${theme.gridUnit * 1.25}px;
top: ${theme.gridUnit * 2.75}px;
}
}`}
`;

const StyledFormGroup = styled('div')`
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
margin-bottom: ${({ theme }) => theme.gridUnit * 5}px;
.ant-form-item {
margin-bottom: 0;
}
`;

const infoTooltip = (theme: SupersetTheme) => css`
svg {
vertical-align: bottom;
margin-bottom: ${theme.gridUnit * 0.25}px;
}
`;

const LabeledErrorBoundInput = ({
label,
validationMethods,
errorMessage,
helpText,
required = false,
hasTooltip = false,
tooltipText,
id,
className,
...props
}: LabeledErrorBoundInputProps) => (
<StyledFormGroup className={className}>
<FormLabel htmlFor={id} required={required}>
<FormLabel
htmlFor={id}
required={required}
css={(theme: SupersetTheme) => infoTooltip(theme)}
>
{label}
</FormLabel>
{hasTooltip && (
<InfoTooltip tooltip={`${tooltipText}`} viewBox="0 -6 24 24" />
)}
<FormItem
css={(theme: SupersetTheme) => alertIconStyles(theme, !!errorMessage)}
validateTrigger={Object.keys(validationMethods)}
Expand Down
3 changes: 3 additions & 0 deletions superset-frontend/src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ import { ReactComponent as WarningIcon } from 'images/icons/warning.svg';
import { ReactComponent as WarningSolidIcon } from 'images/icons/warning_solid.svg';
import { ReactComponent as XLargeIcon } from 'images/icons/x-large.svg';
import { ReactComponent as XSmallIcon } from 'images/icons/x-small.svg';
import { ReactComponent as DefaultDatabaseIcon } from 'images/icons/default_db_image.svg';

export type IconName =
| 'alert'
Expand Down Expand Up @@ -184,6 +185,7 @@ export type IconName =
| 'copy'
| 'cursor-target'
| 'database'
| 'default-database'
| 'dataset-physical'
| 'dataset-virtual'
| 'dataset-virtual-greyscale'
Expand Down Expand Up @@ -299,6 +301,7 @@ export const iconsRegistry: Record<
'circle-check-solid': CircleCheckSolidIcon,
'color-palette': ColorPaletteIcon,
'cursor-target': CursorTargeIcon,
'default-database': DefaultDatabaseIcon,
'dataset-physical': DatasetPhysicalIcon,
'dataset-virtual': DatasetVirtualIcon,
'dataset-virtual-greyscale': DatasetVirtualGreyscaleIcon,
Expand Down
Loading