Skip to content

Commit

Permalink
Add and improve status colours
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Sep 12, 2024
1 parent f3496e2 commit f791305
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 67 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Release Notes for Campaign

## 3.4.4 - Unreleased
## 3.5.0 - Unreleased

### Added

- Added status colours to the “Status” column in element index pages.

### Changed

- Campaign now requires Craft CMS 5.2.0 or later.
- Improved the status colours of element types.
- Improved the French translation ([#484](https://github.com/putyourlightson/craft-campaign/issues/484)).
- Improved the German translation.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"php": "^8.2",
"ext-dom": "*",
"aws/aws-php-sns-message-validator": "^1.5",
"craftcms/cms": "^5.0",
"craftcms/cms": "^5.2",
"html2text/html2text": "^4.3.1",
"matomo/device-detector": "^3.9.1|^4.0|^5.0|^6.0",
"starkbank/ecdsa": "0.*"
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/CampaignsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function actionCreate(string $campaignTypeHandle): Response
{
$campaignType = Campaign::$plugin->campaignTypes->getCampaignTypeByHandle($campaignTypeHandle);
if (!$campaignType) {
throw new BadRequestHttpException("Invalid campaign type handle: $campaignTypeHandle");
throw new BadRequestHttpException('Invalid campaign type handle: ' . $campaignTypeHandle);
}

$site = Cp::requestedSite();
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/MailingListsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function actionCreate(string $mailingListTypeHandle): Response
{
$mailingListType = Campaign::$plugin->mailingListTypes->getMailingListTypeByHandle($mailingListTypeHandle);
if (!$mailingListType) {
throw new BadRequestHttpException("Invalid mailing list type handle: $mailingListType");
throw new BadRequestHttpException('Invalid mailing list type handle: ' . $mailingListType);
}

$site = Cp::requestedSite();
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/SendoutsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function actionGetPlaintextBody(): Response
public function actionCreate(string $sendoutType = null): Response
{
if (!isset(SendoutElement::sendoutTypes()[$sendoutType])) {
throw new BadRequestHttpException("Invalid sendout type: $sendoutType");
throw new BadRequestHttpException('Invalid sendout type: ' . $sendoutType);
}

$site = Cp::requestedSite();
Expand Down Expand Up @@ -196,7 +196,7 @@ public function actionPreview(int $sendoutId): Response
$sendout = Campaign::$plugin->sendouts->getSendoutById($sendoutId);

if ($sendout === null) {
throw new BadRequestHttpException("Invalid sendout ID: $sendoutId");
throw new BadRequestHttpException('Invalid sendout ID: ' . $sendoutId);
}

$this->view->registerAssetBundle(SendoutPreflightAsset::class);
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/TrackerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function actionClick(): ?Response

// Split the URL on the anchor hashtag, so we can add it at the end.
// https://github.com/putyourlightson/craft-campaign/issues/383
$urlParts = explode("#", $url);
$urlParts = explode('#', $url);
$url = $urlParts[0];
$hashtag = !empty($urlParts[1]) ? '#' . $urlParts[1] : '';

Expand Down
22 changes: 17 additions & 5 deletions src/elements/CampaignElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use craft\elements\actions\Restore;
use craft\elements\Entry;
use craft\elements\User;
use craft\enums\Color;
use craft\helpers\Cp;
use craft\helpers\Html;
use craft\helpers\UrlHelper;
Expand Down Expand Up @@ -152,10 +153,21 @@ public static function hasStatuses(): bool
public static function statuses(): array
{
return [
self::STATUS_SENT => Craft::t('campaign', 'Sent'),
self::STATUS_PENDING => Craft::t('campaign', 'Pending'),
self::STATUS_CLOSED => Craft::t('campaign', 'Closed'),
self::STATUS_DISABLED => Craft::t('app', 'Disabled'),
self::STATUS_SENT => [
'label' => Craft::t('campaign', 'Sent'),
'color' => Color::Teal,
],
self::STATUS_PENDING => [
'label' => Craft::t('campaign', 'Pending'),
'color' => Color::Orange,
],
self::STATUS_CLOSED => [
'label' => Craft::t('campaign', 'Closed'),
'color' => Color::Red,
],
self::STATUS_DISABLED => [
'label' => Craft::t('app', 'Disabled'),
],
];
}

Expand Down Expand Up @@ -765,7 +777,7 @@ public function getPostEditUrl(): ?string
{
$campaignType = $this->getCampaignType();

return UrlHelper::cpUrl("campaign/campaigns/$campaignType->handle");
return UrlHelper::cpUrl('campaign/campaigns/' . $campaignType->handle);
}

/**
Expand Down
21 changes: 17 additions & 4 deletions src/elements/ContactElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\elements\actions\Restore;
use craft\elements\conditions\ElementConditionInterface;
use craft\elements\User;
use craft\enums\Color;
use craft\helpers\ArrayHelper;
use craft\helpers\Cp;
use craft\helpers\Html;
Expand Down Expand Up @@ -175,10 +176,22 @@ public static function hasThumbs(): bool
public static function statuses(): array
{
return [
self::STATUS_ACTIVE => Craft::t('campaign', 'Active'),
self::STATUS_COMPLAINED => Craft::t('campaign', 'Complained'),
self::STATUS_BOUNCED => Craft::t('campaign', 'Bounced'),
self::STATUS_BLOCKED => Craft::t('campaign', 'Blocked'),
self::STATUS_ACTIVE => [
'label' => Craft::t('campaign', 'Active'),
'color' => Color::Teal,
],
self::STATUS_COMPLAINED => [
'label' => Craft::t('campaign', 'Complained'),
'color' => Color::Orange,
],
self::STATUS_BOUNCED => [
'label' => Craft::t('campaign', 'Bounced'),
'color' => Color::Red,
],
self::STATUS_BLOCKED => [
'label' => Craft::t('campaign', 'Blocked'),
'color' => Color::Black,
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/elements/MailingListElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public function getPostEditUrl(): ?string
{
$mailingListType = $this->getMailingListType();

return UrlHelper::cpUrl("campaign/mailinglists/$mailingListType->handle");
return UrlHelper::cpUrl('campaign/mailinglists/' . $mailingListType->handle);
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/elements/SegmentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public static function refHandle(): ?string
return 'segment';
}

/**
* @inheritdoc
*/
public static function hasDrafts(): bool
{
return true;
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -261,7 +269,7 @@ protected function defineRules(): array
*/
public function getPostEditUrl(): ?string
{
return UrlHelper::cpUrl("campaign/segments");
return UrlHelper::cpUrl('campaign/segments');
}

/**
Expand Down
46 changes: 37 additions & 9 deletions src/elements/SendoutElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use craft\elements\actions\Restore;
use craft\elements\User;
use craft\enums\CmsEdition;
use craft\enums\Color;
use craft\helpers\Cp;
use craft\helpers\DateTimeHelper;
use craft\helpers\Json;
Expand Down Expand Up @@ -155,6 +156,14 @@ public static function refHandle(): ?string
return 'sendout';
}

/**
* @inheritdoc
*/
public static function hasDrafts(): bool
{
return true;
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -185,14 +194,33 @@ public static function hasStatuses(): bool
public static function statuses(): array
{
return [
self::STATUS_SENT => Craft::t('campaign', 'Sent'),
self::STATUS_SENDING => Craft::t('campaign', 'Sending'),
self::STATUS_QUEUED => Craft::t('campaign', 'Queued'),
self::STATUS_PENDING => Craft::t('campaign', 'Pending'),
self::STATUS_PAUSED => Craft::t('campaign', 'Paused'),
self::STATUS_CANCELLED => Craft::t('campaign', 'Cancelled'),
self::STATUS_FAILED => Craft::t('campaign', 'Failed'),
self::STATUS_DRAFT => Craft::t('campaign', 'Draft'),
self::STATUS_SENT => [
'label' => Craft::t('campaign', 'Sent'),
'color' => Color::Teal,
],
self::STATUS_SENDING => [
'label' => Craft::t('campaign', 'Sending'),
'color' => Color::Lime,
],
self::STATUS_QUEUED => [
'label' => Craft::t('campaign', 'Queued'),
'color' => Color::Yellow,
],
self::STATUS_PENDING => [
'label' => Craft::t('campaign', 'Pending'),
],
self::STATUS_PAUSED => [
'label' => Craft::t('campaign', 'Paused'),
'color' => Color::Fuchsia,
],
self::STATUS_CANCELLED => [
'label' => Craft::t('campaign', 'Cancelled'),
'color' => Color::Red,
],
self::STATUS_FAILED => [
'label' => Craft::t('campaign', 'Failed'),
'color' => Color::Black,
],
];
}

Expand Down Expand Up @@ -565,7 +593,7 @@ protected function defineRules(): array
*/
public function getPostEditUrl(): ?string
{
return UrlHelper::cpUrl("campaign/sendouts");
return UrlHelper::cpUrl('campaign/sendouts');
}

/**
Expand Down
40 changes: 0 additions & 40 deletions src/resources/css/campaign.css
Original file line number Diff line number Diff line change
Expand Up @@ -173,46 +173,6 @@ table th.thin, table td.thin {
cursor: help;
}

.status.sent {
background-color: var(--enabled-color);
border-color: transparent !important;
}

.status.sending {
background-color: rgb(32, 160, 123, 0.3);
border-color: var(--enabled-color) !important;
}

.status.queued {
background-color: rgb(203, 110, 23, 0.3);
border-color: var(--pending-color) !important;
}

.status.blocked, .status.closed, .status.cancelled, .status.paused {
background-color: var(--disabled-color);
border-color: transparent !important;
}

.status.paused {
background-color: rgb(207, 17, 36, 0.3);
border-color: var(--disabled-color) !important;
}

.status.complained {
background-color: var(--amber-800);
border-color: transparent !important;
}

.status.bounced, .status.failed {
background-color: var(--gray-800);
border-color: transparent !important;
}

.status.draft {
--outline-color: var(--gray-500);
box-shadow: inset 0 0 0 2px var(--outline-color);
}

label.subscriptionStatus {
display: inline-block;
border-radius: 3px;
Expand Down

0 comments on commit f791305

Please sign in to comment.