Skip to content

Commit

Permalink
Merge pull request #156 from lilt/4.x-fix-translation-link
Browse files Browse the repository at this point in the history
Fix translation link
  • Loading branch information
hadomskyi authored Aug 17, 2024
2 parents 7e3e6a0 + 8f7a134 commit 9f4c845
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
"cypress/e2e/jobs/verified/success-path-single.cy.js",
"cypress/e2e/jobs/instant/success-path-single.cy.js",
]
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set the value
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ unit: codecept-build
test: functional integration unit

prepare-container:
PHP_VERSION=8.0 docker compose up -d
docker compose up -d
docker compose exec -T -u root cli-app sh -c "chown -R www-data:www-data /craft-lilt-plugin"
docker compose exec -T -u root cli-app sh -c "apk --no-cache add bash make git"
docker compose exec -T -u www-data cli-app sh -c "cp tests/.env.test tests/.env"
Expand Down
66 changes: 33 additions & 33 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ composer-install:
composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9"

reset: cp composer-install
docker-compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'
docker compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'


install: clone
Expand All @@ -28,23 +28,23 @@ install: clone
composer require craftcms/cms:3.7.68 -W

backup-db:
docker-compose exec -T app sh -c 'php craft db/backup'
docker compose exec -T app sh -c 'php craft db/backup'

refresh:
docker-compose exec -T app sh -c 'rm -rf /app/vendor/lilt/craft-lilt-plugin'
docker-compose exec -T app sh -c 'composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9"'
docker compose exec -T app sh -c 'rm -rf /app/vendor/lilt/craft-lilt-plugin'
docker compose exec -T app sh -c 'composer require --ignore-platform-reqs "lilt/craft-lilt-plugin":"^999.9.9"'

build:
docker build -f happy-lager-main/Dockerfile happy-lager-main -t happy-lager

down:
docker-compose down --remove-orphans -v
docker compose down --remove-orphans -v

mup: #migrate app up
docker-compose exec -T app sh -c 'php craft migrate/up'
docker compose exec -T app sh -c 'php craft migrate/up'

mdown: #migrate app down
docker-compose exec -T app sh -c 'php craft migrate/down'
docker compose exec -T app sh -c 'php craft migrate/down'

cp:
rm -rf happy-lager-main/plugin-src
Expand Down Expand Up @@ -84,32 +84,32 @@ wait-service:
@echo "Service is up and running or max retries reached!"

up: clone down composer-install
docker-compose up --build -d
docker-compose ps
docker-compose exec -T app sh -c 'chmod -R 777 /app'
docker-compose exec -T app sh -c 'chown -R www-data:www-data /app'
docker-compose exec -T mysql sh -c 'while ! mysqladmin ping -h"mysql" --silent; do sleep 1; done'
docker-compose exec -T app sh -c 'php craft setup/security-key'
docker-compose exec -T app sh -c 'echo DB_DRIVER=mysql >> .env'
docker-compose exec -T app sh -c 'echo DB_SERVER=mysql >> .env'
docker-compose exec -T app sh -c 'echo DB_DATABASE=${DB_DATABASE} >> .env'
docker-compose exec -T app sh -c 'echo DB_USER=craft-lilt >> .env'
docker-compose exec -T app sh -c 'echo DB_PASSWORD=craft-lilt >> .env'
docker-compose exec -T app sh -c 'echo DB_SCHEMA=public >> .env'
docker-compose exec -T app sh -c 'echo DB_TABLE_PREFIX= >> .env'
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=1 >> .env'
docker-compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_MANAGER_WAIT_TIME_IN_SECONDS=86400 >> .env'
docker-compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker-compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'
docker-compose exec -T app sh -c 'php craft plugin/install neo'
docker-compose exec -T app sh -c 'php craft plugin/install super-table'
docker-compose exec -T app sh -c 'php craft project-config/rebuild'
docker-compose exec -T app sh -c 'php craft up'
docker-compose exec -T app sh -c 'php craft migrate/up'
docker-compose exec -T app sh -c 'nohup ./queue_listen.sh > queue.log 2>&1 &'
docker-compose exec -T app sh -c 'cat .env'
docker compose up --build -d
docker compose ps
docker compose exec -T app sh -c 'chmod -R 777 /app'
docker compose exec -T app sh -c 'chown -R www-data:www-data /app'
docker compose exec -T mysql sh -c 'while ! mysqladmin ping -h"mysql" --silent; do sleep 1; done'
docker compose exec -T app sh -c 'php craft setup/security-key'
docker compose exec -T app sh -c 'echo DB_DRIVER=mysql >> .env'
docker compose exec -T app sh -c 'echo DB_SERVER=mysql >> .env'
docker compose exec -T app sh -c 'echo DB_DATABASE=${DB_DATABASE} >> .env'
docker compose exec -T app sh -c 'echo DB_USER=craft-lilt >> .env'
docker compose exec -T app sh -c 'echo DB_PASSWORD=craft-lilt >> .env'
docker compose exec -T app sh -c 'echo DB_SCHEMA=public >> .env'
docker compose exec -T app sh -c 'echo DB_TABLE_PREFIX= >> .env'
docker compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_DELAY_IN_SECONDS=1 >> .env'
docker compose exec -T app sh -c 'echo CRAFT_LILT_PLUGIN_QUEUE_MANAGER_WAIT_TIME_IN_SECONDS=86400 >> .env'
docker compose exec -T app sh -c 'php craft db/restore happylager.sql'
docker compose exec -T app sh -c 'php craft plugin/install craft-lilt-plugin'
docker compose exec -T app sh -c 'php craft plugin/install neo'
docker compose exec -T app sh -c 'php craft plugin/install super-table'
docker compose exec -T app sh -c 'php craft project-config/rebuild'
docker compose exec -T app sh -c 'php craft up'
docker compose exec -T app sh -c 'php craft migrate/up'
docker compose exec -T app sh -c 'nohup ./queue_listen.sh > queue.log 2>&1 &'
docker compose exec -T app sh -c 'cat .env'
cli:
docker-compose exec app sh
docker compose exec app sh

