-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add allowed config keys feature #120
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
base: main
Are you sure you want to change the base?
Conversation
Code Review Summary✨ This pull request successfully refactors the application's configuration management by removing a custom 🚀 Key Improvements
💡 Minor Suggestions
🚨 Critical Issues
|
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.
Review complete. See the overview comment for a summary.
9d57617 to
7a9baee
Compare
🔍 Code Review💡 1. **app/Http/Controllers/API/v1/ConfigurationController.php** (Lines 26-37) - STYLEThe current implementation defines the Suggested Code: Current Code: $rules = [
'key' => 'required',
'value' => 'required',
'type' => 'required|in:string,int,float,bool,array,json,date',
'client_id' => ['nullable', 'string', new ValidateClientId],
];
$allowedKeys = $this->getAllowedConfigKeys();
if (! empty($allowedKeys)) {
$rules['key'] = 'required|in:'.implode(',', $allowedKeys);
}
$validator = Validator::make($request->all(), $rules);💡 2. **app/Http/Controllers/API/v1/ConfigurationController.php** (Lines 93-95) - CLARITYThe current logic for Suggested Code: Current Code: if (isset($data['client_id']) && ! $config->client_id) {
$config->setClientGeneratedId($data['client_id'], $user);
}💡 3. **tests/Feature/ConfigurationTest.php** (Lines 70-77) - IMPROVEMENTAdd a test case to ensure that attempting to update a non-existent configuration key returns a 404 status. This covers an important negative scenario handled by the Suggested Code: Verdict: APPROVE Posted as a comment because posting a review failed. |
nfebe
left a comment
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.
This basically re-implements the feature which means our package is poorly designed.
This too : #114
Is problematic, packages are used to prevent these kind of things.
I will do some changes in the package.
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.
Review complete. See the overview comment for a summary.
ce1f88c to
b6eacfb
Compare
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.
Review complete. No specific code suggestions were generated. See the overview comment for a summary.
Update to use eloquent-model-configuration v1.0.6 which supports custom Configuration models without requiring controller duplication. Changes: - Update package version to ^1.0.6 - Enable package routes and configure custom model - Remove custom ConfigurationController (140+ lines) - Remove custom Configurable trait override - Update User model to use package trait - Remove custom configuration routes The custom Configuration model with Syncable trait is retained for sync functionality, while all other code now comes from the package, ensuring automatic updates for features like allowed_keys validation. Signed-off-by: nfebe <[email protected]>
b6eacfb to
eec46e6
Compare
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.
Review complete. See the overview comment for a summary.
|
Made some update solving 1 critical issue and closing For example you where still using version All now fix, please review if you catch anything if not I will merge. cc: @kofimokome |
|
@nfebe configurations are syncable. So your recent changes have removed the syncable functionality |
|
I actually updated to 1.0.5. Looks like I forgot to commit the composer.json file |
Not true. |
We still need to override the configuration controller. The endpoint to get Syncables has extra parameters like |
Still not true. We can append on the custom model you added. Which was NOT modified and which is why you don't see it here. |
|
I have tested with the recent changes, and the filtering is not working because the filters are applied at the controller level. using the public function index(Request $request): JsonResponse
{
$user = $request->user();
$walletsQuery = $user->wallets();
try {
$data = $this->applyApiQuery($request, $walletsQuery);
return $this->success($data);
} catch (\InvalidArgumentException $e) {
return $this->failure($e->getMessage(), 422);
}
}``` |
|
Or we can add a hook to the model controller. Trakli can use the hook to apply the filters 🤷 |
Yes this a geniune problem and it can be solved the way you mentioned. However, the core problem has been solved without needing to basically maintain a "fork" of the package here. So please you can go ahead and implement that at the package level then add one final commit here! I am now much happier with this direction as opposed to the previous one. |
Fixes #116