Skip to content

Commit 96e49eb

Browse files
committed
code refactor
1 parent 580b492 commit 96e49eb

File tree

5 files changed

+60
-29
lines changed

5 files changed

+60
-29
lines changed

.github/workflows/js-tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: js-tests
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
push:
7+
branches:
8+
- main
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Install modules
16+
working-directory: ./tests/js
17+
run: npm install
18+
- name: Run tests
19+
working-directory: ./tests/js
20+
run: npm test

bigframes/display/table_widget.css

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
align-items: center;
2929
display: flex;
3030
font-size: 0.8rem;
31-
padding-top: 8px;
31+
justify-content: space-between;
32+
padding: 8px;
33+
font-family:
34+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
3235
}
3336

3437
.bigframes-widget .footer > * {
@@ -44,6 +47,14 @@
4447
padding: 4px;
4548
}
4649

50+
.bigframes-widget .page-indicator {
51+
margin: 0 8px;
52+
}
53+
54+
.bigframes-widget .row-count {
55+
margin: 0 8px;
56+
}
57+
4758
.bigframes-widget .page-size {
4859
align-items: center;
4960
display: flex;
@@ -52,6 +63,10 @@
5263
justify-content: end;
5364
}
5465

66+
.bigframes-widget .page-size label {
67+
margin-right: 8px;
68+
}
69+
5570
.bigframes-widget table {
5671
border-collapse: collapse;
5772
text-align: left;
@@ -91,4 +106,9 @@
91106
font-family:
92107
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
93108
font-size: 14px;
109+
padding: 8px;
110+
margin-bottom: 8px;
111+
border: 1px solid red;
112+
border-radius: 4px;
113+
background-color: #ffebee;
94114
}

bigframes/display/table_widget.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,46 +43,34 @@ function render({ model, el }) {
4343
// Add error message container at the top
4444
const errorContainer = document.createElement("div");
4545
errorContainer.classList.add("error-message");
46-
errorContainer.style.display = "none";
47-
errorContainer.style.color = "red";
48-
errorContainer.style.padding = "8px";
49-
errorContainer.style.marginBottom = "8px";
50-
errorContainer.style.border = "1px solid red";
51-
errorContainer.style.borderRadius = "4px";
52-
errorContainer.style.backgroundColor = "#ffebee";
5346

5447
const tableContainer = document.createElement("div");
55-
const footer = document.createElement("div");
56-
57-
// Footer styles
58-
footer.style.display = "flex";
59-
footer.style.justifyContent = "space-between";
60-
footer.style.alignItems = "center";
61-
footer.style.padding = "8px";
62-
footer.style.fontFamily =
63-
'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
48+
tableContainer.classList.add("table-container");
49+
const footer = document.createElement("footer");
50+
footer.classList.add("footer");
6451

6552
// Pagination controls
6653
const paginationContainer = document.createElement("div");
54+
paginationContainer.classList.add("pagination");
6755
const prevPage = document.createElement("button");
6856
const pageIndicator = document.createElement("span");
57+
pageIndicator.classList.add("page-indicator");
6958
const nextPage = document.createElement("button");
7059
const rowCountLabel = document.createElement("span");
60+
rowCountLabel.classList.add("row-count");
7161

7262
// Page size controls
7363
const pageSizeContainer = document.createElement("div");
64+
pageSizeContainer.classList.add("page-size");
7465
const pageSizeLabel = document.createElement("label");
7566
const pageSizeInput = document.createElement("select");
7667

7768
prevPage.textContent = "<";
7869
nextPage.textContent = ">";
7970
pageSizeLabel.textContent = "Page size:";
80-
pageSizeLabel.style.marginRight = "8px";
81-
pageIndicator.style.margin = "0 8px";
82-
rowCountLabel.style.margin = "0 8px";
8371

8472
// Page size options
85-
const pageSizes = [10, 20, 50, 100, 200, 500, 1000];
73+
const pageSizes = [10, 25, 50, 100];
8674
for (const size of pageSizes) {
8775
const option = document.createElement("option");
8876
option.value = size;

notebooks/dataframes/anywidget_mode.ipynb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
{
158158
"data": {
159159
"application/vnd.jupyter.widget-view+json": {
160-
"model_id": "030f0b706a17487288677d33b6921a8e",
160+
"model_id": "f0f1cc04e1564a6ab4ba39935aebd11a",
161161
"version_major": 2,
162162
"version_minor": 1
163163
},
@@ -189,7 +189,7 @@
189189
"id": "sorting-intro",
190190
"metadata": {},
191191
"source": [
192-
"### Sorting by Column\n",
192+
"### Sorting by Single-Column\n",
193193
"You can sort the table by clicking on the headers of columns that have orderable data types (like numbers, strings, and dates). Non-orderable columns (like arrays or structs) do not have sorting controls.\n",
194194
"\n",
195195
"**Sorting indicators (▲, ▼) are always visible for sorted columns. The unsorted indicator (●) is only visible when you hover over an unsorted column header.** The sorting control cycles through three states:\n",
@@ -255,7 +255,7 @@
255255
{
256256
"data": {
257257
"application/vnd.jupyter.widget-view+json": {
258-
"model_id": "2fe252168e4249e5a694579e49f04065",
258+
"model_id": "bed78e341154486bb49841ce12a0af93",
259259
"version_major": 2,
260260
"version_minor": 1
261261
},
@@ -369,7 +369,7 @@
369369
{
370370
"data": {
371371
"application/vnd.jupyter.widget-view+json": {
372-
"model_id": "cc4d4dffe00a4f44b7cbcfdea440cc5a",
372+
"model_id": "357c732c110e44fa9efe3e512da61638",
373373
"version_major": 2,
374374
"version_minor": 1
375375
},
@@ -409,8 +409,7 @@
409409
"data": {
410410
"text/html": [
411411
"✅ Completed. \n",
412-
" Query processed 85.9 kB in 15 seconds of slot time.\n",
413-
" Query processed 85.9 kB in 15 seconds of slot time.\n",
412+
" Query processed 85.9 kB in 14 seconds of slot time.\n",
414413
" "
415414
],
416415
"text/plain": [
@@ -457,7 +456,7 @@
457456
{
458457
"data": {
459458
"application/vnd.jupyter.widget-view+json": {
460-
"model_id": "7f9f40cf56ec4c30a2f1f52d0e825633",
459+
"model_id": "af87c96ce359412a99b5eabbc1b9d137",
461460
"version_major": 2,
462461
"version_minor": 1
463462
},

tests/unit/session/test_clients.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ def test_user_agent_not_in_vscode(monkeypatch):
180180

181181

182182
@mock.patch.dict(os.environ, {"VSCODE_PID": "12345"}, clear=True)
183-
def test_user_agent_in_vscode(monkeypatch):
183+
@mock.patch(
184+
"bigframes.session.environment.is_vscode_google_cloud_code_extension_installed",
185+
return_value=False,
186+
)
187+
def test_user_agent_in_vscode(mock_is_installed, monkeypatch):
184188
monkeypatch_client_constructors(monkeypatch)
185189
provider = create_clients_provider()
186190
assert_clients_w_user_agent(provider, "vscode")

0 commit comments

Comments
 (0)