console: support global_select_limit for bigquery sources

https://github.com/hasura/graphql-engine-mono/pull/1812

GitOrigin-RevId: 55785579523fcd3500486139431c4d9b3c1ace19
This commit is contained in:
Sooraj 2021-07-16 20:34:30 +05:30 committed by hasura-bot
parent 2aeb6ad0b1
commit 08847566d8
9 changed files with 45 additions and 1 deletions

View File

@ -3,6 +3,7 @@
## Next release
(Add entries below in the order of server, console, cli, docs, others)
- console: support `global_select_limit` for bigquery sources
- cli: add `-o`/`--output` flag for `hasura metadata inconsistency list` command
## v2.0.2

View File

@ -6,6 +6,7 @@ interface LabeledInputProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
boldlabel?: boolean;
tooltipText?: string;
type?: string;
}
export const LabeledInput: React.FC<LabeledInputProps> = props => (
@ -15,7 +16,7 @@ export const LabeledInput: React.FC<LabeledInputProps> = props => (
{props.tooltipText && <Tooltip message={props.tooltipText} />}
</label>
<input
type="text"
type={props?.type ?? 'text'}
className={`form-control ${styles.connect_db_input_pad}`}
{...props}
/>

View File

@ -315,6 +315,24 @@ const ConnectDatabaseForm: React.FC<ConnectDatabaseFormProps> = ({
placeholder="dataset1, dataset2"
data-test="datasets"
/>
<LabeledInput
label="Global Select Limit"
onChange={e => {
let data = Number.parseInt(e.target.value, 10);
if (Number.isNaN(data) || data <= 0) {
data = 0;
}
connectionDBStateDispatch({
type: 'UPDATE_DB_BIGQUERY_GLOBAL_LIMIT',
data,
});
}}
type="number"
min="0"
value={connectionDBState.databaseURLState.global_select_limit}
placeholder="1000"
data-test="global_select_limit"
/>
</>
) : null}
{connectionTypeState.includes(connectionTypes.CONNECTION_PARAMS) &&

View File

@ -130,6 +130,12 @@ const ConnectDatabase: React.FC<ConnectDatabaseProps> = props => {
type: 'UPDATE_DB_BIGQUERY_PROJECT_ID',
data: conf?.project_id ?? '',
});
if (conf?.global_select_limit) {
connectDBDispatch({
type: 'UPDATE_DB_BIGQUERY_GLOBAL_LIMIT',
data: +conf?.global_select_limit,
});
}
if (conf?.service_account?.from_env) {
changeConnectionType(connectionTypes.ENV_VAR);
connectDBDispatch({

View File

@ -56,6 +56,7 @@ describe('dataSourceIsEqual works', () => {
},
project_id: 'project_id',
datasets: ['dataset1'],
global_select_limit: 1000,
},
};
const request = {
@ -67,6 +68,7 @@ describe('dataSourceIsEqual works', () => {
client_email: 'email@bigquery_account.com',
},
project_id: 'project_id',
global_select_limit: 1000,
datasets: ['dataset1'],
},
replace_configuration: false,

View File

@ -31,6 +31,7 @@ export type ConnectDBState = {
databaseURLState: {
dbURL: string;
serviceAccount: string;
global_select_limit: number;
projectId: string;
datasets: string;
};
@ -56,6 +57,7 @@ export const defaultState: ConnectDBState = {
databaseURLState: {
dbURL: '',
serviceAccount: '',
global_select_limit: 1000,
projectId: '',
datasets: '',
},
@ -155,6 +157,7 @@ export const connectDataSource = (
bigQuery: {
projectId: currentState.databaseURLState.projectId,
datasets: currentState.databaseURLState.datasets,
global_select_limit: currentState.databaseURLState.global_select_limit,
},
...(checkEmpty(currentState.connectionSettings) && {
connection_pool_settings: currentState.connectionSettings,
@ -197,6 +200,7 @@ export type ConnectDBActions =
| { type: 'UPDATE_DISPLAY_NAME'; data: string }
| { type: 'UPDATE_DB_URL'; data: string }
| { type: 'UPDATE_DB_BIGQUERY_SERVICE_ACCOUNT'; data: string }
| { type: 'UPDATE_DB_BIGQUERY_GLOBAL_LIMIT'; data: number }
| { type: 'UPDATE_DB_BIGQUERY_PROJECT_ID'; data: string }
| { type: 'UPDATE_DB_BIGQUERY_DATASETS'; data: string }
| { type: 'UPDATE_DB_URL_ENV_VAR'; data: string }
@ -417,6 +421,14 @@ export const connectDBReducer = (
serviceAccount: action.data,
},
};
case 'UPDATE_DB_BIGQUERY_GLOBAL_LIMIT':
return {
...state,
databaseURLState: {
...state.databaseURLState,
global_select_limit: action.data,
},
};
case 'UPDATE_DB_BIGQUERY_DATASETS':
return {
...state,

View File

@ -129,6 +129,7 @@ export interface AddDataSourceRequest {
bigQuery: {
projectId: string;
datasets: string;
global_select_limit: number;
};
sslConfiguration?: SSLConfigOptions;
preparedStatements?: boolean;

View File

@ -16,6 +16,7 @@ export const addSource = (
bigQuery: {
projectId: string;
datasets: string;
global_select_limit: number;
};
sslConfiguration?: SSLConfigOptions;
preparedStatements?: boolean;
@ -58,6 +59,7 @@ export const addSource = (
name: payload.name,
configuration: {
service_account,
global_select_limit: payload.bigQuery.global_select_limit,
project_id: payload.bigQuery.projectId,
datasets: payload.bigQuery.datasets.split(',').map(d => d.trim()),
},

View File

@ -947,6 +947,7 @@ export interface MetadataDataSource {
// pro-only feature
read_replicas?: SourceConnectionInfo[];
service_account?: BigQueryServiceAccount;
global_select_limit?: number;
project_id?: string;
datasets?: string[];
};