Skip to content

Commit 83cedfc

Browse files
author
ci bot
committed
Merge branch 'table-groups-filter' into 'enterprise'
feat: add partial name filter to table group list See merge request dkinternal/testgen/dataops-testgen!291
2 parents 40546bc + d3bb59a commit 83cedfc

4 files changed

Lines changed: 67 additions & 25 deletions

File tree

testgen/ui/components/frontend/js/components/connection_form.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ const RedshiftForm = (
486486
value: connectionPassword,
487487
height: 38,
488488
type: 'password',
489+
passwordSuggestions: false,
489490
placeholder: (originalConnection?.connection_id && originalConnection?.project_pw_encrypted) ? secretsPlaceholder : '',
490491
onChange: (value, state) => {
491492
connectionPassword.val = value;
@@ -683,6 +684,7 @@ const DatabricksForm = (
683684
value: connectionPassword,
684685
height: 38,
685686
type: 'password',
687+
passwordSuggestions: false,
686688
placeholder: (originalConnection?.connection_id && originalConnection?.project_pw_encrypted) ? secretsPlaceholder : '',
687689
onChange: (value, state) => {
688690
connectionPassword.val = value;
@@ -891,6 +893,7 @@ const SnowflakeForm = (
891893
value: connectionPrivateKeyPassphrase,
892894
height: 38,
893895
type: 'password',
896+
passwordSuggestions: false,
894897
help: 'Passphrase used when creating the private key. Leave empty if the private key is not encrypted.',
895898
placeholder: () => (originalConnection?.connection_id && originalConnection?.private_key_passphrase && !clearPrivateKeyPhrase.val) ? secretsPlaceholder : '',
896899
onChange: (value, state) => {
@@ -928,7 +931,7 @@ const SnowflakeForm = (
928931
console.error(err);
929932
isFieldValid = false;
930933
}
931-
validityPerField['private_key'] = state.valid;
934+
validityPerField['private_key'] = isFieldValid;
932935
isValid.val = Object.values(validityPerField).every(v => v);
933936
},
934937
validators: [
@@ -944,6 +947,7 @@ const SnowflakeForm = (
944947
value: connectionPassword,
945948
height: 38,
946949
type: 'password',
950+
passwordSuggestions: false,
947951
placeholder: (originalConnection?.connection_id && originalConnection?.project_pw_encrypted) ? secretsPlaceholder : '',
948952
onChange: (value, state) => {
949953
connectionPassword.val = value;

testgen/ui/components/frontend/js/components/input.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @property {string?} icon
2121
* @property {boolean?} clearable
2222
* @property {('value' | 'always')?} clearableCondition
23+
* @property {boolean?} passwordSuggestions
2324
* @property {function(string, InputState)?} onChange
2425
* @property {boolean?} disabled
2526
* @property {function(string, InputState)?} onClear
@@ -164,6 +165,7 @@ const Input = (/** @type Properties */ props) => {
164165
name: props.name ?? '',
165166
type: inputType,
166167
disabled: props.disabled,
168+
...(props.passwordSuggestions ?? true ? {} : {autocomplete: 'off', 'data-op-ignore': true}),
167169
placeholder: () => getValue(props.placeholder) ?? '',
168170
oninput: debounce((/** @type Event */ event) => value.val = event.target.value, 300),
169171
onclick: van.derive(() => autocompleteOptions.val?.length

testgen/ui/components/frontend/js/pages/table_group_list.js

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* @type {object}
1212
* @property {ProjectSummary} project_summary
1313
* @property {string?} connection_id
14+
* @property {string?} table_group_name
1415
* @property {Connection[]} connections
1516
* @property {TableGroup[]} table_groups
1617
* @property {Permissions} permissions
@@ -26,6 +27,7 @@ import { EMPTY_STATE_MESSAGE, EmptyState } from '../components/empty_state.js';
2627
import { Select } from '../components/select.js';
2728
import { Icon } from '../components/icon.js';
2829
import { withTooltip } from '../components/tooltip.js';
30+
import { Input } from '../components/input.js';
2931

3032
const { div, h4, i, span } = van.tags;
3133

@@ -49,6 +51,7 @@ const TableGroupList = (props) => {
4951
const permissions = getValue(props.permissions) ?? {can_edit: false};
5052
const connections = getValue(props.connections) ?? [];
5153
const connectionId = getValue(props.connection_id);
54+
const tableGroupNameFilter = getValue(props.table_group_name);
5255
const tableGroups = getValue(props.table_groups) ?? [];
5356
const projectSummary = getValue(props.project_summary);
5457

@@ -68,7 +71,7 @@ const TableGroupList = (props) => {
6871

6972
return projectSummary.table_group_count > 0
7073
? div(
71-
Toolbar(permissions, connections, connectionId),
74+
Toolbar(permissions, connections, connectionId, tableGroupNameFilter),
7275
tableGroups.length
7376
? tableGroups.map((tableGroup) => Card({
7477
testId: 'table-group-card',
@@ -211,25 +214,49 @@ const TableGroupList = (props) => {
211214
* @param {Permissions} permissions
212215
* @param {Connection[]} connections
213216
* @param {string?} selectedConnection
217+
* @param {string?} tableGroupNameFilter
214218
* @returns
215219
*/
216-
const Toolbar = (permissions, connections, selectedConnection) => {
220+
const Toolbar = (permissions, connections, selectedConnection, tableGroupNameFilter) => {
221+
const connection = van.state(selectedConnection || null);
222+
const tableGroupFilter = van.state(tableGroupNameFilter || null);
223+
224+
van.derive(() => {
225+
if (connection.val !== selectedConnection || tableGroupFilter.val !== tableGroupNameFilter) {
226+
emitEvent('TableGroupsFiltered', { payload: { connection_id: connection.val || null, table_group_name: tableGroupFilter.val || null } });
227+
}
228+
});
229+
217230
return div(
218231
{ class: 'flex-row fx-align-flex-end fx-justify-space-between mb-4' },
219-
(getValue(connections) ?? [])?.length > 1
220-
? Select({
221-
testId: 'connection-select',
222-
label: 'Connection',
223-
allowNull: true,
232+
div(
233+
{class: 'flex-row fx-gap-4'},
234+
(getValue(connections) ?? [])?.length > 1
235+
? Select({
236+
testId: 'connection-select',
237+
label: 'Connection',
238+
allowNull: true,
239+
height: 38,
240+
value: connection,
241+
options: getValue(connections)?.map((connection) => ({
242+
label: connection.connection_name,
243+
value: String(connection.connection_id),
244+
})) ?? [],
245+
onChange: (value) => connection.val = value,
246+
})
247+
: '',
248+
Input({
249+
testId: 'table-groups-name-filter',
250+
icon: 'search',
251+
label: '',
252+
placeholder: 'Search table group names',
224253
height: 38,
225-
value: selectedConnection,
226-
options: getValue(connections)?.map((connection) => ({
227-
label: connection.connection_name,
228-
value: String(connection.connection_id),
229-
})) ?? [],
230-
onChange: (value) => emitEvent('ConnectionSelected', { payload: value }),
231-
})
232-
: span(''),
254+
width: 300,
255+
clearable: true,
256+
value: tableGroupFilter,
257+
onChange: (value) => tableGroupFilter.val = value || null,
258+
}),
259+
),
233260
div(
234261
{ class: 'flex-row fx-gap-4' },
235262
Button({

testgen/ui/views/table_groups.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,38 @@ class TableGroupsPage(Page):
4040
roles=[ role for role in typing.get_args(user_session_service.RoleType) if role != "catalog" ],
4141
)
4242

43-
def render(self, project_code: str, connection_id: str | None = None, **_kwargs) -> None:
43+
def render(
44+
self,
45+
project_code: str,
46+
connection_id: str | None = None,
47+
table_group_name: str | None = None,
48+
**_kwargs,
49+
) -> None:
4450
testgen.page_header(PAGE_TITLE, "create-a-table-group")
4551

4652
user_can_edit = user_session_service.user_can_edit()
4753
project_summary = Project.get_summary(project_code)
4854
if connection_id and not connection_id.isdigit():
4955
connection_id = None
5056

57+
table_group_filters = [
58+
TableGroup.project_code == project_code,
59+
]
5160
if connection_id:
52-
table_groups = TableGroup.select_minimal_where(
53-
TableGroup.project_code == project_code,
54-
TableGroup.connection_id == connection_id,
55-
)
56-
else:
57-
table_groups = TableGroup.select_minimal_where(TableGroup.project_code == project_code)
61+
table_group_filters.append(TableGroup.connection_id == connection_id)
62+
63+
if table_group_name:
64+
table_group_filters.append(TableGroup.table_groups_name.ilike(f"%{table_group_name}%"))
5865

66+
table_groups = TableGroup.select_minimal_where(*table_group_filters)
5967
connections = self._get_connections(project_code)
6068

6169
return testgen.testgen_component(
6270
"table_group_list",
6371
props={
6472
"project_summary": project_summary.to_dict(json_safe=True),
6573
"connection_id": connection_id,
74+
"table_group_name": table_group_name,
6675
"permissions": {
6776
"can_edit": user_can_edit,
6877
},
@@ -75,9 +84,9 @@ def render(self, project_code: str, connection_id: str | None = None, **_kwargs)
7584
"EditTableGroupClicked": partial(self.edit_table_group_dialog, project_code),
7685
"DeleteTableGroupClicked": partial(self.delete_table_group_dialog, project_code),
7786
"RunProfilingClicked": partial(self.run_profiling_dialog, project_code),
78-
"ConnectionSelected": lambda inner_connection_id: self.router.queue_navigation(
87+
"TableGroupsFiltered": lambda params: self.router.queue_navigation(
7988
to="table-groups",
80-
with_args={"project_code": project_code, "connection_id": inner_connection_id},
89+
with_args={"project_code": project_code, **params},
8190
),
8291
},
8392
)

0 commit comments

Comments
 (0)