Conversation
| const noCustomWildcardFields: CustomWildcardField[] = []; | ||
| const customWildcardFields = customWildcardFieldReducer( | ||
| noCustomWildcardFields, | ||
| const noCustomWildcardFieldDefs: CustomWildcardFieldDef[] = []; |
There was a problem hiding this comment.
Just use [], the name is unnecessary and is a bit confusing the first time I saw it.
| if (isWildcard(fieldDef.field)) { | ||
| if (fieldDef.field === '?') { | ||
| fields = schema.fieldNames() | ||
| .filter(field => schema.vlType(field) === type); |
There was a problem hiding this comment.
I would just tab by two empty space. (The current tabbing isn't aligned anyway)
|
|
||
| let field; | ||
| let popupComponent; | ||
| let isCustomWildcardField; |
There was a problem hiding this comment.
Why do you need let for isCustomWildcardField? You can just use const here.
| const key = isWildcard(fieldDef.field) ? stringify(fieldDef) : fieldDef.field; | ||
|
|
||
| let field; | ||
| let popupComponent; |
There was a problem hiding this comment.
For popupComponent, you may want to extract a method.
| const {schema, filters, handleAction} = this.props; | ||
| const key = isWildcard(fieldDef.field) ? stringify(fieldDef) : fieldDef.field; | ||
|
|
||
| let field; |
There was a problem hiding this comment.
Why do you need let for field? Just use const if possible.
|
|
||
| private renderField(fieldDef: ShelfFieldDef, popupComponent?: JSX.Element) { | ||
| const {schema, filters, handleAction} = this.props; | ||
| let filterShow; |
src/components/data-pane/index.tsx
Outdated
| data: Dataset; | ||
| export interface DataPanelProps extends ActionHandler<CustomWildcardAction> { | ||
| config: VoyagerConfig; | ||
| customWildcardFieldDefs: CustomWildcardFieldDef[]; |
There was a problem hiding this comment.
This doesn't seem to be used anywhere?
src/components/field/index.tsx
Outdated
| onRemove?: () => void; | ||
|
|
||
| handleAction?: (action: FilterAction | ShelfAction | DatasetSchemaChangeFieldType) => void; | ||
| handleAction?: (action: CustomWildcardAction | FilterAction | |
There was a problem hiding this comment.
Better make it implement ActionHandler?
|
|
||
| export interface CustomWildcardFieldDropZonePropsBase { | ||
| schema: Schema; | ||
| handleAction?: (action: CustomWildcardAction) => void; |
There was a problem hiding this comment.
Why is this optional? Better just make it implements ActionHandler
| customWildcardField: CustomWildcardFieldDef; | ||
| schema: Schema; | ||
| index: number; | ||
| handleAction?: (action: CustomWildcardAction) => void; |
There was a problem hiding this comment.
Why is this optional? Better just make it implements ActionHandler
|
|
||
| let fields; | ||
| if (isWildcard(fieldDef.field)) { | ||
| if (fieldDef.field === '?') { |
There was a problem hiding this comment.
Use SHORT_WILDCARD over question mark
| fields = schema.fieldNames() | ||
| .filter(field => schema.vlType(field) === type); | ||
| } else { | ||
| fields = fieldDef.field.enum.concat([]); |
| return; | ||
| } | ||
|
|
||
| const {fieldDef} = monitor.getItem() as DraggedFieldIdentifier; |
There was a problem hiding this comment.
Bad type inference. Monitor.getItem() is inferred simply as type 'Object' -- it doesn't know the object contains the property fieldDef. I casted to DraggedFieldIdentifier so it could infer fieldDef and let me write const {fieldDef} =. We do the same thing in encoding-shelf.tsx for the encodingShelfTarget.
| }); | ||
| } | ||
|
|
||
| private handleDescriptionChange(event: any) { |
| ); | ||
| } | ||
|
|
||
| protected customWildcardRemoveField(field: string) { |
There was a problem hiding this comment.
Use consistent name onRemoveField (we use on... elsewhere in the project)
(customWildcardRemoveField isn't consistent with handleDescriptionChange.)
| return connectDropTarget(this.props.children[0]); | ||
| } | ||
|
|
||
| private customWildcardRemove() { |
There was a problem hiding this comment.
Why do you need this remove here?
a892f0c to
81425d7
Compare
1c5b259 to
187272a
Compare
187272a to
9ec6fb1
Compare
|
cc: @kanitw |
92d5004 to
8015021
Compare
|
Is this ready? If so, rebase? |
CustomWildcardField ==> CustomWildcardFieldDef
Trying to make Field both a dragsource and droptarget
8015021 to
aef4b0f
Compare
|
cc @kanitw Rebased. |
|
There is a conflict -- do you want to rebase and squash to one commit (or a few commits that are more useful?) |
| fields = schema.fieldNames() | ||
| .filter(field => schema.vlType(field) === type); | ||
| } else { | ||
| fields = droppedFieldDef.field.enum.concat([]); |
| (state: State) => { | ||
| return { | ||
| // Somehow TS does not infer type that CustomWildcardFieldDefs can be a ShelfFieldDef | ||
| fieldDefs: selectCustomWildcardFieldDefs(state) as ShelfFieldDef[], |
There was a problem hiding this comment.
There are so too casting in this PR -- I doubt if we really need all of them.
Can you see if upgrading to the latest TS allow you to eliminate a lot of these as?
|
|
||
| if (isCustomWildcardField) { | ||
| const fields = (fieldDef as CustomWildcardFieldDef).field.enum; // TS isn't the inferring correct type | ||
| customWildcardFieldDescription = "(" + fields.length + ") " + (description || fields.toString()); |
There was a problem hiding this comment.
fields.toString()
This will add comma without space -- is that what you want?
Wouldn't it be better to .join(', ')?
|
|
||
| const component = ( | ||
| const isCustomWildcardField = isWildcardDef(fieldDef.field); | ||
| let customWildcardFieldDescription = ""; |
There was a problem hiding this comment.
Please always use single quote for TS code. (Do the same for the whole PR)
|
|
||
| export type CustomWildcardField = { | ||
| fields: string[]; | ||
| export type CustomWildcardFieldDef = { |
| @@ -0,0 +1,23 @@ | |||
| .drop-zone { | |||
There was a problem hiding this comment.
-
Instead of declaring a totally new CSS, can this extend some style of Field
-
The old version of Voyager has nicer CSS here
- We should rounded corner like normal Field
- It should be semi-transparent

Fix #555