-
Notifications
You must be signed in to change notification settings - Fork 17.4k
feat: base tabbed modal for new database CRUD UI #10668
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6114e45
Basic Database Add Modal UI
riahk 5b1edf8
Add customized antd modal to common
riahk a51106d
tweaks
riahk cdffca8
translation wrapping
riahk 5b008ff
style tweaks
riahk 565f591
move tabs re-styling to common components
riahk 152ad91
add test + basic form state
riahk 62c563c
update database list spec
riahk dc9f701
fix lint + update style
riahk e4874ae
rm test code + unnecessary comments
riahk 2f9af9b
rm console statement
riahk f86c2ff
add URI field
riahk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
superset-frontend/spec/javascripts/views/CRUD/data/database/DatabaseModal_spec.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import React from 'react'; | ||
| import thunk from 'redux-thunk'; | ||
| import configureStore from 'redux-mock-store'; | ||
| import { styledMount as mount } from 'spec/helpers/theming'; | ||
|
|
||
| import DatabaseModal from 'src/views/CRUD/data/database/DatabaseModal'; | ||
| import Modal from 'src/common/components/Modal'; | ||
|
|
||
| // store needed for withToasts(DatabaseModal) | ||
| const mockStore = configureStore([thunk]); | ||
| const store = mockStore({}); | ||
|
|
||
| describe('DatabaseModal', () => { | ||
| const wrapper = mount(<DatabaseModal />, { context: { store } }); | ||
|
|
||
| it('renders', () => { | ||
| expect(wrapper.find(DatabaseModal)).toExist(); | ||
| }); | ||
|
|
||
| it('renders a Modal', () => { | ||
| expect(wrapper.find(Modal)).toExist(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import React from 'react'; | ||
| import styled from '@superset-ui/style'; | ||
| import { Modal as BaseModal } from 'src/common/components'; | ||
| import { t } from '@superset-ui/translation'; | ||
| import Button from 'src/views/CRUD/data/dataset/Button'; | ||
|
|
||
| interface ModalProps { | ||
| className?: string; | ||
| children: React.ReactNode; | ||
| disablePrimaryButton?: boolean; | ||
| onHide: () => void; | ||
| onHandledPrimaryAction: () => void; | ||
| primaryButtonName: string; | ||
| primaryButtonType?: 'primary' | 'danger'; | ||
| show: boolean; | ||
| title: React.ReactNode; | ||
| width?: string; | ||
| centered?: boolean; | ||
| } | ||
|
|
||
| const StyledModal = styled(BaseModal)` | ||
| .ant-modal-header { | ||
| background-color: ${({ theme }) => theme.colors.grayscale.light4}; | ||
| border-radius: ${({ theme }) => theme.borderRadius}px | ||
| ${({ theme }) => theme.borderRadius}px 0 0; | ||
|
|
||
| .ant-modal-title h4 { | ||
| display: flex; | ||
| margin: 0; | ||
| align-items: center; | ||
| } | ||
| } | ||
|
|
||
| .ant-modal-close-x { | ||
| display: flex; | ||
| align-items: center; | ||
|
|
||
| .close { | ||
| flex: 1 1 auto; | ||
| margin-bottom: 3px; | ||
| color: ${({ theme }) => theme.colors.secondary.dark1}; | ||
| font-size: 32px; | ||
| font-weight: ${({ theme }) => theme.typography.weights.light}; | ||
| } | ||
| } | ||
|
|
||
| .ant-modal-body { | ||
| padding: 18px; | ||
| } | ||
|
|
||
| .ant-modal-footer { | ||
| border-top: 1px solid ${({ theme }) => theme.colors.grayscale.light2}; | ||
| padding: 16px; | ||
|
|
||
| .btn { | ||
| font-size: 12px; | ||
| text-transform: uppercase; | ||
| } | ||
|
|
||
| .btn + .btn { | ||
| margin-left: 8px; | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export default function Modal({ | ||
| children, | ||
| disablePrimaryButton = false, | ||
| onHide, | ||
| onHandledPrimaryAction, | ||
| primaryButtonName, | ||
| primaryButtonType = 'primary', | ||
| show, | ||
| title, | ||
| width, | ||
| centered, | ||
| ...rest | ||
| }: ModalProps) { | ||
| return ( | ||
| <StyledModal | ||
| centered={!!centered} | ||
| onOk={onHandledPrimaryAction} | ||
| onCancel={onHide} | ||
| width={width || '600px'} | ||
| visible={show} | ||
| title={title} | ||
| closeIcon={ | ||
| <span className="close" aria-hidden="true"> | ||
| × | ||
| </span> | ||
| } | ||
| footer={[ | ||
| <Button key="back" onClick={onHide}> | ||
| {t('Cancel')} | ||
| </Button>, | ||
| <Button | ||
| key="submit" | ||
| disabled={disablePrimaryButton} | ||
| onClick={onHandledPrimaryAction} | ||
| > | ||
| {primaryButtonName} | ||
| </Button>, | ||
| ]} | ||
| {...rest} | ||
| > | ||
| {children} | ||
| </StyledModal> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import styled from '@superset-ui/style'; | ||
| import { Tabs as BaseTabs } from 'src/common/components'; | ||
|
|
||
| const Tabs = styled(BaseTabs)` | ||
| margin-top: -18px; | ||
|
|
||
| .ant-tabs-nav-list { | ||
| width: 100%; | ||
| } | ||
|
|
||
| .ant-tabs-tab { | ||
| flex: 1 1 auto; | ||
| width: 0; | ||
|
|
||
| &.ant-tabs-tab-active .ant-tabs-tab-btn { | ||
| color: inherit; | ||
| } | ||
| } | ||
|
|
||
| .ant-tabs-tab-btn { | ||
| flex: 1 1 auto; | ||
| font-size: ${({ theme }) => theme.typography.sizes.s}px; | ||
| text-align: center; | ||
| text-transform: uppercase; | ||
|
|
||
| .required { | ||
| margin-left: ${({ theme }) => theme.gridUnit / 2}px; | ||
| color: ${({ theme }) => theme.colors.error.base}; | ||
| } | ||
| } | ||
|
|
||
| .ant-tabs-ink-bar { | ||
| background: ${({ theme }) => theme.colors.secondary.base}; | ||
| } | ||
| `; | ||
|
|
||
| export default Tabs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.