Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ insert_final_newline = true
indent_style = space
indent_size = 2

[*.php]
[*.{php,xml}]
indent_size = 4

[*.{diff,md}]
[*.md]
trim_trailing_whitespace = false

[Jenkinsfile]
indent_size = 4
25 changes: 20 additions & 5 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Requests
on:
pull_request:
branches:
- main
- master

jobs:
runner:
Expand All @@ -13,15 +13,30 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4

# Can maybe be replaced with pnpm/action-setup@v4 in the future
- name: Setup pnpm/corepack
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- run: npm i -g --force corepack && corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Setup PHP with tools
uses: silverorange/actions-setup-php@v2
with:
php-version: "8.2"
extensions: gd
php-version: '8.2'

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache dependencies
uses: actions/cache@v4
Expand All @@ -31,7 +46,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install PHP dependencies
run: "composer install"
run: 'composer install'

- name: Run tests
timeout-minutes: 5
Expand Down
24 changes: 13 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
vendor/
node_modules/
/vendor/
/node_modules/

# misc
.DS_Store
.env
.idea/
.php-cs-fixer.cache
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.idea/
pnpm-debug.log*
pnpm-error.log*
*.swp

# dependency lock file
composer.lock
# testing/tooling output
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
/build/

# overrides for local tooling
/phpstan.neon
/phpstan-baseline.neon
phpstan.neon
phpstan-baseline.neon
phpunit.xml
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

$finder = (new Finder())
->in(__DIR__)
->name(['*.php', '*.inc']);
->append([__FILE__]);

return (new Config())
->setParallelConfig(ParallelConfigFactory::detect(null, null, 2 ** 18 - 1))
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/composer.lock
/pnpm-lock.yaml

# SVG files will be optimized/prettified with other tools
**/*.svg
39 changes: 11 additions & 28 deletions Admin/AdminSearchClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,33 +142,16 @@ private static function getOperatorString($operator)
{
$operator = intval($operator);

switch ($operator) {
case self::OP_EQUALS:
return '=';

case self::OP_GT:
return '>';

case self::OP_GTE:
return '>=';

case self::OP_LT:
return '<';

case self::OP_LTE:
return '<=';

case self::OP_CONTAINS:
return 'like';

case self::OP_STARTS_WITH:
return 'like';

case self::OP_ENDS_WITH:
return 'like';

default:
throw new AdminException('Unknown operator in clause: ' . $operator);
}
return match ($operator) {
self::OP_EQUALS => '=',
self::OP_GT => '>',
self::OP_GTE => '>=',
self::OP_LT => '<',
self::OP_LTE => '<=',
self::OP_CONTAINS => 'like',
self::OP_STARTS_WITH => 'like',
self::OP_ENDS_WITH => 'like',
default => throw new AdminException('Unknown operator in clause: ' . $operator),
};
}
}
39 changes: 11 additions & 28 deletions Admin/AdminSearchOperatorFlydown.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,16 @@ public function display()

private static function getOperatorTitle($id)
{
switch ($id) {
case AdminSearchClause::OP_EQUALS:
return Admin::_('is');

case AdminSearchClause::OP_GT:
return '>';

case AdminSearchClause::OP_GTE:
return '>=';

case AdminSearchClause::OP_LT:
return '<';

case AdminSearchClause::OP_LTE:
return '<=';

case AdminSearchClause::OP_CONTAINS:
return Admin::_('contains');

case AdminSearchClause::OP_STARTS_WITH:
return Admin::_('starts with');

case AdminSearchClause::OP_ENDS_WITH:
return Admin::_('ends with');

default:
throw new Exception('AdminSearchOperatorFlydown: unknown operator');
}
return match ($id) {
AdminSearchClause::OP_EQUALS => Admin::_('is'),
AdminSearchClause::OP_GT => '>',
AdminSearchClause::OP_GTE => '>=',
AdminSearchClause::OP_LT => '<',
AdminSearchClause::OP_LTE => '<=',
AdminSearchClause::OP_CONTAINS => Admin::_('contains'),
AdminSearchClause::OP_STARTS_WITH => Admin::_('starts with'),
AdminSearchClause::OP_ENDS_WITH => Admin::_('ends with'),
default => throw new Exception('AdminSearchOperatorFlydown: unknown operator'),
};
}
}
60 changes: 16 additions & 44 deletions Admin/AdminTitleLinkCellRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,50 +77,22 @@ public function setFromStock($stock_id, $overwrite_properties = true)

$class = null;

switch ($stock_id) {
case 'document':
$class = 'admin-title-link-cell-renderer-document';
break;

case 'document-with-contents':
$class = 'admin-title-link-cell-renderer-document-with-contents';
break;

case 'edit':
$class = 'admin-title-link-cell-renderer-edit';
break;

case 'file-save-as':
$class = 'admin-title-link-cell-renderer-file-save-as';
break;

case 'folder-with-contents':
$class = 'admin-title-link-cell-renderer-folder-with-contents';
break;

case 'folder':
$class = 'admin-title-link-cell-renderer-folder';
break;

case 'person':
$class = 'admin-title-link-cell-renderer-person';
break;

case 'product':
$class = 'admin-title-link-cell-renderer-product';
break;

case 'download':
$class = 'admin-title-link-cell-renderer-download';
break;

default:
throw new SwatUndefinedStockTypeException(
"Stock type with id of '{$stock_id}' not found.",
0,
$stock_id
);
}
$class = match ($stock_id) {
'document' => 'admin-title-link-cell-renderer-document',
'document-with-contents' => 'admin-title-link-cell-renderer-document-with-contents',
'edit' => 'admin-title-link-cell-renderer-edit',
'file-save-as' => 'admin-title-link-cell-renderer-file-save-as',
'folder-with-contents' => 'admin-title-link-cell-renderer-folder-with-contents',
'folder' => 'admin-title-link-cell-renderer-folder',
'person' => 'admin-title-link-cell-renderer-person',
'product' => 'admin-title-link-cell-renderer-product',
'download' => 'admin-title-link-cell-renderer-download',
default => throw new SwatUndefinedStockTypeException(
"Stock type with id of '{$stock_id}' not found.",
0,
$stock_id
),
};

$this->stock_class = $class;
$this->last_stock_id = $stock_id;
Expand Down
Loading
Loading