Skip to content

Commit

Permalink
Merge branch 'craft-4' of https://github.com/verbb/workflow into craft-5
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	composer.json
  • Loading branch information
engram-design committed Nov 28, 2024
2 parents be3a422 + adb64b5 commit 2dc2699
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
- Now requires PHP `8.2.0+`.
- Now requires Craft `5.0.0+`.

## 2.0.13 - 2024-11-28

### Fixed
- Fix when deleting a Craft User that owned a review, would also delete that review.
- Fix an error when approving a submission. (thanks @iainsaxon).

## 2.0.12 - 2024-10-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Workflow extends Plugin
// =========================================================================

public bool $hasCpSettings = true;
public string $schemaVersion = '2.5.0';
public string $schemaVersion = '2.6.0';
public string $minVersionRequired = '1.7.0';


Expand Down
2 changes: 1 addition & 1 deletion src/elements/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function getSupportedSites(): array
return $owner->getSupportedSites();
}

return Craft::$app->getSites()->getAllSites();
return Craft::$app->getSites()->getAllSiteIds();
}

public function setOwner(Entry $owner): void
Expand Down
2 changes: 1 addition & 1 deletion src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function addForeignKeys(): void
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementId', '{{%elements}}', 'id', 'SET NULL', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementSiteId', '{{%sites}}', 'id', 'CASCADE', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'draftId', '{{%drafts}}', 'id', 'SET NULL', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'CASCADE', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'SET NULL', null);
}

public function dropTables(): void
Expand Down
36 changes: 36 additions & 0 deletions src/migrations/m241030_000000_user_fk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace verbb\workflow\migrations;

use craft\db\Migration;
use craft\db\Query;
use craft\helpers\MigrationHelper;

use Throwable;

class m241030_000000_user_fk extends Migration
{
/**
* @inheritdoc
*/
public function safeUp(): bool
{
MigrationHelper::dropAllForeignKeysOnTable('{{%workflow_reviews}}');

$this->addForeignKey(null, '{{%workflow_reviews}}', 'submissionId', '{{%workflow_submissions}}', 'id', 'CASCADE', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementId', '{{%elements}}', 'id', 'SET NULL', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'elementSiteId', '{{%sites}}', 'id', 'CASCADE', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'draftId', '{{%drafts}}', 'id', 'SET NULL', null);
$this->addForeignKey(null, '{{%workflow_reviews}}', 'userId', '{{%users}}', 'id', 'SET NULL', null);

return true;
}

/**
* @inheritdoc
*/
public function safeDown(): bool
{
echo "m241030_000000_user_fk cannot be reverted.\n";
return false;
}
}
2 changes: 1 addition & 1 deletion src/models/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getUserUrl(): ?Markup
return Template::raw($user);
}

return null;
return Template::raw(Craft::t('workflow', '[Deleted User]'));
}

public function getStatusName(): ?string
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_sidebar/_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<div id="{{ anchorKey }}" class="workflow-history-info hidden">
<div class="instructions">
<p>{{ review.userUrl }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>
<p>{{ review.getUserUrl() }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>

{% if review.notes %}
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_sidebar/publisher-pane.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div id="workflow-submission-info" class="hidden">
<div class="instructions">
<p>{{ review.userUrl }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
<p>{{ review.getUserUrl() }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>

{% if review.notes %}
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_sidebar/reviewer-pane.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div id="workflow-submission-info" class="hidden">
<div class="instructions">
<p>{{ review.userUrl }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>
<p>{{ review.getUserUrl() }} {{ 'submitted this entry for review on {date}. Please review this entry before approving' | t('workflow', { date: review.dateCreated | datetime('medium') }) }}</p>

{% if review.notes %}
<p class="code">{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/reviews/_includes/_review.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% set statusText = (review.status == 'pending') ? 'created' | t('workflow') : review.status %}

<div class="workflow-compare-review-heading">
<label class="review-count">{{ review.userUrl }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</label>
<label class="review-count">{{ review.getUserUrl() }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</label>
<label class="review-status-badge {{ review.status }}">{{ statusText }}</label>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/templates/submissions/_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</div>

<div class="workflow-single-review-info">
<p>{{ review.userUrl }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>
<p>{{ review.getUserUrl() }} {{ '{status} this submission on {date}.' | t('workflow', { status: statusText, date: review.dateCreated | datetime('medium') }) }}</p>

{% if review.notes %}
<p>{{ '{role} Notes: “{note}”' | t('workflow', { role: review.roleName, note: review.notes }) | raw }}</p>
Expand Down

0 comments on commit 2dc2699

Please sign in to comment.