Commit Message : git commit -m 'Issue #2734841 by ajalan065, naveenvalecha, penyaskito, eugene.ilyin: Implement a runtime requirement checking if API key is not set' --author="ajalan065 <ajalan065@3224995.no-reply.drupal.org>"
At present, the status report does not show up any error if the API key is not set on the admin config page. But setting the key is required to carry out the functionalities of the module.
If the user forgets to set the API key, the status report must reflect the same.
Remaining Tasks:
Develop a patch which would check for the requirement at runtime and would show up the notice on the Status Report page if the key is not set.
Technical Implementation :
- Add a hook_requirements and phase should be runtime. See for an example like https://api.drupal.org/api/drupal/core%21modules%21system%21system.insta...
Comment | File | Size | Author |
---|---|---|---|
#42 | 2734841-42.patch | 3.97 KB | naveenvalecha |
| |||
#32 | interdiff-2734841-30-32.txt | 1004 bytes | ajalan065 |
#32 | access-modifier-added-8-2734841-8-32.patch | 3.97 KB | ajalan065 |
| |||
#30 | interdiff-2734841-27-30.txt | 2.08 KB | ajalan065 |
#30 | Useless-lines-removed-2734841-8-30.patch | 3.96 KB | ajalan065 |
|
Comments
Comment #2
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedComment #3
naveenvalechaI think we then don't need to throw the exception at run time.
Eugene, what do you reckon here ?
Comment #4
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the patch which implements hook_requirements(), giving the notice at status page if the key is not set.
Comment #5
naveenvalechause \Drupal::config('google_vision.settings')->get('api_key');
use Url::fromRoute instead of \Drupal::url
Comment #6
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedChanges implemented as suggested in #5.
Comment #7
naveenvalechalet's do it.
create a separate issue for Handling errors in Response.
Comment #8
naveenvalechaComment #9
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the issue https://www.drupal.org/node/2736567 to handle errors from Google Vision API Response.
Comment #10
penyaskito"The API key is not set at /admin/config/media/google_vision. It is highly required to set the API Key at the :settings page."
I don't see the point of giving an end user a message with a path.
Also, I don't think "highly required" makes sense, it is required or it is not.
Let's change it to something like
"Google Vision API key is not set and it is required for some functionalities to work. Please set it up at the :Google Vision module settings page."
Comment #11
penyaskitoAlso, let's include Google Vision API as the title, so we have the right context. See the following screenshot, and you won't know which API key are we talking about here.
Comment #12
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedNew patch and interdiff implementing the changes as suggested in #10 and #11.
Kindly review the patch. :)
Comment #13
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedComment #14
penyaskitoThe link is not working.
Comment #15
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedThe links are now working.
Please check for any other issues.
Comment #16
penyaskitoI think this is a perfect issue for setting up our first WebTest. Please read https://www.drupal.org/contributor-tasks/write-tests for getting started.
Comment #17
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedComment #18
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedTest for api key configuration
Comment #19
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the patch combining the patch from #15 along with its tests.
Comment #20
penyaskitoThis looks really great, congrats. Some minor comments:
Use {@inheritdoc}
Is $config used there? I think that statement is useless.
Don't use an if. If the field doesn't exist, it will fail the test already.
And assert that the link goes to the right page.
Comment #21
penyaskitoI forgot: this phpdoc is not accurate, that's not what we are testing.
But we should add a test for testing that too.
Comment #22
penyaskitoComment #23
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the patch along with the interdiff implementing all the suggestions as in #20.
Comment #24
penyaskitoWe still need a test for saving the Google Vision API Key and verify that it's stored successfully.
Comment #25
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedThe test for saving the API key and verifying whether it is stored successfully(#24) has been implemented in the attached patch.
Comment #26
naveenvalechaWhy we are restricting strictconfigschema ?
Define the schema/metadata of the config being used.
See https://www.drupal.org/node/1905070
Comment #27
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the patch implementing the suggestions of #26.
Comment #28
penyaskitoThis use statement is not needed I think? Just looking at the patch, not in context.
This should be {@inheritdoc}
Otherwise looks good to me.
Comment #29
penyaskitoThis new line is weird too. And I would prefer short array syntax, but that's a matter of taste I guess.
Extra empty line.
Variables are usually using underscore vs camelCase. See https://www.drupal.org/coding-standards#naming
Usually we use $edit as a name for this variables, but I don't care that much. Maybe you want to change it for consistence.
Also, can be a single line.
Comment #30
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHere is the new patch implementing the suggestions of #28.
In #29, all the points have been implemented except the first one. Instead of assigning a new array, I merged the two in the same line.
But still I would change it if it is required to.
Comment #31
naveenvalechaAdd the access modifier of the function. same as below one.
Comment #32
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedAccess modifier added as per #31.
Comment #33
penyaskitoLooks good to me, thanks :D
Comment #34
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedThanks :)
Comment #40
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedPatch looks okay, but in this patch you're modifying the file google_vision.schema.yml. This file is not exists yet. Maybe another issue should be solved befor it?
Comment #41
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commentedHi Eugene,
Sorry, I could not understand what you want to convey by
google_vision.schema.yml is present under the config/schema/google_vision.schema.yml
Comment #42
naveenvalechaThe patch needs reroll as the permission of the google_vision.schema.yml was changed from 755 to 644 in #2731801: Use of services to access functions
Here's the updated patch with the permission fixing.Hope this will cleanly apply
@ajalan065,
There's nothing major needs to be done here.
let's go for it and enable to drupalci on project :)
Comment #43
naveenvalechaAdding proposed commit mesage
Comment #44
penyaskitoComment #45
ajalan065 CreditAttribution: ajalan065 at Google Summer of Code commented@naveenvalecha, Thanks :)
Comment #46
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commented@ajalan
sorry, I was wrong about the file config/schema/google_vision.schema.yml
Comment #47
naveenvalechaThanks! There's was not my code so doing RTBC it.
Comment #48
naveenvalechaCommitted and pushed to 8.x-1.x
Well now we have tests :)
Comment #49
naveenvalechaupdating commit message.
Comment #51
naveenvalecha