Making the frontend type-agnostic #849
Replies: 3 comments 5 replies
-
"Alternative approach 3" sounds good for now. @pavish I really like "Alternative approach 1: Implement types as plugins on the frontend", and would hope that we could move in that direction in the long run. Obviously it raises many other questions, including security, so probably not worth tackling for the alpha release. |
Beta Was this translation helpful? Give feedback.
-
I think this relies a lot on what happens with Mathesar types (mathesar-foundation/mathesar-wiki#14). I feel like a combination of improving Mathesar type definition and simplifying UX would solve this in a robust way. I too like the current UX and I think that we don't have to discard it, but it might need iteration to account for the UI's declarative construction. Again, #14 will be at the center of this. Approach 1, serving frontend modules/code through the API, does not seem useful to me, off the top of my head. The modularization does not help with defining or using the API in a declarative way, right? Or, is this a way to achieve portability and scalability without declarativeness? Currently, I'm not convinced this would be effective. I think that we're on the right path and some iteration on Mathesar types and UX will be effective at addressing this. Procedural UI construction is a really cool problem and if we solve this right it could be a significant selling-point for Mathesar, I think. Edit: by the way, I really liked your samples from the frontend's data layer. They capture the complexity of the various operations and data structures very well, in my opinion. You've said that you see these as being hard to maintain, but a non-declarative UI would be much worse, right? The complexity seems to come from the complexity of database and Mathesar types, which I'd call essential complexity in this context. Again, I think the declarations you shared are on really good track. |
Beta Was this translation helpful? Give feedback.
-
I support Alternative Approach 3 with one caveat. Could we defer JSON representation of unknown types to the future, when we do our plugin architecture milestone? That way, we'll know more about how we're handling types and how we expect to plug new types in. As far as Alternative Approach 2, I'm fine with reevaluating some Mathesar types, but I don't think we should do it on the level of Integer vs. Decimal being separate types, this is not as approachable for non-technical users. I think you covered the drawbacks of Alternative Approach 1 pretty well. |
Beta Was this translation helpful? Give feedback.
-
Types are currently hard-coded at the component level on the frontend. The eventual goal is to make the frontend type-agnostic. Inorder to achieve that, the following information has to be provided by the backend: (I'm only covering the functional parts here and not the presentational elements)
Related:
If we were to hard-code all of these at the component layer, it will involve a massive refactor when we move to the api at a later stage.
Inorder to avoid that, we decided to move all the type related configurations into the data layer at the frontend. That way the component layer remains type-agnostic whereas the data layer has an isolated module which deals with hardcoded type configurations which would have the same response as we would expect the api to provide. When we are ready, the module could be modified to fetch the configuration data from an API without much hassle.
I've encountered some issues when implementing this, which would also be a factor when we move to the API. The following points are in the perspective of changing a column's type.
Approach 0 (Current approach): Use a seriazliable JSON to represent type options, which can be swapped by the API response.
As mentioned above, this will involve maintaining a hard-coded JSON on the frontend, which would later be provided by the API.
Some aspects of our UX is a bit complex to represent using a serializable JSON, although it is possible.
eg.,
The UI for Number type:
Requires the following JSON representation:
This would be a pain to maintain in the long run.
The frontend handles determination of the db_type from the selected mathesar_type + user configurations. This requires letting the frontend know how to do that.
eg.,
determinationRules
property.Validation & Display of user input
All of these lead me to accept that it is going to be incredibly hard to do this without implementing dedicated frontend code for each type.
I came up with some alternative approaches:
Alternative approach 1: Implement types as plugins on the frontend.
Drawbacks
Alternative approach 2: Re-evaluate mathesar_types and make UX for types simple enough to be represented as JSON
Drawbacks
Alternative approach 3: Support JSON representation but override it for known types we provide with the product
Drawbacks
I am inclined to go with Alternative approach 3.
I would love to hear your thoughts on this. @kgodey @seancolsen @mathemancer @dmos62 @silentninja
Beta Was this translation helpful? Give feedback.
All reactions