From 05fcf49ec1f6b670ba172b0333b5fbdac4786942 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:39:55 +1200 Subject: [PATCH 1/3] MNT Fix scss lint warnings (#199) --- .stylelintignore | 1 - client/src/bundles/bundle.scss | 4 ++-- package.json | 4 ++-- yarn.lock | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .stylelintignore diff --git a/.stylelintignore b/.stylelintignore deleted file mode 100644 index 8688292..0000000 --- a/.stylelintignore +++ /dev/null @@ -1 +0,0 @@ -client/src/**/*.js diff --git a/client/src/bundles/bundle.scss b/client/src/bundles/bundle.scss index dea47a2..7c948be 100755 --- a/client/src/bundles/bundle.scss +++ b/client/src/bundles/bundle.scss @@ -2,8 +2,8 @@ @import "variables"; // Import all of your SCSS stylesheets using relative paths from "components" -@import "../components/LoginSession/LoginSession.scss"; -@import "../components/SessionManagerField/SessionManagerField.scss"; +@import "../components/LoginSession/LoginSession"; +@import "../components/SessionManagerField/SessionManagerField"; // Import any legacy SCSS stylesheets // e.g. @import '../styles/MyComponent-ModelAdmin-legacy.scss diff --git a/package.json b/package.json index 70e20ad..5f90fe7 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "css": "WEBPACK_CHILD=css npm run build", "test": "jest", "coverage": "jest --coverage", - "lint": "eslint client/src && yarn lint-sass", + "lint": "yarn lint-js && yarn lint-sass", "lint-js": "eslint client/src", "lint-js-fix": "eslint client/src --fix", "lint-sass": "stylelint client/src" @@ -32,7 +32,7 @@ }, "devDependencies": { "@babel/runtime": "^7.20.1", - "@silverstripe/eslint-config": "^1.2.1", + "@silverstripe/eslint-config": "^1.3.0", "@silverstripe/webpack-config": "^2.1.0", "@testing-library/react": "^14.0.0", "babel-jest": "^29.3.0", diff --git a/yarn.lock b/yarn.lock index f53dad5..9d947e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1574,10 +1574,10 @@ resolved "https://registry.yarnpkg.com/@sect/modernizr-loader/-/modernizr-loader-1.0.5.tgz#512afc60c715cd658fdffab244123661e1339083" integrity sha512-L8y2BTVeLtdSe1XzBcD2DOlc+7fR7Z/uNdhsKvf3d3x3gmEKz9sfl2wJ3VzFhEd+a/O6qgacuhbziphG2p4s8g== -"@silverstripe/eslint-config@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@silverstripe/eslint-config/-/eslint-config-1.2.1.tgz#17ed5e955308a4a89e87f5090df66ca1e8ea462d" - integrity sha512-T4Lz1aZEDLxRpSNe4EgEmLKPfofxba0p0+YkL/AOD8VM/sng7VM9vKwMoqICbsUGvNoymHfeWtARlCa575O4PA== +"@silverstripe/eslint-config@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@silverstripe/eslint-config/-/eslint-config-1.3.0.tgz#fa88f47cacd6103f6b759d81e1d86f9e93799413" + integrity sha512-Q3+sQKO1ysyMLhJ91kOl2LqJhQICfHFeqMx09EH0xx3dRHgjsQvqHIzVWEzPkM/l7D79m+Ma/WBnon30S7TVlA== dependencies: eslint "^8.26.0" eslint-config-airbnb "^19.0.4" From 75524242cbc7d54bc342772a1251773a75542f0c Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 14 Jun 2024 21:48:37 +1200 Subject: [PATCH 2/3] ENH Use class name instead of self --- src/FormFields/SessionManagerField.php | 2 +- src/Jobs/GarbageCollectionJob.php | 4 ++-- src/Models/LoginSession.php | 2 +- src/Services/GarbageCollectionService.php | 2 +- tests/php/Extensions/ForcePermission.php | 16 ++++++++-------- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/FormFields/SessionManagerField.php b/src/FormFields/SessionManagerField.php index be48bd7..f45eb60 100644 --- a/src/FormFields/SessionManagerField.php +++ b/src/FormFields/SessionManagerField.php @@ -89,7 +89,7 @@ public function setTitleLinkHref(string $titleLinkHref) public function Field($properties = array()) { - return $this->renderWith(self::class); + return $this->renderWith(SessionManagerField::class); } /** diff --git a/src/Jobs/GarbageCollectionJob.php b/src/Jobs/GarbageCollectionJob.php index 130aa56..49526e9 100644 --- a/src/Jobs/GarbageCollectionJob.php +++ b/src/Jobs/GarbageCollectionJob.php @@ -61,9 +61,9 @@ public function requireDefaultJob(): void private function queueNextJob(): void { - $timestamp = time() + self::config()->get('seconds_between_jobs'); + $timestamp = time() + static::config()->get('seconds_between_jobs'); QueuedJobService::singleton()->queueJob( - Injector::inst()->create(self::class), + Injector::inst()->create(GarbageCollectionJob::class), DBDatetime::create()->setValue($timestamp)->Rfc2822() ); } diff --git a/src/Models/LoginSession.php b/src/Models/LoginSession.php index 3900823..39038d5 100644 --- a/src/Models/LoginSession.php +++ b/src/Models/LoginSession.php @@ -256,7 +256,7 @@ public function getFriendlyUserAgent(): string * @param HTTPRequest|null $request * @return LoginSession|null */ - public static function getCurrentLoginSession(?HTTPRequest $request = null): ?self + public static function getCurrentLoginSession(?HTTPRequest $request = null): ?LoginSession { // Fall back to retrieving request from current Controller if available if ($request === null) { diff --git a/src/Services/GarbageCollectionService.php b/src/Services/GarbageCollectionService.php index 53c7d1e..8a3ea30 100644 --- a/src/Services/GarbageCollectionService.php +++ b/src/Services/GarbageCollectionService.php @@ -31,7 +31,7 @@ public function collect(): void private function batchRemoveAll($datalist) { - $limit = self::config()->get('batch_remove_limit'); + $limit = static::config()->get('batch_remove_limit'); $limitedList = $datalist->limit($limit); DB::get_conn()->transactionStart(); foreach ($limitedList as $record) { diff --git a/tests/php/Extensions/ForcePermission.php b/tests/php/Extensions/ForcePermission.php index 13a4e07..01e6cdf 100644 --- a/tests/php/Extensions/ForcePermission.php +++ b/tests/php/Extensions/ForcePermission.php @@ -16,31 +16,31 @@ class ForcePermission extends DataExtension implements TestOnly public static function forceCanView($val) { - self::$canView = $val; + ForcePermission::$canView = $val; } public static function forceCanDelete($val) { - self::$canDelete = $val; + ForcePermission::$canDelete = $val; } public static function reset() { - self::$canView = null; - self::$canDelete = null; + ForcePermission::$canView = null; + ForcePermission::$canDelete = null; } public function canView($member) { - if (self::$canView !== null) { - return self::$canView; + if (ForcePermission::$canView !== null) { + return ForcePermission::$canView; } } public function canDelete($member) { - if (self::$canDelete !== null) { - return self::$canDelete; + if (ForcePermission::$canDelete !== null) { + return ForcePermission::$canDelete; } } } From 9b688bf2287ca4280e7342749f9f82a2177676df Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 20 Jun 2024 12:19:56 +1200 Subject: [PATCH 3/3] MNT Run module-standardiser (#203) --- .github/workflows/add-prs-to-project.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/add-prs-to-project.yml diff --git a/.github/workflows/add-prs-to-project.yml b/.github/workflows/add-prs-to-project.yml new file mode 100644 index 0000000..2d3f41a --- /dev/null +++ b/.github/workflows/add-prs-to-project.yml @@ -0,0 +1,22 @@ +name: Add new PRs to github project + +on: + pull_request_target: + types: + - opened + - ready_for_review + +permissions: {} + +jobs: + addprtoproject: + name: Add PR to GitHub Project + # Only run on the silverstripe account + if: github.repository_owner == 'silverstripe' + runs-on: ubuntu-latest + steps: + - name: Add PR to github project + uses: silverstripe/gha-add-pr-to-project@v1 + with: + app_id: ${{ vars.PROJECT_PERMISSIONS_APP_ID }} + private_key: ${{ secrets.PROJECT_PERMISSIONS_APP_PRIVATE_KEY }}