Skip to content

Commit b54609e

Browse files
authored
Revert "Fix: Editor labels not clickable (#256)" (#273)
This reverts commit 8ec159d.
1 parent c50f420 commit b54609e

File tree

6 files changed

+13
-39
lines changed

6 files changed

+13
-39
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"react-use": "^17.3.1",
4141
"react-virtualized-auto-sizer": "^1.0.6",
4242
"sql-formatter-plus": "^1.3.6",
43-
"tslib": "2.5.3"
43+
"tslib": "2.5.3",
44+
"uuid": "^8.3.2"
4445
},
4546
"devDependencies": {
4647
"@babel/core": "^7.21.4",
@@ -57,6 +58,7 @@
5758
"@types/node": "^20.8.7",
5859
"@types/react-router-dom": "^5.2.0",
5960
"@types/testing-library__jest-dom": "5.14.8",
61+
"@types/uuid": "^8.3.1",
6062
"@typescript-eslint/eslint-plugin": "^5.42.1",
6163
"@typescript-eslint/parser": "^5.42.1",
6264
"copy-webpack-plugin": "^11.0.0",

src/components/DatasetSelector.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ interface DatasetSelectorProps extends ResourceSelectorProps {
1212
applyDefault?: boolean;
1313
disabled?: boolean;
1414
onChange: (v: SelectableValue) => void;
15-
inputId?: string;
1615
}
1716

1817
export const DatasetSelector: React.FC<DatasetSelectorProps> = ({
@@ -24,7 +23,6 @@ export const DatasetSelector: React.FC<DatasetSelectorProps> = ({
2423
disabled,
2524
className,
2625
applyDefault,
27-
inputId,
2826
}) => {
2927
const state = useAsync(async () => {
3028
const datasets = await apiClient.getDatasets(location, project);
@@ -54,7 +52,6 @@ export const DatasetSelector: React.FC<DatasetSelectorProps> = ({
5452
<Select
5553
className={className}
5654
aria-label="Dataset selector"
57-
inputId={inputId}
5855
value={value}
5956
options={state.value}
6057
onChange={onChange}

src/components/ProjectSelector.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ interface ProjectSelectorProps extends Omit<ResourceSelectorProps, 'location'> {
1010
value?: string;
1111
applyDefault?: boolean;
1212
onChange: (v: SelectableValue) => void;
13-
inputId?: string;
1413
}
1514

16-
export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
17-
apiClient,
18-
value,
19-
onChange,
20-
applyDefault,
21-
inputId,
22-
}) => {
15+
export const ProjectSelector: React.FC<ProjectSelectorProps> = ({ apiClient, value, onChange, applyDefault }) => {
2316
const theme = useTheme2();
2417
const state = useAsync(async () => {
2518
const projects = await apiClient.getProjects();
@@ -70,7 +63,6 @@ export const ProjectSelector: React.FC<ProjectSelectorProps> = ({
7063
<EditorField label="Project" width={25} error={getErrorMessage()} invalid={!!state.error}>
7164
<Select
7265
aria-label="Project selector"
73-
inputId={inputId}
7466
value={state.loading ? null : value}
7567
options={state.loading ? [] : state.value || [{ label: value, value }]}
7668
onChange={onChange}

src/components/QueryHeader.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { SelectableValue } from '@grafana/data';
22
import { EditorField, EditorHeader, EditorMode, EditorRow, FlexItem, InlineSelect, Space } from '@grafana/experimental';
33
import { Button, InlineSwitch, RadioButtonGroup, Tooltip } from '@grafana/ui';
44
import { BigQueryAPI } from 'api';
5-
import React, { useCallback, useId, useState } from 'react';
5+
import React, { useCallback, useState } from 'react';
66
import { useCopyToClipboard } from 'react-use';
77
import { toRawSql } from 'utils/sql.utils';
88
import { PROCESSING_LOCATIONS, QUERY_FORMAT_OPTIONS } from '../constants';
@@ -11,6 +11,7 @@ import { ConfirmModal } from './ConfirmModal';
1111
import { DatasetSelector } from './DatasetSelector';
1212
import { ProjectSelector } from './ProjectSelector';
1313
import { TableSelector } from './TableSelector';
14+
import { v4 as uuidv4 } from 'uuid';
1415

1516
interface QueryHeaderProps {
1617
query: QueryWithDefaults;
@@ -41,7 +42,6 @@ export function QueryHeader({
4142
const { location, editorMode } = query;
4243
const [_, copyToClipboard] = useCopyToClipboard();
4344
const [showConfirm, setShowConfirm] = useState(false);
44-
const htmlId = useId();
4545

4646
const onEditorModeChange = useCallback(
4747
(newEditorMode: EditorMode) => {
@@ -160,7 +160,7 @@ export function QueryHeader({
160160
{editorMode === EditorMode.Builder && (
161161
<>
162162
<InlineSwitch
163-
id={`bq-filter-${htmlId}}`}
163+
id={`bq-filter-${uuidv4()}}`}
164164
label="Filter"
165165
transparent={true}
166166
showLabel={true}
@@ -172,7 +172,7 @@ export function QueryHeader({
172172
/>
173173

174174
<InlineSwitch
175-
id={`bq-group-${htmlId}}`}
175+
id={`bq-group-${uuidv4()}}`}
176176
label="Group"
177177
transparent={true}
178178
showLabel={true}
@@ -184,7 +184,7 @@ export function QueryHeader({
184184
/>
185185

186186
<InlineSwitch
187-
id={`bq-order-${htmlId}}`}
187+
id={`bq-order-${uuidv4()}}`}
188188
label="Order"
189189
transparent={true}
190190
showLabel={true}
@@ -196,7 +196,7 @@ export function QueryHeader({
196196
/>
197197

198198
<InlineSwitch
199-
id={`bq-preview-${htmlId}}`}
199+
id={`bq-preview-${uuidv4()}}`}
200200
label="Preview"
201201
transparent={true}
202202
showLabel={true}
@@ -243,19 +243,12 @@ export function QueryHeader({
243243
<Space v={0.5} />
244244

245245
<EditorRow>
246-
<ProjectSelector
247-
apiClient={apiClient}
248-
value={query.project}
249-
onChange={onProjectChange}
250-
applyDefault
251-
inputId={`bq-project-${htmlId}`}
252-
/>
246+
<ProjectSelector apiClient={apiClient} value={query.project} onChange={onProjectChange} applyDefault />
253247

254248
<EditorField label="Dataset" width={25}>
255249
<DatasetSelector
256250
apiClient={apiClient}
257251
location={query.location}
258-
inputId={`bq-dataset-${htmlId}`}
259252
value={query.dataset === undefined ? null : query.dataset}
260253
project={query.project}
261254
onChange={onDatasetChange}
@@ -266,7 +259,6 @@ export function QueryHeader({
266259
<TableSelector
267260
apiClient={apiClient}
268261
query={query}
269-
inputId={`bq-table-${htmlId}`}
270262
value={query.table === undefined ? null : query.table}
271263
onChange={onTableChange}
272264
applyDefault

src/components/TableSelector.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,9 @@ interface TableSelectorProps extends ResourceSelectorProps {
99
value: string | null;
1010
query: QueryWithDefaults;
1111
onChange: (v: SelectableValue) => void;
12-
inputId?: string;
1312
}
1413

15-
export const TableSelector: React.FC<TableSelectorProps> = ({
16-
apiClient,
17-
query,
18-
value,
19-
className,
20-
onChange,
21-
inputId,
22-
}) => {
14+
export const TableSelector: React.FC<TableSelectorProps> = ({ apiClient, query, value, className, onChange }) => {
2315
const state = useAsync(async () => {
2416
if (!query.dataset) {
2517
return [];
@@ -32,7 +24,6 @@ export const TableSelector: React.FC<TableSelectorProps> = ({
3224
<Select
3325
className={className}
3426
disabled={state.loading}
35-
inputId={inputId}
3627
aria-label="Table selector"
3728
value={value}
3829
options={state.value}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@
23352335
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.3.tgz#3d06b6769518450871fbc40770b7586334bdfd90"
23362336
integrity sha512-THo502dA5PzG/sfQH+42Lw3fvmYkceefOspdCwpHRul8ik2Jv1K8I5OZz1AT3/rs46kwgMCe9bSBmDLYkkOMGg==
23372337

2338-
"@types/uuid@^8.3.3":
2338+
"@types/uuid@^8.3.1", "@types/uuid@^8.3.3":
23392339
version "8.3.4"
23402340
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
23412341
integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==

0 commit comments

Comments
 (0)