Skip to content
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

Remove hardcoded fields #170

Merged
merged 5 commits into from
Dec 17, 2024
Merged

Remove hardcoded fields #170

merged 5 commits into from
Dec 17, 2024

Conversation

ashfame
Copy link
Member

@ashfame ashfame commented Dec 17, 2024

closes #161

@ashfame ashfame requested a review from psrpinto December 17, 2024 15:57
@ashfame ashfame self-assigned this Dec 17, 2024
case FieldType.Link:
acc[ fieldName ] = newLinkField(
rawValue,
...( parsedValue.split( '||' ) as [ string, string ] )
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psrpinto The only way I could think of supplying link's parsed value in a single string was to use a separator like ||. Let me know if you have ideas around handling this better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the correct solution here would be. For the moment, I think we could postpone this decision by not handling link here (removing the case for it) as there will be no field coming from the API of type link yet. At the moment, LinkField is only used in the UI (to parse navigation), but it's not yet sent to the server (as there is no need to store it yet).

Once we add link as a supported type of field in the schema, we would come back to this and figure out what to do. Would that make sense to you?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will comment out this much code rather than just deleting it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I see the value in keeping this code around, as it's a simple call to newLinkField(), so I think we'd be able to write the code again easily. I also have concerns about the specific implementation (using ||), as to me that is a sign that there's something off in the way we're expressing the data model. I think if we need to resort to this sort of "hack", something must be off in the data model.

That's why I was suggesting to just remove it, because I think that properly supporting LinkField (and other fields that are not just a string) will require re-evaluating the approach we're currently using for sending fields across the API.

If you think there is value in keeping this code commented out, I'm ok with it, but I generally don't see the value in keeping commented out code in repos.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value that I see in keeping this commented code is to serve as a pointer to come back to this exact discussion of what we discussed, what we were trying to do and why it didn't work. Other than that, I don't have any reasons to keep it around and if you prefer to keep commented code out, I will go ahead and remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping this commented code is to serve as a pointer to come back to this exact discussion

I didn't understand your intention initially, I'm fine with this. In that case, would it make sense to add a comment in the code with a link to this discussion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have explicitly linked the PR instead indeed, but merged it already now.

Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fantastic, well done!

case FieldType.Link:
acc[ fieldName ] = newLinkField(
rawValue,
...( parsedValue.split( '||' ) as [ string, string ] )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the correct solution here would be. For the moment, I think we could postpone this decision by not handling link here (removing the case for it) as there will be no field coming from the API of type link yet. At the moment, LinkField is only used in the UI (to parse navigation), but it's not yet sent to the server (as there is no need to store it yet).

Once we add link as a supported type of field in the schema, we would come back to this and figure out what to do. Would that make sense to you?

src/api/SubjectsApi.ts Outdated Show resolved Hide resolved
@ashfame ashfame requested a review from psrpinto December 17, 2024 18:15
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be ok with keeping the commented out in with a link to the discussion. Whichever your decision, feel free to merge.

@ashfame ashfame merged commit 4c0e46f into trunk Dec 17, 2024
3 checks passed
@ashfame ashfame deleted the unhardcode_fields branch December 17, 2024 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't hardcode fields when getting or updating subject
2 participants