-
Notifications
You must be signed in to change notification settings - Fork 17.4k
feat: Added Steps and centralized Headers #15041
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
hughhhh
merged 10 commits into
apache:pexdax/db-connection-ui
from
preset-io:ch16648_headerSteps
Jun 10, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eb53d28
centralized headers with conditional logic
AAfghahi 08571d4
move header to separate file
eschutho f96f58a
Merge pull request #107 from preset-io/elizabeth/move-header
AAfghahi 66f488c
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh a066672
Merge branch 'pexdax/db-connection-ui' of https://github.com/apache/s…
hughhhh 038eae3
Merge branch 'ch16648_headerSteps' of https://github.com/preset-io/su…
hughhhh 7e040bf
working big query form with arash updates
hughhhh bb6c981
revisions
AAfghahi 4632093
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 9fb68e0
merged pexdax and then pushed
AAfghahi 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
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
134 changes: 134 additions & 0 deletions
134
superset-frontend/src/views/CRUD/data/database/DatabaseModal/ModalHeader.tsx
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,134 @@ | ||
| /** | ||
| * 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 { | ||
| EditHeaderTitle, | ||
| EditHeaderSubtitle, | ||
| CreateHeaderTitle, | ||
| CreateHeaderSubtitle, | ||
| StyledFormHeader, | ||
| } from './styles'; | ||
| import { DatabaseForm, DatabaseObject } from '../types'; | ||
|
|
||
| export const DOCUMENTATION_LINK = | ||
| 'https://superset.apache.org/docs/databases/installing-database-drivers'; | ||
|
|
||
| const irregularDocumentationLinks = { | ||
| postgresql: 'https://superset.apache.org/docs/databases/postgres', | ||
| mssql: 'https://superset.apache.org/docs/databases/sql-server', | ||
| }; | ||
|
|
||
| const documentationLink = (engine: string | undefined) => { | ||
| if (!engine) return null; | ||
| if (!irregularDocumentationLinks[engine]) { | ||
| return `https://superset.apache.org/docs/databases/${engine}`; | ||
| } | ||
| return irregularDocumentationLinks[engine]; | ||
| }; | ||
| const ModalHeader = ({ | ||
| isLoading, | ||
| isEditMode, | ||
| useSqlAlchemyForm, | ||
| hasConnectedDb, | ||
| db, | ||
| dbName, | ||
| dbModel, | ||
| }: { | ||
| isLoading: boolean; | ||
| isEditMode: boolean; | ||
| useSqlAlchemyForm: boolean; | ||
| hasConnectedDb: boolean; | ||
| db: Partial<DatabaseObject> | null; | ||
| dbName: string; | ||
| dbModel: DatabaseForm; | ||
| }) => { | ||
| const isEditHeader = ( | ||
| <> | ||
| <EditHeaderTitle>{db?.backend}</EditHeaderTitle> | ||
| <EditHeaderSubtitle>{dbName}</EditHeaderSubtitle> | ||
| </> | ||
| ); | ||
| const useSqlAlchemyFormHeader = ( | ||
| <> | ||
| <p className="helper"> Step 2 of 2 </p> | ||
| <CreateHeaderTitle>Enter Primary Credentials</CreateHeaderTitle> | ||
| <CreateHeaderSubtitle> | ||
| Need help? Learn how to connect your database{' '} | ||
| <a href={DOCUMENTATION_LINK} target="_blank" rel="noopener noreferrer"> | ||
| here | ||
| </a> | ||
| . | ||
| </CreateHeaderSubtitle> | ||
| </> | ||
| ); | ||
| const hasConnectedDbHeader = ( | ||
| <StyledFormHeader> | ||
| <p className="helper"> Step 3 of 3 </p> | ||
|
AAfghahi marked this conversation as resolved.
|
||
| <h4> | ||
| Your database was successfully connected! Here are some optional | ||
| settings for your database | ||
| </h4> | ||
| <p className="helper"> | ||
| Need help? Learn more about{' '} | ||
| <a | ||
| href={documentationLink(db?.engine)} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| connecting to {dbModel.name} | ||
| </a> | ||
| </p> | ||
| </StyledFormHeader> | ||
| ); | ||
| const hasDbHeader = ( | ||
| <StyledFormHeader> | ||
| <p className="helper"> Step 2 of 3 </p> | ||
| <h4>Enter the required {dbModel.name} credentials</h4> | ||
| <p className="helper"> | ||
| Need help? Learn more about connecting to {dbModel.name}. | ||
| </p> | ||
| </StyledFormHeader> | ||
| ); | ||
| const noDbHeader = ( | ||
| <StyledFormHeader> | ||
| <div className="select-db"> | ||
| <p className="helper"> Step 1 of 3 </p> | ||
| <h4>Select a database to connect</h4> | ||
| </div> | ||
| </StyledFormHeader> | ||
| ); | ||
|
|
||
| if (isLoading) return <></>; | ||
|
Member
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. nit: prefer a switch statement here |
||
| if (isEditMode) { | ||
| return isEditHeader; | ||
| } | ||
| if (useSqlAlchemyForm) { | ||
| return useSqlAlchemyFormHeader; | ||
| } | ||
| if (hasConnectedDb) { | ||
| return hasConnectedDbHeader; | ||
| } | ||
| if (db) { | ||
| return hasDbHeader; | ||
| } | ||
| return noDbHeader; | ||
| }; | ||
|
|
||
| export default ModalHeader; | ||
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.