Skip to content

Commit b2bccc7

Browse files
Removed the custom course resource controller (#965)
Co-authored-by: Adrian Marin <[email protected]>
1 parent c52bb67 commit b2bccc7

File tree

9 files changed

+19
-3
lines changed

9 files changed

+19
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
NODE_ENV: production
9191
run: |
9292
yarn build:js
93+
yarn build:custom-js
9394
yarn build:css
9495
9596
- name: Run tests

CONTRIBUTING.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ POSTGRES_PASSWORD=
9494

9595
We use [appraisal](https://github.com/thoughtbot/appraisal) to run tests against multiple versions of rails. When the gemfile gets updated you must also run `bundle exec appraisal install` to update the versioned ones and commit them to the repo.
9696

97+
# Custom JS
98+
99+
In order to be able to test the custom Stimulus integration we need to have some kind of JS content injected in the dummy app. We also need not to have that content present in every Avo installation. That's why we ejected the `_head.html.erb` partial that loads the `avo_custom.js` file from the engine's `build` directory. The build directory is not commited to git so we're all good on that. In order to have that file built and watche we added a `cjs` (short for `custom-js`) process in the `Procfile.dev` (which is used only in development).
100+
97101
# Misc
98102

99103
## Annotate models

Procfile.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
web: bin/rails server -p 3030
22
js: yarn build:js --watch
33
css: yarn build:css --watch
4+
cjs: yarn build:custom-js --watch

app/javascript/js/controllers.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import BelongsToFieldController from './controllers/fields/belongs_to_field_cont
77
import BooleanFilterController from './controllers/boolean_filter_controller'
88
import CodeFieldController from './controllers/fields/code_field_controller'
99
import CopyToClipboardController from './controllers/copy_to_clipboard_controller'
10-
import CourseResourceController from './controllers/custom/course_resource_controller'
1110
import DashboardCardController from './controllers/dashboard_card_controller'
1211
import DateFieldController from './controllers/fields/date_field_controller'
1312
import FilterController from './controllers/filter_controller'
@@ -70,4 +69,3 @@ application.register('simple-mde', SimpleMdeController)
7069
application.register('trix-field', TrixFieldController)
7170

7271
// Custom controllers
73-
application.register('course-resource', CourseResourceController)

bin/test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fi;
1212
# Run system tests
1313
if [[ -z "$1" ]] || [[ "$1" == "system" ]]; then
1414
yarn build:js
15+
yarn build:custom-js
1516
yarn build:css
1617
bundle exec rspec ./spec --tag type:system
1718
fi;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"js:visualize": "yarn prod:build:js -- --metafile=js_bundle_metadata.json && esbuild-visualizer --metadata=js_bundle_metadata.json --filename=js_bundle_stats.html",
1010
"build": "yarn build:js && yarn build:css",
1111
"build:js": "esbuild app/javascript/*.js --bundle --sourcemap --minify --outdir=app/assets/builds",
12+
"build:custom-js": "esbuild spec/dummy/app/javascript/*.js --bundle --sourcemap --minify --outdir=app/assets/builds",
1213
"build:css": "tailwindcss -i ./app/assets/stylesheets/avo.css -o ./app/assets/builds/avo.css --postcss",
1314
"prod:build": "yarn prod:build:js && yarn prod:build:css",
1415
"prod:build:js": "esbuild app/javascript/*.js --bundle --sourcemap --minify --outdir=public/avo-assets",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Application } from '@hotwired/stimulus'
2+
import CourseResourceController from './avo_custom/course_resource_controller'
3+
4+
const application = Application.start()
5+
console.log('mer')
6+
7+
// Configure Stimulus development experience
8+
application.debug = window?.localStorage.getItem('avo.debug')
9+
application.register('course-resource', CourseResourceController)

app/javascript/js/controllers/custom/course_resource_controller.js renamed to spec/dummy/app/javascript/avo_custom/course_resource_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class extends Controller {
99
view: String,
1010
}
1111

12-
// Te fields initial value
12+
// The fields initial value
1313
static initialValue
1414

1515
get placeholder() {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= javascript_include_tag "avo_custom", "data-turbo-track": "reload", defer: true %>

0 commit comments

Comments
 (0)