Fixed disable logic and disable hints for info providers

This commit is contained in:
Jan Böhmer 2025-08-24 21:10:38 +02:00
parent a48490ac1a
commit eaaf44b391
9 changed files with 28 additions and 27 deletions

View file

@ -78,7 +78,7 @@ class DigikeyProvider implements InfoProviderInterface
'description' => 'This provider uses the DigiKey API to search for parts.',
'url' => 'https://www.digikey.com/',
'oauth_app_name' => self::OAUTH_APP_NAME,
'disabled_help' => 'Set the PROVIDER_DIGIKEY_CLIENT_ID and PROVIDER_DIGIKEY_SECRET env option and connect OAuth to enable.'
'disabled_help' => 'Set the Client ID and Secret in provider settings and connect OAuth to enable.'
];
}
@ -101,7 +101,7 @@ class DigikeyProvider implements InfoProviderInterface
public function isActive(): bool
{
//The client ID has to be set and a token has to be available (user clicked connect)
return $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
return $this->settings->clientId !== null && $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
}
public function searchByKeyword(string $keyword): array

View file

@ -66,7 +66,7 @@ class Element14Provider implements InfoProviderInterface
'name' => 'Farnell element14',
'description' => 'This provider uses the Farnell element14 API to search for parts.',
'url' => 'https://www.element14.com/',
'disabled_help' => 'Configure the API key in the PROVIDER_ELEMENT14_KEY environment variable to enable.'
'disabled_help' => 'Configure the API key in the provider settings to enable.'
];
}

View file

@ -51,7 +51,7 @@ class LCSCProvider implements InfoProviderInterface
'name' => 'LCSC',
'description' => 'This provider uses the (unofficial) LCSC API to search for parts.',
'url' => 'https://www.lcsc.com/',
'disabled_help' => 'Set PROVIDER_LCSC_ENABLED to 1 (or true) in your environment variable config.'
'disabled_help' => 'Enable this provider in the provider settings.'
];
}

View file

@ -61,7 +61,7 @@ class MouserProvider implements InfoProviderInterface
'name' => 'Mouser',
'description' => 'This provider uses the Mouser API to search for parts.',
'url' => 'https://www.mouser.com/',
'disabled_help' => 'Configure the API key in the PROVIDER_MOUSER_KEY environment variable to enable.'
'disabled_help' => 'Configure the API key in the provider settings to enable.'
];
}

View file

@ -246,7 +246,7 @@ class OEMSecretsProvider implements InfoProviderInterface
'name' => 'OEMSecrets',
'description' => 'This provider uses the OEMSecrets API to search for parts.',
'url' => 'https://www.oemsecrets.com/',
'disabled_help' => 'Configure the API key in the PROVIDER_OEMSECRETS_KEY environment variable to enable.'
'disabled_help' => 'Configure the API key in the provider settings to enable.'
];
}
/**
@ -265,7 +265,7 @@ class OEMSecretsProvider implements InfoProviderInterface
*/
public function isActive(): bool
{
return $this->settings->apiKey !== '';
return $this->settings->apiKey !== null && $this->settings->apiKey !== '';
}

View file

@ -170,7 +170,7 @@ class OctopartProvider implements InfoProviderInterface
'name' => 'Octopart',
'description' => 'This provider uses the Nexar/Octopart API to search for parts on Octopart.',
'url' => 'https://www.octopart.com/',
'disabled_help' => 'Set the PROVIDER_OCTOPART_CLIENT_ID and PROVIDER_OCTOPART_SECRET env option.'
'disabled_help' => 'Set the Client ID and Secret in provider settings.'
];
}
@ -183,7 +183,8 @@ class OctopartProvider implements InfoProviderInterface
{
//The client ID has to be set and a token has to be available (user clicked connect)
//return /*!empty($this->clientId) && */ $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
return $this->settings->clientId !== '' && $this->settings->secret !== '';
return $this->settings->clientId !== null && $this->settings->clientId !== ''
&& $this->settings->secret !== null && $this->settings->secret !== '';
}
private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus

View file

@ -51,7 +51,7 @@ class PollinProvider implements InfoProviderInterface
'name' => 'Pollin',
'description' => 'Webscraping from pollin.de to get part information',
'url' => 'https://www.pollin.de/',
'disabled_help' => 'Set PROVIDER_POLLIN_ENABLED env to 1'
'disabled_help' => 'Enable the provider in provider settings'
];
}

View file

@ -51,7 +51,7 @@ class ReicheltProvider implements InfoProviderInterface
'name' => 'Reichelt',
'description' => 'Webscraping from reichelt.com to get part information',
'url' => 'https://www.reichelt.com/',
'disabled_help' => 'Set PROVIDER_REICHELT_ENABLED env to 1'
'disabled_help' => 'Enable provider in provider settings.'
];
}

View file

@ -54,7 +54,7 @@ class TMEProvider implements InfoProviderInterface
'name' => 'TME',
'description' => 'This provider uses the API of TME (Transfer Multipart).',
'url' => 'https://tme.eu/',
'disabled_help' => 'Configure the PROVIDER_TME_KEY and PROVIDER_TME_SECRET environment variables to use this provider.'
'disabled_help' => 'Configure the API Token and secret in provider settings to use this provider.'
];
}