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

fix: TabTableBuilder and VirtualTableList #1799

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/studio/src/assets/styles/app/sidebar/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@
overflow-y: auto;
-webkit-overflow-scrolling: touch!important;
padding-left: $gutter-w - 0.4rem;
&.list-body-empty {
flex: 0;
}
}
.list-group {
display: flex;
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/common/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
workspaceCheckInterval: 5000, // 5 seconds
dataCheckInterval: 1000 * 30, // 30 secs
errorNoticeTimeout: 60 * 1000, // 1 minute
tableListItemHeight: 22.8, // in pixels
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<virtual-list
ref="vList"
class="list-body"
:class="{ 'list-body-empty': displayItems.length === 0 }"
:data-key="'key'"
:data-sources="displayItems"
:data-component="itemComponent"
Expand Down Expand Up @@ -32,6 +33,7 @@ import { AppEvent } from "@/common/AppEvent";
import { mapGetters, mapState } from "vuex";
import { PinnedEntity } from "@/common/appdb/models/PinnedEntity";
import { entityId } from "@/common/utils";
import globals from '@/common/globals';
import "scrollyfills";

type Entity = TableOrView | Routine | string;
Expand Down Expand Up @@ -82,7 +84,7 @@ export default Vue.extend({
items: [],
displayItems: [],
itemComponent: ItemComponent,
estimateItemHeight: 22.8, // height of collapsed item
estimateItemHeight: globals.tableListItemHeight, // height of collapsed item
keeps: 30,
generated: false,
};
Expand Down Expand Up @@ -182,7 +184,7 @@ export default Vue.extend({

// Summarizing the total height of all list items to get the average height

totalHeight += 22.8; // height of list item
totalHeight += globals.tableListItemHeight; // height of list item

if (item.expanded) {
if (item.type === "table") {
Expand All @@ -196,7 +198,11 @@ export default Vue.extend({
}
}

this.estimateItemHeight = totalHeight / displayItems.length;
if (displayItems.length > 0) {
this.estimateItemHeight = totalHeight / displayItems.length;
} else {
this.estimateItemHeight = globals.tableListItemHeight;
}
this.displayItems = displayItems;
},
loadColumns(item: TableItem) {
Expand Down
6 changes: 4 additions & 2 deletions apps/studio/src/lib/db/clients/BasicDatabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ChangeBuilderBase } from '@shared/lib/sql/change_builder/ChangeBuilderB
export interface ExecutionContext {
executedBy: 'user' | 'app'
location: string // eg tab name or ID
purpose?: string // why
purpose?: string // why
details?: string // any useful details
}

Expand Down Expand Up @@ -40,7 +40,6 @@ export abstract class BasicDatabaseClient<RawResultType> implements DatabaseClie
this.knex = knex;
this.contextProvider = contextProvider
}
defaultSchema?: () => string;
listTablePartitions(_table: string): Promise<TablePartition[]> {
return Promise.resolve([])
}
Expand All @@ -50,6 +49,9 @@ export abstract class BasicDatabaseClient<RawResultType> implements DatabaseClie
alterPartition: (changes: AlterPartitionsSpec) => Promise<void> = () => Promise.resolve();
getMaterializedViewCreateScript?: (view: string, schema?: string) => Promise<string[]> = () => Promise.resolve([]);
abstract versionString(): string;
defaultSchema(): string | null {
return null
}


abstract getBuilder(table: string, schema?: string): ChangeBuilderBase
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/src/lib/db/clients/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class SqliteClient extends BasicDatabaseClient<SqliteResult> {

this.database = database?.database;
}

versionString(): string {
return this.version?.data[0]["sqlite_version()"];
return this.version?.data[0]["sqlite_version()"];
}

getBuilder(table: string, _schema?: string): ChangeBuilderBase {
Expand Down