Skip to content

Commit eb9499c

Browse files
author
billy clark
committed
Merge branch 'develop'
2 parents 36529ea + b604ebb commit eb9499c

File tree

372 files changed

+721
-32415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+721
-32415
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Please provide screenshots / animations for any change that involves the UI. Ple
2121

2222
## Checklist
2323

24+
- [ ] I have labeled my PR with: bug, feature, engineering, security fix or testing
2425
- [ ] I have performed a self-review of my own code
2526
- [ ] I have reviewed the title & description of this PR which I will use as the squashed PR commit message
2627
- [ ] I have commented my code, particularly in hard-to-understand areas

.github/workflows/integrate-and-deploy.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ jobs:
6666
-
6767
name: Verify version stamping
6868
run: |
69-
docker compose run --rm app cat build-version.txt version.php
70-
docker compose run --rm app cat version.php | grep ${{ steps.image.outputs.TAG_APP }}
69+
docker run --rm lf-app head build-version.txt version.php
70+
docker run --rm lf-app head version.php | grep -q ${{ steps.image.outputs.TAG_APP }}
7171
-
7272
name: Build "next" images
7373
run: make build-next
@@ -79,11 +79,11 @@ jobs:
7979
run: make e2e-tests-ci
8080
-
8181
name: Upload Playwright test results
82-
if: always()
83-
uses: actions/upload-artifact@v2
82+
uses: actions/upload-artifact@v3
8483
with:
8584
name: test-results
86-
path: test-results
85+
path: test/e2e/test-results
86+
if-no-files-found: error
8787
-
8888
name: Log in to Docker Hub
8989
uses: docker/login-action@v2

.github/workflows/pull-request.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
jobs:
16+
require-label:
17+
runs-on: ubuntu-latest
18+
env:
19+
GITHUB_TOKEN: ${{ github.token }}
20+
outputs:
21+
status: ${{ steps.check-labels.outputs.status }}
22+
steps:
23+
- uses: mheap/github-action-required-labels@v2
24+
id: check-labels
25+
with:
26+
mode: exactly
27+
count: 1
28+
labels: "bug, feature, engineering, security fix, testing"
29+
- uses: mheap/github-action-required-labels@v2
30+
with:
31+
mode: exactly
32+
count: 0
33+
labels: "do not merge"
34+
1635
unit-tests:
1736
runs-on: ubuntu-latest
1837

@@ -68,11 +87,11 @@ jobs:
6887

6988
-
7089
name: Upload Playwright test results
71-
if: always()
7290
uses: actions/upload-artifact@v3
7391
with:
7492
name: test-results
7593
path: test/e2e/test-results
94+
if-no-files-found: error
7695

7796
check-code-formatting:
7897
runs-on: ubuntu-latest

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ next-app/**/.env.*
3838

3939
## Extras
4040
# Libraries and generated code
41-
src/help/template/scripts/
42-
src/help/template/Theme3_Black/
43-
src/help/whxdata/
4441
src/js/lib/
4542
src/Site/views/languageforge/theme/default/page/home/assets/
4643
*.generated-data.*

LICENSE.txt

Lines changed: 0 additions & 485 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ services:
191191
command: sh -c "postconf -e 'default_transport = retry:no outbound email allowed' && /run.sh"
192192

193193
db:
194-
image: mongo:4.4
194+
image: mongo:5
195195
container_name: lf-db
196196
ports:
197197
# exposed this to host for admin tools
@@ -241,7 +241,7 @@ services:
241241
dockerfile: docker/app/Dockerfile
242242
args:
243243
- ENVIRONMENT=development
244-
image: lf-app
244+
image: lf-app-for-playwright
245245
container_name: app-for-playwright
246246
platform: linux/amd64
247247
depends_on:

docker/app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ COPY --from=sillsdev/web-languageforge:wait-latest /wait /wait
5656

5757
# DEVELOPMENT IMAGE
5858
FROM sillsdev/web-languageforge:base-php AS development-app
59-
RUN install-php-extensions xdebug
59+
RUN install-php-extensions xdebug-^3.1
6060
COPY docker/app/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d
6161
RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
6262
COPY --from=sillsdev/web-languageforge:wait-latest /wait /wait