test:
docker run -u root -t -v ${PWD}:/e2e -w /e2e --env CYPRESS_CACHE_FOLDER=${CYPRESS_CACHE_FOLDER} node:18.12.1 npm install
Expand Down
11 changes: 11 additions & 0 deletions src/elements/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use lilthq\craftliltplugin\elements\actions\JobEdit;
use lilthq\craftliltplugin\elements\db\TranslationQuery;
use lilthq\craftliltplugin\models\TranslationModelTrait;
use craft\elements\User;
use lilthq\craftliltplugin\records\TranslationNotificationsRecord;
use lilthq\craftliltplugin\records\TranslationRecord;

Expand Down Expand Up @@ -128,6 +129,16 @@ public function getIsReviewed(): bool
return $this->getIsPublished() || $this->status === TranslationRecord::STATUS_READY_TO_PUBLISH;
}

public function getUrl(): ?string
{
return $this->getCpEditUrl();
}

public function canView(User $user): bool
{
return true;
}

public function getStatusHtml(): string
{
$label = self::statuses()[$this->status]['label'] ?? self::statuses()[$this->status];
Expand Down
5 changes: 2 additions & 3 deletions tests/_craft/migrations/m220617_164156_add_sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function safeUp()
}

$siteEnUS->name = 'Craft test';
$siteEnUS->setBaseUrl('$PRIMARY_SITE_URL');

$siteEnUS->setBaseUrl('http://test.craftcms.test:80');
Craft::$app->sites->saveSite($siteEnUS);

$siteSetting = new Section_SiteSettings();
Expand All @@ -61,6 +60,7 @@ public function safeUp()
$site->setName(
sprintf('Craft test %s', explode('-', $language)[0])
);

$site->groupId = $groups[0]->id;
$site->setBaseUrl('@web/' . explode('-', $language)[0]);

Expand All @@ -72,7 +72,6 @@ public function safeUp()
$siteSetting->siteId = $site->id;
$siteSetting->enabledByDefault = true;

#$siteSetting->uriFormat = sprintf('/blog/%s', explode('-',$language)[0]);
$siteSetting->uriFormat = sprintf('/blog/%s/{slug}', explode('-', $language)[0]);
$siteSetting->hasUrls = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ private function getExpected(): array
'crumbs' => [
0 => [
'label' => 'Lilt Plugin',
'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin&site=default',
'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin&site=default',
],
1 => [
'label' => 'Jobs',
'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default',
'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default',
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ private function getExpected(Job $job): array
'crumbs' => [
0 => [
'label' => 'Lilt Plugin',
'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin&site=default',
'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin&site=default',
],
1 => [
'label' => 'Jobs',
'url' => 'http://$PRIMARY_SITE_URL/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default',
'url' => 'http://test.craftcms.test:80/index.php?p=admin/admin/craft-lilt-plugin/jobs&site=default',
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function testSuccess(IntegrationTester $I): void

if (method_exists(Assert::class, 'assertMatchesRegularExpression')) {
Assert::assertMatchesRegularExpression(
"/^http:\/\/\\\$PRIMARY_SITE_URL\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/",
"/^http:\/\/test\.craftcms\.test:80\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/",
$actual['variables']['originalUrl']
);
Assert::assertMatchesRegularExpression(
Expand All @@ -128,7 +128,7 @@ public function testSuccess(IntegrationTester $I): void
);
} else {
Assert::assertRegExp(
"/^http:\/\/\\\$PRIMARY_SITE_URL\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/",
"/^http:\/\/test\.craftcms\.test:80\/index\.php\?p=blog\/first-entry-user-1&token=[0-9a-zA-Z\S]+$/",
$actual['variables']['originalUrl']
);
Assert::assertRegExp(
Expand Down

0 comments on commit 9f4c845

Please sign in to comment.