Skip to content

Commit

Permalink
PS-683 share (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem authored Oct 16, 2024
1 parent 2e07842 commit 592097c
Show file tree
Hide file tree
Showing 140 changed files with 2,568 additions and 374 deletions.
16 changes: 10 additions & 6 deletions dashboard/client/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ export default function Dashboard({}: Props) {
]}
/>
)}
{isInIframe ? <Service
mainUrl={`/`}
title={`Dashboard`}
description={`Phrasea entrypoint`}
logo={notifyImg}
/> : ''}
{isInIframe ? (
<Service
mainUrl={`/`}
title={`Dashboard`}
description={`Phrasea entrypoint`}
logo={notifyImg}
/>
) : (
''
)}
</Grid>
{roles.includes('tech') && (
<Grid container spacing={2} marginTop={1}>
Expand Down
8 changes: 4 additions & 4 deletions databox/api/fixtures/Newspaper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ App\Entity\Core\Asset:
workspace: '@w_newspaper'
privacy: '<numberBetween(1, 5)>'
__calls:
- addToCollection: ['@c_n_*']
- addToCollection: ['@c_n_*', true, true]
- addTag (80%?): ['@tag_*']
- addTag (50%?): ['@tag_*']
- addToCollection (80%?): ['@c_n_sport', true]
- addToCollection (80%?): ['@c_n_entertainment_archives_movies', true]
- addToCollection (80%?): ['@c_n_entertainment_archives_series', true]
- addToCollection (80%?): ['@c_n_sport', true, true]
- addToCollection (80%?): ['@c_n_entertainment_archives_movies', true, true]
- addToCollection (80%?): ['@c_n_entertainment_archives_series', true, true]

a_img{1..50} (extends asset_n):
title: 'Image #<ucwords($current)>'
Expand Down
12 changes: 6 additions & 6 deletions databox/api/fixtures/Permissions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,37 @@ App\Entity\Core\Asset:
title: 'Image in <ucwords($current)>'
source: '@f_img_o1'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

a_{a2} (extends asset_p):
title: 'Image in <ucwords($current)>'
source: '@f_img_o2'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

a_{b} (extends asset_p):
title: 'Image in <ucwords($current)>'
source: '@f_img_o3'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

a_{c} (extends asset_p):
title: 'Image in <ucwords($current)>'
source: '@f_img_o4'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

a_{c2} (extends asset_p):
title: 'Image in <ucwords($current)>'
source: '@f_img_o5'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

a_{d} (extends asset_p):
title: 'Image in <ucwords($current)>'
source: '@f_img_o6'
__calls:
- addToCollection: ['@c_<current()>']
- addToCollection: ['@c_<current()>', true, true]

App\Entity\Core\File:
file_p (template):
Expand Down
40 changes: 40 additions & 0 deletions databox/api/migrations/Version20241008092528.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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 Version20241008092528 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('CREATE TABLE share (id UUID NOT NULL, asset_id UUID NOT NULL, starts_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, expires_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, token VARCHAR(255) NOT NULL, config JSON NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, owner_id VARCHAR(36) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_EF069D5A5DA1941 ON share (asset_id)');
$this->addSql('COMMENT ON COLUMN share.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN share.asset_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN share.starts_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN share.expires_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN share.created_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN share.updated_at IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE share ADD CONSTRAINT FK_EF069D5A5DA1941 FOREIGN KEY (asset_id) REFERENCES asset (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE share DROP CONSTRAINT FK_EF069D5A5DA1941');
$this->addSql('DROP TABLE share');
}
}
33 changes: 33 additions & 0 deletions databox/api/migrations/Version20241008094404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 Version20241008094404 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 share ALTER starts_at DROP NOT NULL');
$this->addSql('ALTER TABLE share ALTER expires_at DROP NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE share ALTER starts_at SET NOT NULL');
$this->addSql('ALTER TABLE share ALTER expires_at SET NOT NULL');
}
}
31 changes: 31 additions & 0 deletions databox/api/migrations/Version20241008110554.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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 Version20241008110554 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 share ALTER token TYPE VARCHAR(64)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE share ALTER token TYPE VARCHAR(255)');
}
}
35 changes: 35 additions & 0 deletions databox/api/migrations/Version20241009104832.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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 Version20241009104832 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 share ADD title VARCHAR(255) DEFAULT NULL');
$this->addSql('DELETE FROM share');
$this->addSql('ALTER TABLE share ADD enabled BOOLEAN 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 share DROP title');
$this->addSql('ALTER TABLE share DROP enabled');
}
}
33 changes: 33 additions & 0 deletions databox/api/migrations/Version20241009133041.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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 Version20241009133041 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 share DROP CONSTRAINT FK_EF069D5A5DA1941');
$this->addSql('ALTER TABLE share ADD CONSTRAINT FK_EF069D5A5DA1941 FOREIGN KEY (asset_id) REFERENCES asset (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE share DROP CONSTRAINT fk_ef069d5a5da1941');
$this->addSql('ALTER TABLE share ADD CONSTRAINT fk_ef069d5a5da1941 FOREIGN KEY (asset_id) REFERENCES asset (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}
25 changes: 17 additions & 8 deletions databox/api/src/Api/Model/Output/AssetOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Entity\Core\Asset;
use App\Entity\Core\AssetRendition;
use App\Entity\Core\File;
use App\Entity\Core\Share;
use Symfony\Component\Serializer\Annotation\Groups;

class AssetOutput extends AbstractUuidOutput
Expand All @@ -35,13 +36,21 @@ class AssetOutput extends AbstractUuidOutput
/**
* @var AttributeOutput[]
*/
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
protected ?array $attributes = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, WebhookSerializationInterface::DEFAULT_GROUP])]
#[Groups([Asset::GROUP_LIST,
Asset::GROUP_READ,
WebhookSerializationInterface::DEFAULT_GROUP,
Share::GROUP_PUBLIC_READ])]
private ?string $title = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, WebhookSerializationInterface::DEFAULT_GROUP])]
#[Groups([Asset::GROUP_LIST,
Asset::GROUP_READ,
WebhookSerializationInterface::DEFAULT_GROUP,
Share::GROUP_READ,
Share::GROUP_PUBLIC_READ,
])]
private ?string $resolvedTitle = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
Expand Down Expand Up @@ -71,19 +80,19 @@ class AssetOutput extends AbstractUuidOutput
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
private array $collections;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
private ?File $source = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
private ?AssetRendition $original = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
private ?AssetRendition $preview = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
private ?AssetRendition $thumbnail = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
private ?AssetRendition $thumbnailActive = null;