docker/deployment/db-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ spec:
4949
spec:
5050
containers:
5151
- name: db
52-
image: mongo:4.4
52+
image: mongo:5
5353
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
5454
resources:
5555
requests:

docs/ACKNOWLEDGEMENTS.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@
33
![BrowserStack Logo](../readme_images/browserstack-logo.png "BrowserStack")
44

55
for mobile device testing.
6-
7-
## Libraries Used
8-
9-
[lamejs](https://github.com/zhuker/lamejs) is used for encoding recorded audio and is based on [LAME](http://lame.sourceforge.net/), which is licensed under the terms of [the LGPL](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html).

next-app/src/lib/auth/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// src/Api/Model/Shared/Rights/ProjectRoles.php
2+
// src/Api/Model/Shared/Rights/LexRoles.php
3+
const roles = [
4+
'project_manager',
5+
'contributor',
6+
'tech_support',
7+
'observer_with_comment',
8+
'observer',
9+
]
10+
11+
export const can_view_comments = role => roles.filter(_role => _role != 'observer').includes(role)
12+
export const can_view_activity = role => roles.filter(_role => ! _role.startsWith('observer')).includes(role)

next-app/src/lib/data/user.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { throwError } from '$lib/error'
2+
import { sf } from '$lib/fetch/server'
3+
4+
export async function fetch_current_user(cookie) {
5+
const { userId, userProjectRole } = await sf({
6+
name: 'session_getSessionData',
7+
cookie,
8+
})
9+
10+
if (! userId) {
11+
throwError('User unknown', 404)
12+
}
13+
14+
return {
15+
id: userId,
16+
role: userProjectRole,
17+
}
18+
}

next-app/src/lib/fetch/client.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,18 @@ async function customFetch(method, url, body) {
2323
body = JSON.stringify(body)
2424
}
2525

26-
let response = {}
27-
try {
28-
start(url)
29-
30-
response = await fetch(url, {
31-
method,
32-
headers,
33-
body,
34-
})
35-
} catch (e) {
36-
// these only occur for network errors, like these:
37-
// request made with a bad host, e.g., //httpbin
38-
// the host is refusing connections
39-
// client is offline, i.e., airplane mode or something
40-
// CORS preflight failures
41-
throwError(e)
42-
} finally {
43-
stop(url)
44-
}
26+
start(url)
27+
const response = await fetch(url, {
28+
method,
29+
headers,
30+
body,
31+
})
32+
.catch (throwError) // these only occur for network errors, like these:
33+
// * request made with a bad host, e.g., //httpbin
34+
// * the host is refusing connections
35+
// * client is offline, i.e., airplane mode or something
36+
// * CORS preflight failures
37+
.finally(() => stop(url))
4538

4639
// reminder: fetch does not throw exceptions for non-200 responses (https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)
4740
if (! response.ok) {

next-app/src/lib/fetch/server.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,21 @@ export async function sf(rpc) {
3838
async function customFetch(url, method, body, cookie) {
3939
const bodyAsJSON = JSON.stringify(body)
4040

41-
let response : Response
42-
43-
try {
44-
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Supplying_request_options
45-
response = await fetch(url, {
46-
method,
47-
headers: {
48-
'content-type': 'application/json',
49-
cookie,
50-
},
51-
body: bodyAsJSON,
52-
})
53-
} catch (e) {
41+
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Supplying_request_options
42+
const response = await fetch(url, {
43+
method,
44+
headers: {
45+
'content-type': 'application/json',
46+
cookie,
47+
},
48+
body: bodyAsJSON,
49+
}).catch(e => {
5450
// these only occur for network errors, like these:
5551
// request made with a bad host, e.g., //httpbin
5652
// the host is refusing connections
5753
console.log(`fetch/server.ts.customFetch caught error on ${url}=>${bodyAsJSON}: `, e)
5854
throwError('NETWORK ERROR', 500)
59-
}
55+
})
6056

6157
if (! response.ok) {
6258
console.log('fetch/server.ts.customFetch response !ok: ', await response.text())

next-app/src/routes/password/+server.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { json } from '@sveltejs/kit'
2+
import { fetch_current_user } from '$lib/data/user'
23
import { throwError } from '$lib/error'
34
import { sf } from '$lib/fetch/server'
45

@@ -14,18 +15,11 @@ export async function PUT({ request }) {
1415

1516
const cookie = request.headers.get('cookie')
1617

17-
const { userId } = await sf({
18-
name: 'session_getSessionData',
19-
cookie,
20-
})
21-
22-
if (! userId) {
23-
throwError('User unknown', 404)
24-
}
18+
const { id } = await fetch_current_user(cookie)
2519

2620
await sf({
2721
name: 'change_password',
28-
args: [userId, password],
22+
args: [id, password],
2923
cookie,
3024
})
3125

next-app/src/routes/projects/[project_code]/+page.server.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
import { get_activities } from './activities/+server'
2-
import { get as get_project_info } from './meta/+server'
1+
import { fetch_activities } from './activities/+server'
2+
import { fetch_project_details } from './meta/+server'
3+
import { can_view_activity } from '$lib/auth'
4+
import { fetch_current_user } from '$lib/data/user'
35

46
export async function load({ params: { project_code }, request: { headers }}) {
57
const args = {
68
project_code,
79
cookie: headers.get('cookie'),
810
}
911

10-
const project = await get_project_info(args)
11-
12-
const last_30_days = {
13-
start_date: daysAgo(30),
14-
end_date: new Date(),
12+
const result = {
13+
project: await fetch_project_details(args),
1514
}
16-
const activities = await get_activities({ ...last_30_days, ...args })
1715

18-
return {
19-
project,
20-
activities,
16+
const { role } = await fetch_current_user(args.cookie)
17+
if (can_view_activity(role)) {
18+
const last_30_days = {
19+
start_date: daysAgo(30),
20+
end_date: new Date(),
21+
}
22+
23+
result.activities = await fetch_activities({ ...last_30_days, ...args })
2124
}
25+
26+
return result
2227
}
2328

2429
function daysAgo(num_days) {

next-app/src/routes/projects/[project_code]/+page.svelte

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
icon: MessageAlertIcon,
5050
url: `/app/lexicon/${ project.id }#!/editor/entry/000000?filterBy=Comments`,
5151
},
52-
]
52+
].filter(({ value }) => value !== undefined)
5353
5454
async function load_all_activities() {
5555
activities = await GET(`/projects/${$page.params.project_code}/activities`)
@@ -76,13 +76,15 @@
7676
{/each}
7777
</Stats>
7878

79-
<h2>Activity</h2>
80-
<Activity { activities } />
79+
{#if activities}
80+
<h2>Activity</h2>
81+
<Activity { activities } />
8182

82-
{#if only_showing_subset}
83-
<footer class='flex justify-center mt-2'>
84-
<Button on:click={ load_all_activities } class='btn-outline btn-xs sm:btn-sm'>
85-
show all
86-
</Button>
87-
</footer>
83+
{#if only_showing_subset}
84+
<footer class='flex justify-center mt-2'>
85+
<Button on:click={ load_all_activities } class='btn-outline btn-xs sm:btn-sm'>
86+
show all
87+
</Button>
88+
</footer>
89+
{/if}
8890
{/if}

next-app/src/routes/projects/[project_code]/activities/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ export async function GET({ params: { project_code }, request: { headers } }) {
66

77
await sf({ name: 'set_project', args: [ project_code ], cookie })
88

9-
const activities = await get_activities({ cookie })
9+
const activities = await fetch_activities({ cookie })
1010

1111
return json(activities)
1212
}
1313

1414
// src/Api/Model/Shared/Dto/ActivityListDto.php
1515
// src/Api/Model/Shared/Dto/ActivityListDto.php->ActivityListModel.__construct
16-
export async function get_activities({ cookie, start_date, end_date }) {
16+
export async function fetch_activities({ cookie, start_date, end_date }) {
1717
const args = {
1818
name: 'activity_list_dto_for_current_project',
1919
args: [

0 commit comments

Comments
 (0)