Skip to content

Commit

Permalink
Merge pull request #22 from dolthub/taylor/other-fixes
Browse files Browse the repository at this point in the history
web,graphql: Some UI improvements
  • Loading branch information
tbantle22 authored Oct 26, 2023
2 parents 4ed1202 + c7ebce1 commit 720f768
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/graphql-server/src/tables/table.queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FROM information_schema.statistics
WHERE table_name=? AND index_name!="PRIMARY"
GROUP BY index_name;`;

export const foreignKeysQuery = `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name=? AND referenced_table_schema IS NOT NULL`;
export const foreignKeysQuery = `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name=? AND table_schema=? AND referenced_table_schema IS NOT NULL`;

export const columnsQuery = `DESCRIBE ??`;

Expand Down
15 changes: 11 additions & 4 deletions packages/graphql-server/src/tables/table.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class TableResolver {
@Query(_returns => Table)
async table(@Args() args: TableArgs): Promise<Table> {
return this.dss.queryMaybeDolt(
async q => getTableInfo(q, args),
async (q, isDolt) => getTableInfo(q, args, isDolt),
args.databaseName,
args.refName,
);
Expand All @@ -46,7 +46,7 @@ export class TableResolver {
const tableNames = await getTableNames(q, args, isDolt);
const tables = await Promise.all(
tableNames.list.map(async name =>
getTableInfo(q, { ...args, tableName: name }),
getTableInfo(q, { ...args, tableName: name }, isDolt),
),
);
return tables;
Expand Down Expand Up @@ -77,9 +77,16 @@ async function getTableNames(
return { list: [...mapped, ...systemTables] };
}

async function getTableInfo(query: ParQuery, args: TableArgs): Promise<Table> {
async function getTableInfo(
query: ParQuery,
args: TableArgs,
isDolt: boolean,
): Promise<Table> {
const columns = await query(columnsQuery, [args.tableName]);
const fkRows = await query(foreignKeysQuery, [args.tableName]);
const fkRows = await query(foreignKeysQuery, [
args.tableName,
isDolt ? `${args.databaseName}/${args.refName}` : args.databaseName,
]);
const idxRows = await query(indexQuery, [args.tableName]);
return fromDoltRowRes(
args.databaseName,
Expand Down
7 changes: 5 additions & 2 deletions packages/web/components/CellButtons/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

.notTable {
@apply font-sans text-sm;
button {
@apply flex flex-wrap;
}
}

.check {
Expand All @@ -25,7 +28,7 @@
}

.foreignKeyDropdown {
@apply absolute -top-[0.3rem] left-[8.2rem] bg-white widget-shadow-hover z-100 rounded px-3 py-1 border border-ld-lightgrey w-fit;
@apply absolute -top-[0.3rem] left-[8.2rem] bg-white widget-shadow-hover z-100 rounded px-3 py-1 border border-ld-lightgrey w-fit;

a {
@apply text-acc-hoverlinkblue font-semibold font-sans;
Expand All @@ -49,7 +52,7 @@
}

.history:hover .button:disabled ~ .popup {
@apply block absolute -top-0.5 left-24 bg-white widget-shadow-hover z-100 rounded px-3 py-2 border border-ld-lightgrey;
@apply block absolute -top-0.5 left-24 bg-white widget-shadow-hover z-100 rounded px-3 py-2 border border-ld-lightgrey max-w-[12rem];
}

.loading {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/DataTable/Table/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
border-spacing: 0;

@screen lg {
@apply overflow-hidden pr-80 ml-0 pb-80;
@apply overflow-hidden pr-40 ml-0 pb-80;
}

th {
Expand Down
6 changes: 3 additions & 3 deletions packages/web/components/Database404/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Page404 from "@components/Page404";
import Page from "@components/util/Page";
import DatabaseLayoutWrapper from "@layouts/DatabaseLayout/Wrapper";
import { DatabaseLayoutWrapperOuter } from "@layouts/DatabaseLayout/Wrapper";
import { DatabaseParams } from "@lib/params";
import css from "./index.module.css";

Expand All @@ -18,11 +18,11 @@ export default function Database404Page(props: Props) {

export function Database404(props: Props) {
return (
<DatabaseLayoutWrapper>
<DatabaseLayoutWrapperOuter>
<Page404 title="Database not found">
<Database404Inner {...props} />
</Page404>
</DatabaseLayoutWrapper>
</DatabaseLayoutWrapperOuter>
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/DatabasesDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Inner(props: InnerProps) {
setIsOpen={setIsOpen}
position="bottom left"
offsetX={0}
contentStyle={{ width: "8rem", padding: 0 }}
contentStyle={{ width: "12rem", padding: 0 }}
arrow={false}
>
<ul>
Expand Down
6 changes: 5 additions & 1 deletion packages/web/components/SchemaDiagram/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const TABLE_LIST_FOR_BRANCH_QUERY = gql`
}
}
query TableListForSchemas($databaseName: String!, $refName: String!) {
tables(databaseName: $databaseName, refName: $refName) {
tables(
databaseName: $databaseName
refName: $refName
filterSystemTables: true
) {
...TableForSchemaList
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/web/gen/graphql-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export type SqlSelectForSqlDataTableQueryVariables = Exact<{
}>;


export type SqlSelectForSqlDataTableQuery = { __typename?: 'Query', sqlSelect: { __typename?: 'SqlSelect', _id: string, queryExecutionStatus: QueryExecutionStatus, queryExecutionMessage: string, columns: Array<{ __typename?: 'Column', name: string, isPrimaryKey: boolean, type: string }>, rows: Array<{ __typename?: 'Row', columnValues: Array<{ __typename?: 'ColumnValue', displayValue: string }> }> } };
export type SqlSelectForSqlDataTableQuery = { __typename?: 'Query', sqlSelect: { __typename?: 'SqlSelect', queryExecutionStatus: QueryExecutionStatus, queryExecutionMessage: string, columns: Array<{ __typename?: 'Column', name: string, isPrimaryKey: boolean, type: string }>, rows: Array<{ __typename?: 'Row', columnValues: Array<{ __typename?: 'ColumnValue', displayValue: string }> }> } };

export type StatusFragment = { __typename?: 'Status', _id: string, refName: string, tableName: string, staged: boolean, status: string };

Expand Down Expand Up @@ -1732,7 +1732,7 @@ export type SchemaDiffLazyQueryHookResult = ReturnType<typeof useSchemaDiffLazyQ
export type SchemaDiffQueryResult = Apollo.QueryResult<SchemaDiffQuery, SchemaDiffQueryVariables>;
export const TableListForSchemasDocument = gql`
query TableListForSchemas($databaseName: String!, $refName: String!) {
tables(databaseName: $databaseName, refName: $refName) {
tables(databaseName: $databaseName, refName: $refName, filterSystemTables: true) {
...TableForSchemaList
}
}
Expand Down Expand Up @@ -1773,7 +1773,6 @@ export const SqlSelectForSqlDataTableDocument = gql`
refName: $refName
queryString: $queryString
) {
_id
queryExecutionStatus
queryExecutionMessage
columns {
Expand Down

0 comments on commit 720f768

Please sign in to comment.