#[Groups(['dates'])]
Expand Down
5 changes: 3 additions & 2 deletions databox/api/src/Api/Model/Output/AssetRenditionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Api\Model\Output\Traits\UpdatedAtDTOTrait;
use App\Entity\Core\Asset;
use App\Entity\Core\AssetRendition;
use App\Entity\Core\Share;
use Symfony\Component\Serializer\Attribute\Groups;

class AssetRenditionOutput extends AbstractUuidOutput
Expand All @@ -21,10 +22,10 @@ class AssetRenditionOutput extends AbstractUuidOutput
#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ])]
public $definition;

#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ, Asset::GROUP_LIST, Asset::GROUP_READ])]
#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ, Asset::GROUP_LIST, Asset::GROUP_READ, Share::GROUP_PUBLIC_READ])]
public $file;

#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ])]
#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ, Share::GROUP_PUBLIC_READ])]
public ?string $name = null;

#[Groups([AssetRendition::GROUP_LIST, AssetRendition::GROUP_READ])]
Expand Down
11 changes: 6 additions & 5 deletions databox/api/src/Api/Model/Output/AttributeDefinitionOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Entity\Core\Attribute;
use App\Entity\Core\AttributeClass;
use App\Entity\Core\AttributeDefinition;
use App\Entity\Core\Share;
use App\Entity\Core\Workspace;
use Symfony\Component\Serializer\Annotation\Groups;

Expand All @@ -27,7 +28,7 @@ class AttributeDefinitionOutput extends AbstractUuidOutput
#[ApiProperty(security: "is_granted('READ_ADMIN', object)")]
public ?AttributeClass $class = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, AttributeDefinition::GROUP_LIST, Attribute::GROUP_LIST])]
#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, AttributeDefinition::GROUP_LIST, Attribute::GROUP_LIST, Share::GROUP_PUBLIC_READ])]
public ?string $name = null;

#[Groups([Asset::GROUP_LIST, Asset::GROUP_READ, AttributeDefinition::GROUP_LIST, Attribute::GROUP_LIST])]
Expand All @@ -36,7 +37,7 @@ class AttributeDefinitionOutput extends AbstractUuidOutput
#[Groups([AttributeDefinition::GROUP_LIST])]
public ?string $fileType = null;

#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST])]
#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST, Share::GROUP_PUBLIC_READ])]
public string $fieldType = TextAttributeType::NAME;

#[Groups([AttributeDefinition::GROUP_LIST])]
Expand All @@ -51,10 +52,10 @@ class AttributeDefinitionOutput extends AbstractUuidOutput
#[Groups([AttributeDefinition::GROUP_LIST])]
public bool $facetEnabled = false;

#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST])]
#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST, Share::GROUP_PUBLIC_READ])]
public bool $translatable = false;

#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST])]
#[Groups([AttributeDefinition::GROUP_LIST, Asset::GROUP_LIST, Share::GROUP_PUBLIC_READ])]
public bool $multiple = false;

#[Groups([AttributeDefinition::GROUP_LIST])]
Expand Down Expand Up @@ -89,7 +90,7 @@ class AttributeDefinitionOutput extends AbstractUuidOutput
#[Groups([AttributeDefinition::GROUP_LIST])]
public ?bool $canEdit = null;

#[Groups([AttributeDefinition::GROUP_LIST])]
#[Groups([AttributeDefinition::GROUP_LIST, Share::GROUP_PUBLIC_READ])]
public function getLocales(): ?array
{
if ($this->translatable) {
Expand Down
Loading

0 comments on commit 592097c

Please sign in to comment.