-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#119] Change set-field Web-API #128
Conversation
Problem: `set-field` route was used both for changing visibility and setting fields. This resulted in ambiguous behavior in case of missing contents and visibility options. Solution: require contents for setting field and allow changing visibility for convenience. Add `set-field-visibility` request which doesn't require field contents.
Seems in issue description field visibility should be a query parametr
|
Yes but that was an initial proposal, we later decided to split our queries into I don't want the |
Ok, IMO it would be more logical to make it query. JSON looks like overshot. And seems nothing chain us to JSON format |
Yeah, will redo. |
@Kariel-Myrr I moved visibility from JSON body to the query string. Now a request looks like
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
] | ||
|] | ||
-- unit_set_field_missing_field_contents :: IO () | ||
-- TODO: add test that expects an error in case of missing contents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems as unsolved TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved now, you can check how I did it, I'm not sure it is the proper way
void $ setField "dir/entry" "private-field" Nothing "contents" | ||
void $ setField "dir/entry" "public-field" Nothing "contents" | ||
changeFieldVisibility "dir/entry" "private-field" "private" | ||
changeFieldVisibility "dir/entry" "public-field" "public" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why there is two checks in one test?
If we're expecting to fail at once = one way (only private/public)
If it could fail on one, but not on second variant seems as two separate tests
I know that they're just doing the same thing, but we aren't short on test space)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍
tests/server-integration/Utils.hs
Outdated
@@ -102,8 +102,8 @@ scrubDates = | |||
cofferTest :: IO () -> IO () | |||
cofferTest test = deleteRecords >> test | |||
|
|||
setField :: Text -> Text -> Text -> IO (JsonResponse Value) | |||
setField path name contents = | |||
setField :: Text -> Text -> Maybe Bool -> Text -> IO (JsonResponse Value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not straight Maybe Visibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will change Bool
to Text
to unify the style with function changeFieldVisibility
72d11b0
to
e5e088d
Compare
This PR is closed due to existing #130. |
Description
Problem:
set-field
route was used both for changing visibilityand setting new fields. This resulted in additional handling of the
situation where both field contents and visibility option are missing.
Solution: require contents for setting field and allow changing
visibility for convenience. Add
set-field-visibility
requestwhich modifies only visibility.
Question?
Currently in
set-field-visibility
I pass the value in the body of the request.Maybe it would be better to pass it in the request string itself:
I don't know.
Related issue(s)
Fixed part of #119. Refactor of CLI API still needed.
✅ Checklist for your Pull Request
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Stylistic guide (mandatory)