Skip to content

Commit 2706cb3

Browse files
authored
Switch to ESM and Baseline2024 (#311)
* Drop custom upload progress events * Update browser support to Baseline 2024 * Update Django version support * Update Python version support * Fix #310 -- Add `formaction` support on submit buttons
1 parent 071b17e commit 2706cb3

File tree

16 files changed

+1187
-304
lines changed

16 files changed

+1187
-304
lines changed

.github/workflows/ci.yml

+35-17
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,45 @@ jobs:
1111
dist:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: actions/checkout@v4
1415
- uses: actions/setup-python@v5
1516
with:
1617
python-version: "3.x"
17-
- uses: actions/checkout@v4
1818
- run: python -m pip install --upgrade pip build wheel twine
1919
- run: python -m build --sdist --wheel
2020
- run: python -m twine check dist/*
2121

22-
standardjs:
22+
js-lint:
2323
runs-on: ubuntu-latest
2424
steps:
25+
- uses: actions/checkout@v4
2526
- uses: actions/setup-node@v4
2627
with:
27-
node-version: '14.x'
28+
node-version-file: .nvmrc
29+
- name: Install Node dependencies
30+
run: npm ci
31+
- run: npm run lint:js
32+
33+
34+
js-test:
35+
runs-on: ubuntu-latest
36+
needs:
37+
- js-lint
38+
steps:
2839
- uses: actions/checkout@v4
29-
- id: cache-npm
30-
uses: actions/cache@v4
40+
- uses: actions/setup-node@v4
3141
with:
32-
path: ~/.npm
33-
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
34-
restore-keys: |
35-
${{ runner.os }}-node-
42+
node-version-file: .nvmrc
3643
- name: Install Node dependencies
3744
run: npm ci
38-
- run: npm run lint:js
45+
- run: node --test --experimental-test-coverage --test-reporter=spec --test-reporter=lcov --test-reporter-destination=stdout --test-reporter-destination=lcov.txt
46+
- uses: codecov/codecov-action@v4
47+
with:
48+
token: ${{ secrets.CODECOV_TOKEN }}
49+
flags: javascript
50+
file: lcov.txt
3951

40-
lint:
52+
py-lint:
4153
runs-on: ubuntu-latest
4254
strategy:
4355
matrix:
@@ -59,20 +71,19 @@ jobs:
5971

6072
pytest:
6173
needs:
62-
- lint
63-
- standardjs
74+
- py-lint
6475
- dist
6576
runs-on: ubuntu-latest
6677
strategy:
6778
matrix:
6879
python-version:
69-
- "3.10"
7080
- "3.11"
7181
- "3.12"
82+
- "3.13"
7283
django-version:
73-
- "3.2"
7484
- "4.2"
7585
- "5.0"
86+
- "5.1"
7687
steps:
7788
- uses: actions/checkout@v4
7889
- name: Set up Python ${{ matrix.python-version }}
@@ -90,12 +101,16 @@ jobs:
90101
curl -qO "https://chromedriver.storage.googleapis.com/$(curl -q https://chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip"
91102
unzip chromedriver_linux64.zip -d bin
92103
93-
- run: python -m pip install .[test] codecov
104+
- run: python -m pip install .[test]
94105
- run: python -m pip install django~=${{ matrix.django-version }}.0
95106
- run: python -m pytest -m "not selenium"
96107
env:
97108
PATH: $PATH:$(pwd)/bin
98-
- run: codecov
109+
- uses: codecov/codecov-action@v4
110+
with:
111+
token: ${{ secrets.CODECOV_TOKEN }}
112+
flags: python
113+
99114

100115
selenium:
101116
needs:
@@ -120,6 +135,9 @@ jobs:
120135
- run: python -m pip install -e .[test]
121136
- run: python -m pytest -m selenium
122137
- uses: codecov/codecov-action@v4
138+
with:
139+
token: ${{ secrets.CODECOV_TOKEN }}
140+
flags: selenium
123141

124142

125143
analyze:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ htmlcov/
4141
.cache
4242
nosetests.xml
4343
coverage.xml
44+
lcov.txt
4445

4546
# Translations
4647
*.mo

README.md

+1-48
Original file line numberDiff line numberDiff line change
@@ -140,59 +140,12 @@ to your CORS policy.
140140
]
141141
```
142142

143-
### Progress Bar
144-
145-
S3File does emit progress signals that can be used to display some kind
146-
of progress bar. Signals named `progress` are emitted for both each
147-
individual file input as well as for the form as a whole.
148-
149-
The progress signal carries the following details:
150-
151-
```javascript
152-
console.log(event.detail)
153-
154-
{
155-
progress: 0.4725307607171312 // total upload progress of either a form or single input
156-
loaded: 1048576 // total upload progress of either a form or single input
157-
total: 2219064 // total bytes to upload
158-
currentFile: File {…} // file object
159-
currentFileName: "text.txt" // file name of the file currently uploaded
160-
currentFileProgress: 0.47227834703299176 // upload progress of that file
161-
originalEvent: ProgressEvent {…} // the original XHR onprogress event
162-
}
163-
```
164-
165-
The following example implements a Boostrap progress bar for upload
166-
progress of an entire form.
167-
168-
```html
169-
<div class="progress">
170-
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
171-
</div>
172-
```
173-
174-
```javascript
175-
(function () {
176-
var form = document.getElementsByTagName('form')[0]
177-
var progressBar = document.getElementsByClassName('progress-bar')[0]
178-
179-
form.addEventListener('progress', function (event) {
180-
// event.detail.progress is a value between 0 and 1
181-
var percent = Math.round(event.detail.progress * 100)
182-
183-
progressBar.setAttribute('style', 'width:' + percent + '%')
184-
progressBar.setAttribute('aria-valuenow', percent)
185-
progressBar.innerText = percent + '%'
186-
})
187-
})()
188-
```
189-
190143
### Using S3File in development
191144

192145
Using S3File in development can be helpful especially if you want to use
193146
the progress signals described above. Therefore, S3File comes with a AWS
194147
S3 dummy backend. It behaves similar to the real S3 storage backend. It
195-
is automatically enabled, if the `DEFAULT_FILE_STORAGE` setting is set
148+
is automatically enabled, if the `STORAGES["default"]` setting is set
196149
to `FileSystemStorage`.
197150

198151
To prevent users from accidentally using the `FileSystemStorage` and the

0 commit comments

Comments
 (0)