-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Web: added connections and databases selector, changed theme color #302
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
c5fd504
Merge branch 'liuliu/add-custom-title-bar' into liuliu/web-nav-dropdown
liuliu-dev 0c61823
wip
liuliu-dev 8a51cbb
conn and db list, todo: ui on click, reset, default on open
liuliu-dev d8272a2
use current as default, reset db
liuliu-dev e10306e
remove breadcrumbs for app, todo:fix lint
liuliu-dev bb7938e
mobile, gradient, ui fixes
liuliu-dev b1b57c5
show connections link before database page
liuliu-dev 68696d9
feedback wip
liuliu-dev f65f9d9
move to middle, fix long name, same db name issues
liuliu-dev 74024a1
click outside works
liuliu-dev b20259b
color, weight, top
liuliu-dev bd50529
wip
liuliu-dev a30dc4a
web and app top nav
liuliu-dev c0625dc
dropdown wip
liuliu-dev dce6e2e
Merge remote-tracking branch 'origin/main' into liuliu/web-nav-dropdown
liuliu-dev 65411ec
popup ui
liuliu-dev 4d108ba
mobile wip
liuliu-dev 9f5d54a
plus icon
liuliu-dev cbb0254
views, definitions
liuliu-dev 498749d
colors
liuliu-dev 9c5b32f
label
liuliu-dev e3196ff
Merge branch 'liuliu/web-nav-dropdown' into liuliu/left-nav-ui
liuliu-dev 7d08936
table, view, definition list
liuliu-dev 55d76a3
hide icons, bottom, scroll
liuliu-dev 488af3f
conflict
liuliu-dev 76bb6d3
add min window size, web app nav
liuliu-dev bfc9566
ci
liuliu-dev 2b7418b
mobile fix
liuliu-dev c522458
Merge branch 'liuliu/web-nav-dropdown' into liuliu/left-nav-ui
liuliu-dev 7a8dbc1
selectors
liuliu-dev 2ba37df
buttons ui
liuliu-dev af12a83
viewing
liuliu-dev c4362ea
Merge branch 'liuliu/web-nav-dropdown' into liuliu/left-nav-ui
liuliu-dev eadfde7
dropdown updates
liuliu-dev a1ca0ad
Merge remote-tracking branch 'origin/main' into liuliu/web-nav-dropdown
liuliu-dev 7fbe51b
Merge branch 'liuliu/web-nav-dropdown' into liuliu/left-nav-ui
liuliu-dev 1a5c3b0
Merge pull request #317 from dolthub/liuliu/left-nav-ui
liuliu-dev c5abb76
color
liuliu-dev 6f92205
refresh
liuliu-dev f4b758e
active, font size, lowercase
liuliu-dev 26af6ad
url
liuliu-dev 8d84e7c
branch label fixes in mysql and postgres, reset button tooltip, conne…
liuliu-dev 50d72fb
ci fix, nodrag
liuliu-dev 977d422
showlabel for all non-dolt, clearstore,selected conn
liuliu-dev 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 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
This file contains 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
This file contains 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
This file contains 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
53 changes: 53 additions & 0 deletions
53
web/renderer/components/ConnectionsAndDatabases/ConnectionItem.tsx
This file contains 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,53 @@ | ||
import { | ||
DatabaseConnection, | ||
DatabaseConnectionFragment, | ||
} from "@gen/graphql-types"; | ||
import { MdRemoveRedEye } from "@react-icons/all-files/md/MdRemoveRedEye"; | ||
import { FaChevronRight } from "@react-icons/all-files/fa/FaChevronRight"; | ||
import { Button } from "@dolthub/react-components"; | ||
import { excerpt } from "@dolthub/web-utils"; | ||
import cx from "classnames"; | ||
import { DatabaseTypeLabel } from "./DatabaseTypeLabel"; | ||
import css from "./index.module.css"; | ||
|
||
type Props = { | ||
conn: DatabaseConnectionFragment; | ||
selectedConnection: DatabaseConnectionFragment; | ||
onSelected: (conn: DatabaseConnection) => void; | ||
currentConnection: DatabaseConnection; | ||
}; | ||
export default function ConnectionItem({ | ||
conn, | ||
selectedConnection, | ||
onSelected, | ||
currentConnection, | ||
}: Props) { | ||
return ( | ||
<Button.Link | ||
key={conn.name} | ||
className={cx(css.connection, { | ||
[css.selected]: selectedConnection.name === conn.name, | ||
})} | ||
onClick={async () => onSelected(conn)} | ||
> | ||
<div className={css.connectionTop}> | ||
<div className={css.nameAndLabel}> | ||
<span className={css.connectionName}>{excerpt(conn.name, 16)}</span> | ||
<DatabaseTypeLabel conn={conn} /> | ||
{conn.name === currentConnection.name && ( | ||
<MdRemoveRedEye className={css.viewing} /> | ||
)} | ||
</div> | ||
<FaChevronRight className={css.arrow} /> | ||
</div> | ||
<div className={css.connectionUrl}> | ||
{excerpt(getHostAndPort(conn.connectionUrl), 42)} | ||
</div> | ||
</Button.Link> | ||
); | ||
} | ||
|
||
function getHostAndPort(connectionString: string) { | ||
const url = new URL(connectionString); | ||
return `${url.hostname}:${url.port}`; | ||
} |
77 changes: 77 additions & 0 deletions
77
web/renderer/components/ConnectionsAndDatabases/DatabaseItem.tsx
This file contains 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,77 @@ | ||
import { Button, ErrorMsg, Loader } from "@dolthub/react-components"; | ||
import { MdRemoveRedEye } from "@react-icons/all-files/md/MdRemoveRedEye"; | ||
import { | ||
DatabaseConnectionFragment, | ||
DatabaseType, | ||
useAddDatabaseConnectionMutation, | ||
useResetDatabaseMutation, | ||
} from "@gen/graphql-types"; | ||
import useMutation from "@hooks/useMutation"; | ||
import { useRouter } from "next/router"; | ||
import { database } from "@lib/urls"; | ||
import { excerpt } from "@dolthub/web-utils"; | ||
import cx from "classnames"; | ||
import css from "./index.module.css"; | ||
|
||
type Props = { | ||
db: string; | ||
conn: DatabaseConnectionFragment; | ||
currentConnection: DatabaseConnectionFragment; | ||
currentDatabase: string; | ||
}; | ||
|
||
export default function DatabaseItem({ | ||
db, | ||
conn, | ||
currentConnection, | ||
currentDatabase, | ||
}: Props) { | ||
const { | ||
mutateFn: resetDB, | ||
loading, | ||
err, | ||
} = useMutation({ | ||
hook: useResetDatabaseMutation, | ||
}); | ||
const router = useRouter(); | ||
const [addDb, res] = useAddDatabaseConnectionMutation(); | ||
|
||
const onClick = async (databaseName: string) => { | ||
const addedDb = await addDb({ variables: conn }); | ||
if (!addedDb.data) { | ||
return; | ||
} | ||
await res.client.clearStore(); | ||
|
||
if (conn.type === DatabaseType.Postgres) { | ||
await resetDB({ variables: { newDatabase: databaseName } }); | ||
} | ||
const { href, as } = database({ databaseName }); | ||
router.push(href, as).catch(console.error); | ||
}; | ||
|
||
if (loading) { | ||
return <Loader loaded={!loading} />; | ||
} | ||
|
||
if (err) { | ||
return <ErrorMsg err={err} />; | ||
} | ||
const dbName = excerpt(db, 32); | ||
if (db === currentDatabase && conn.name === currentConnection.name) { | ||
return ( | ||
<span className={css.dbItem}> | ||
{dbName} | ||
<MdRemoveRedEye className={css.viewing} /> | ||
</span> | ||
); | ||
} | ||
return ( | ||
<Button.Link | ||
className={cx(css.dbItem, css.link)} | ||
onClick={async () => onClick(db)} | ||
> | ||
{dbName} | ||
</Button.Link> | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
web/renderer/components/ConnectionsAndDatabases/DatabaseTypeLabel.tsx
This file contains 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,39 @@ | ||
import { getDatabaseType } from "@components/DatabaseTypeLabel"; | ||
import { DatabaseConnectionFragment } from "@gen/graphql-types"; | ||
import css from "./index.module.css"; | ||
|
||
type Props = { | ||
conn: DatabaseConnectionFragment; | ||
}; | ||
|
||
export function DatabaseTypeLabel({ conn }: Props) { | ||
const type = getDatabaseType(conn.type ?? undefined, !!conn.isDolt); | ||
switch (type) { | ||
case "Dolt": | ||
return ( | ||
<span className={css.label}> | ||
<img src="/images/dolt-logo.png" alt="Dolt" /> | ||
</span> | ||
); | ||
case "MySQL": | ||
return ( | ||
<span className={css.label}> | ||
<img src="/images/mysql-logo.png" alt="MySQL" /> | ||
</span> | ||
); | ||
case "PostgreSQL": | ||
return ( | ||
<span className={css.label}> | ||
<img src="/images/postgres-logo.png" alt="PostgreSQL" /> | ||
</span> | ||
); | ||
case "DoltgreSQL": | ||
return ( | ||
<span className={css.label}> | ||
<img src="/images/doltgres-logo.png" alt="DoltgreSQL" /> | ||
</span> | ||
); | ||
default: | ||
return <span className={css.label}>{type}</span>; | ||
} | ||
} |
This file contains 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,72 @@ | ||
import { DatabaseConnection, DatabaseType } from "@gen/graphql-types"; | ||
import { DatabaseParams } from "@lib/params"; | ||
import cx from "classnames"; | ||
import Link from "@components/links/Link"; | ||
import { ErrorMsg, SmallLoader } from "@dolthub/react-components"; | ||
import CreateDatabase from "@components/CreateDatabase"; | ||
import { FiTool } from "@react-icons/all-files/fi/FiTool"; | ||
import { StateType } from "./useSelectedConnection"; | ||
import DatabaseItem from "./DatabaseItem"; | ||
import css from "./index.module.css"; | ||
import ConnectionItem from "./ConnectionItem"; | ||
|
||
type Props = { | ||
params: DatabaseParams; | ||
currentConnection: DatabaseConnection; | ||
onSelected: (conn: DatabaseConnection) => void; | ||
storedConnections: DatabaseConnection[]; | ||
state: StateType; | ||
}; | ||
|
||
export default function Popup({ | ||
params, | ||
currentConnection, | ||
onSelected, | ||
storedConnections, | ||
state, | ||
}: Props) { | ||
return ( | ||
<div className={css.container}> | ||
<div className={css.top}> | ||
<div className={cx(css.header, css.left)}> | ||
<span>CONNECTIONS</span> | ||
<Link href="/connections"> | ||
<FiTool className={css.wrench} /> | ||
</Link> | ||
</div> | ||
<div className={cx(css.header, css.right)}> | ||
<span>DATABASES</span> | ||
<CreateDatabase | ||
isPostgres={currentConnection.type === DatabaseType.Postgres} | ||
/> | ||
</div> | ||
</div> | ||
<div className={css.middle}> | ||
<div className={css.left}> | ||
{storedConnections.map(conn => ( | ||
<ConnectionItem | ||
key={conn.name} | ||
conn={conn} | ||
currentConnection={currentConnection} | ||
onSelected={onSelected} | ||
selectedConnection={state.connection} | ||
/> | ||
))} | ||
</div> | ||
<div className={css.right}> | ||
{state.loading && <SmallLoader loaded={!state.loading} />} | ||
{state.databases.map(db => ( | ||
<DatabaseItem | ||
key={db} | ||
db={db} | ||
conn={state.connection} | ||
currentConnection={currentConnection} | ||
currentDatabase={params.databaseName} | ||
/> | ||
))} | ||
<ErrorMsg err={state.err} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
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.
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.
Is
type
not an enum?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.
no, it's a string returned from
getDatabaseType