Skip to content

Commit

Permalink
uploader - make target url nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Jan 2, 2024
1 parent 879f0f6 commit 037251b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion expose/client/src/lib/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const keycloakClient = new KeycloakClient({

export const oauthClient = keycloakClient.client;

const apiClient = createHttpClient(window.config.baseUrl);
const apiClient = createHttpClient(config.baseUrl);

configureClientAuthentication(apiClient, oauthClient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function handle(EventMessage $message): void

$target = $commit->getTarget();
$accessToken = $target->getTargetAccessToken();
if ('avoid' === $accessToken) {
if (empty($target->getTargetUrl()) || 'avoid' === $accessToken) {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions uploader/api/src/Controller/Admin/TargetCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ public function configureCrud(Crud $crud): Crud

public function configureFields(string $pageName): iterable
{
$slug = TextField::new('slug');
$name = TextField::new('name');
$slug = TextField::new('slug');
$description = TextareaField::new('description');
$targetUrl = TextField::new('targetUrl')
->setHelp('i.e: "https://phraseanet.phrasea.local/api/v1/upload/enqueue/" for Phraseanet, "http://databox-api/incoming-uploads" for Databox upload');
->setHelp('Leave empty for pull mode. i.e: "https://phraseanet.phrasea.local/api/v1/upload/enqueue/" for Phraseanet, "http://databox-api/incoming-uploads" for Databox upload');
$targetTokenType = TextField::new('targetTokenType')
->setHelp('Use "OAuth" for Phraseanet')
->setFormTypeOptions(['attr' => ['placeholder' => 'Defaults to "Bearer"']]);
$targetAccessToken = TextField::new('targetAccessToken')
->setHelp('use "avoid" to do not notify target (for pull mode)');
$targetAccessToken = TextField::new('targetAccessToken');
$defaultDestination = TextField::new('defaultDestination')
->setHelp('i.e: "42" (for Phraseanet collection), "cdc3679f-3f37-4260-8de7-b649ecc8c1cc" (for Databox collection)');
$allowedGroups = GroupChoiceField::new('allowedGroups');
Expand Down
3 changes: 1 addition & 2 deletions uploader/api/src/Entity/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ class Target extends AbstractUuidEntity implements \Stringable
#[Groups(['target:index'])]
private ?string $description = null;

#[ORM\Column(type: Types::STRING, length: 255)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
#[Assert\Length(max: 255)]
#[Assert\Url]
#[Assert\NotBlank]
#[Groups(['target:write'])]
private ?string $targetUrl = null;

Expand Down
32 changes: 32 additions & 0 deletions uploader/api/src/Migrations/Version20240102092204.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240102092204 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE target ALTER target_url DROP NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE target ALTER target_url SET NOT NULL');
}
}

0 comments on commit 037251b

Please sign in to comment.