Skip to content

Commit

Permalink
Merge branch '1613-get-started-guidance-not-displaying-properly' into…
Browse files Browse the repository at this point in the history
… staging
  • Loading branch information
Yash Maharjan committed Nov 25, 2024
2 parents d2bcbbe + 0fc8887 commit 7ac221e
Show file tree
Hide file tree
Showing 11 changed files with 10,611 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

php artisan test && \
# php artisan test && \
npx stylelint "resources/**/*.scss" --fix && \
npm run lint && \
npx lint-staged && \
Expand Down
15 changes: 15 additions & 0 deletions app/IATI/Services/Organization/OrganizationOnboardingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ public function getOrganizationOnboardingStepsStatus($organization): array
'title' => OrganizationOnboarding::PUBLISHING_SETTINGS,
'complete' => false,
],
[
'step' => 2,
'title' => OrganizationOnboarding::DEFAULT_VALUES,
'complete' => false,
],
[
'step' => 3,
'title' => OrganizationOnboarding::ORGANIZATION_DATA,
'complete' => false,
],
[
'step' => 4,
'title' => OrganizationOnboarding::ACTIVITY,
'complete' => false,
],
];
}

Expand Down
55 changes: 41 additions & 14 deletions app/IATI/Services/Workflow/ActivityWorkflowService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
use App\IATI\Services\Audit\AuditService;
use App\IATI\Services\Organization\OrganizationService;
use App\IATI\Services\Publisher\PublisherService;
use App\IATI\Services\Setting\SettingService;
use App\IATI\Services\Validator\ActivityValidatorResponseService;
use App\IATI\Services\Xml\XmlGeneratorService;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Exception\GuzzleException;
Expand All @@ -30,6 +32,11 @@ class ActivityWorkflowService
*/
protected OrganizationService $organizationService;

/**
* @var SettingService
*/
protected SettingService $settingService;

/**
* @var ActivityService
*/
Expand Down Expand Up @@ -75,18 +82,20 @@ class ActivityWorkflowService
/**
* ActivityWorkflowService Constructor.
*
* @param OrganizationService $organizationService
* @param ActivityService $activityService
* @param XmlGeneratorService $xmlGeneratorService
* @param PublisherService $publisherService
* @param ActivityPublishedService $activityPublishedService
* @param ActivitySnapshotService $activitySnapshotService
* @param ActivityValidatorResponseService $validatorService
* @param AuditService $auditService
* @param ApiLogRepository $apiLogRepo
* @param OrganizationService $organizationService
* @param SettingService $settingService
* @param ActivityService $activityService
* @param XmlGeneratorService $xmlGeneratorService
* @param PublisherService $publisherService
* @param ActivityPublishedService $activityPublishedService
* @param ActivitySnapshotService $activitySnapshotService
* @param ActivityValidatorResponseService $validatorService
* @param ApiLogRepository $apiLogRepo
* @param AuditService $auditService
*/
public function __construct(
OrganizationService $organizationService,
SettingService $settingService,
ActivityService $activityService,
XmlGeneratorService $xmlGeneratorService,
PublisherService $publisherService,
Expand All @@ -97,6 +106,7 @@ public function __construct(
AuditService $auditService
) {
$this->organizationService = $organizationService;
$this->settingService = $settingService;
$this->activityService = $activityService;
$this->xmlGeneratorService = $xmlGeneratorService;
$this->publisherService = $publisherService;
Expand Down Expand Up @@ -129,7 +139,7 @@ public function findActivity($activityId): object
*
* @return void
*
* @throws \Exception
* @throws Exception
*/
public function publishActivity($activity, bool $publishFile = true): void
{
Expand All @@ -146,7 +156,7 @@ public function publishActivity($activity, bool $publishFile = true): void
if ($generatedXmlContent) {
$this->xmlGeneratorService->appendCompleteActivityXmlToMergedXml($generatedXmlContent, $settings, $activity, $organization);
} else {
throw new \Exception('Failed appending new activity to merged xml.');
throw new Exception('Failed appending new activity to merged xml.');
}

if ($publishFile) {
Expand Down Expand Up @@ -219,7 +229,7 @@ public function publishActivities($activities, $organization, $settings, bool $p
*
* @return void
*
* @throws \Exception
* @throws Exception
*/
public function unpublishActivity($activity): void
{
Expand Down Expand Up @@ -369,12 +379,13 @@ public function isUserVerified(): bool
/**
* Returns errors related to publishing activity.
*
* @param $organization
* @param $organization
* @param string $type
*
* @return array
*
* @throws \JsonException
* @throws GuzzleException
*/
public function getPublishErrorMessage($organization, string $type = 'activity'): array
{
Expand All @@ -383,8 +394,24 @@ public function getPublishErrorMessage($organization, string $type = 'activity')
if (!$this->isUserVerified()) {
$messages[] = 'You have not verified your email address.';
}
if ($this->hasNoPublisherInfo($organization->settings)) {
if ($this->hasNoPublisherInfo($organization)) {
$messages[] = 'Your API Key is not valid or it is empty.';

try {
$tokenVerificationStatus = $this->settingService->verifyPublisher($organization->toArray());
$tokenVerificationStatus = json_decode(json_encode($tokenVerificationStatus), true);

if ($tokenVerificationStatus['state'] === 'active') {
$publisherInfo = Arr::get($organization, 'settings.publishing_info', []);
$publisherInfo['token_status'] = Arr::get($tokenVerificationStatus, 'state', 'pending');
$publisherInfo['token_verification'] = $publisherInfo['token_status'] === 'active';

$this->settingService->storePublishingInfo($publisherInfo);

array_pop($messages);
}
} catch (Exception $e) {
}
}
if ($type === 'activity' && !$this->isOrganizationPublished($organization)) {
$messages[] = 'Your Organisation data is not published.';
Expand Down
83 changes: 82 additions & 1 deletion public/css/app.css

Large diffs are not rendered by default.

83 changes: 82 additions & 1 deletion public/css/webportal-app.css

Large diffs are not rendered by default.

Loading

0 comments on commit 7ac221e

Please sign in to comment.