-
Notifications
You must be signed in to change notification settings - Fork 190
feat(frontend): add Python UDF UI parameter form support #5043
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7c1d4af
feat(frontend): add Python UDF UI parameter inference
carloea2 f009a36
fix(frontend): reject large binary UI parameters locally
carloea2 9c533e4
Merge branch 'main' into ui-parameter-frontend
carloea2 99b3a37
test(frontend): cover multiline UI parameter parsing
carloea2 a0cbcd9
Merge branch 'main' into ui-parameter-frontend
Xiao-zhen-Liu 4d1a34a
Merge branch 'main' into ui-parameter-frontend
Xiao-zhen-Liu 638ad33
Merge branch 'main' into ui-parameter-frontend
carloea2 8cad906
fix(frontend): address UI parameter review feedback
carloea2 99bb449
refactor(frontend): compact UI parameter foundation
carloea2 9812925
Revert "refactor(frontend): compact UI parameter foundation"
carloea2 e37cc6e
fix(frontend): tighten UI parameter parser feedback
carloea2 5988e50
Merge branch 'main' into ui-parameter-frontend
carloea2 9de4c3a
refactor(frontend): compact UI parameter foundation
carloea2 d06f5d9
Merge remote-tracking branch 'upstream/main' into ui-parameter-frontend
carloea2 432f7cb
Merge remote-tracking branch 'origin/ui-parameter-frontend' into ui-p…
carloea2 7756cbd
fix(frontend): satisfy UI parameter lint
carloea2 e954e2e
refactor(frontend): read UI parameter member paths from AST
carloea2 5afd325
refactor(frontend): centralize Python parser node names
carloea2 2222509
refactor(frontend): normalize UI parameter arguments
carloea2 bc27c11
fix(frontend): address ui parameter follow-up review
carloea2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/src/app/workspace/component/ui-udf-parameters/ui-udf-parameters.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
| <div | ||
| class="ui-udf-param-list" | ||
| *ngIf="(model?.length ?? 0) > 0"> | ||
| <!-- Optional header row --> | ||
| <div class="ui-udf-param-row header"> | ||
| <div class="field-cell"><span class="col-title">Value</span></div> | ||
| <div class="field-cell"><span class="col-title">Name</span></div> | ||
| <div class="field-cell"><span class="col-title">Type</span></div> | ||
| </div> | ||
|
|
||
| <div | ||
| class="ui-udf-param-row" | ||
| *ngFor="let param of (model || []); let i = index; trackBy: trackByParamName"> | ||
| <ng-container *ngIf="field.fieldGroup?.[i] as rowField"> | ||
| <!-- Value --> | ||
| <div class="field-cell"> | ||
| <ng-container *ngIf="getValueField(rowField) as valueField"> | ||
|
carloea2 marked this conversation as resolved.
Outdated
|
||
| <formly-field [field]="valueField"></formly-field> | ||
| </ng-container> | ||
| </div> | ||
|
|
||
| <!-- Name --> | ||
| <div class="field-cell"> | ||
| <ng-container *ngIf="getNameField(rowField) as nameField"> | ||
| <formly-field [field]="nameField"></formly-field> | ||
| </ng-container> | ||
| </div> | ||
|
|
||
| <!-- Type --> | ||
| <div class="field-cell"> | ||
| <ng-container *ngIf="getTypeField(rowField) as typeField"> | ||
| <formly-field [field]="typeField"></formly-field> | ||
| </ng-container> | ||
| </div> | ||
| </ng-container> | ||
| </div> | ||
| </div> | ||
39 changes: 39 additions & 0 deletions
39
frontend/src/app/workspace/component/ui-udf-parameters/ui-udf-parameters.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| .ui-udf-param-row { | ||
| display: grid; | ||
| grid-template-columns: 250px 250px 1fr; | ||
| gap: 12px; | ||
| align-items: start; | ||
| } | ||
|
|
||
| .field-cell { | ||
| min-width: 0; | ||
| } | ||
|
|
||
| /* Remove Formly/Ant label spacing */ | ||
| :host ::ng-deep .ant-form-item { | ||
| margin-bottom: 0; | ||
| } | ||
|
|
||
| /* Hide Formly labels*/ | ||
| :host ::ng-deep .ant-form-item-label { | ||
| display: none; | ||
| } |
93 changes: 93 additions & 0 deletions
93
frontend/src/app/workspace/component/ui-udf-parameters/ui-udf-parameters.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import { Component } from "@angular/core"; | ||
| import { NgFor, NgIf } from "@angular/common"; | ||
| import { FieldArrayType, FormlyFieldConfig, FormlyModule } from "@ngx-formly/core"; | ||
|
|
||
| @Component({ | ||
| selector: "texera-ui-udf-parameters", | ||
| templateUrl: "./ui-udf-parameters.component.html", | ||
| styleUrls: ["./ui-udf-parameters.component.scss"], | ||
| imports: [NgIf, NgFor, FormlyModule], | ||
| }) | ||
| export class UiUdfParametersComponent extends FieldArrayType { | ||
| private getField(rowField: FormlyFieldConfig, key: string): FormlyFieldConfig | undefined { | ||
| return rowField.fieldGroup?.find(f => f.key === key); | ||
| } | ||
|
|
||
| private getAttributeChild(rowField: FormlyFieldConfig, childKey: string): FormlyFieldConfig | undefined { | ||
| const attributeGroup = this.getField(rowField, "attribute"); | ||
| return attributeGroup?.fieldGroup?.find(f => f.key === childKey); | ||
| } | ||
|
|
||
| private setDisabled(field: FormlyFieldConfig | undefined, disabled: boolean): FormlyFieldConfig | undefined { | ||
| if (!field) return undefined; | ||
|
|
||
| // 1) Modern Formly | ||
| field.props = { ...(field.props ?? {}), disabled }; | ||
|
|
||
| // 2) Compatibility for templates/wrappers still using templateOptions | ||
| // (`as any` so we don't get nagged by the @deprecated JSDoc) | ||
| (field as any).templateOptions = { ...((field as any).templateOptions ?? {}), disabled }; | ||
|
|
||
| // 3) Enforce at the reactive form level | ||
| if (field.formControl) { | ||
| if (disabled) { | ||
| field.formControl.disable({ emitEvent: false }); | ||
| } else { | ||
| field.formControl.enable({ emitEvent: false }); | ||
| } | ||
| } else { | ||
| // If control isn't created yet, disable it at init time. | ||
| const prevOnInit = field.hooks?.onInit; | ||
| field.hooks = { | ||
| ...(field.hooks ?? {}), | ||
| onInit: f => { | ||
| prevOnInit?.(f); | ||
| if (disabled) { | ||
| f.formControl?.disable({ emitEvent: false }); | ||
| } else { | ||
| f.formControl?.enable({ emitEvent: false }); | ||
| } | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| return field; | ||
| } | ||
|
|
||
| // Disable Name | ||
| getNameField(rowField: FormlyFieldConfig): FormlyFieldConfig | undefined { | ||
| return this.setDisabled(this.getAttributeChild(rowField, "attributeName"), true); | ||
| } | ||
|
|
||
| // Disable Type | ||
| getTypeField(rowField: FormlyFieldConfig): FormlyFieldConfig | undefined { | ||
| return this.setDisabled(this.getAttributeChild(rowField, "attributeType"), true); | ||
| } | ||
|
|
||
| // Value editable | ||
| getValueField(rowField: FormlyFieldConfig): FormlyFieldConfig | undefined { | ||
| return this.setDisabled(this.getField(rowField, "value"), false); | ||
| } | ||
|
|
||
| trackByParamName = (index: number, param: any): string | number => { | ||
| return param?.attribute?.attributeName ?? index; | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.