mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'dspace-7_x' into w2p-130424_impossible-to-add-new-values-for-fields-without-qualifiers_contribute-7.6
This commit is contained in:
@@ -231,10 +231,13 @@
|
|||||||
"*.json5"
|
"*.json5"
|
||||||
],
|
],
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:jsonc/recommended-with-jsonc"
|
"plugin:jsonc/recommended-with-json5"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-irregular-whitespace": "error",
|
// The ESLint core no-irregular-whitespace rule doesn't work well in JSON
|
||||||
|
// See: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-irregular-whitespace.html
|
||||||
|
"no-irregular-whitespace": "off",
|
||||||
|
"jsonc/no-irregular-whitespace": "error",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"jsonc/comma-dangle": [
|
"jsonc/comma-dangle": [
|
||||||
"error",
|
"error",
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
# This workflow runs whenever a new pull request is created
|
|
||||||
# TEMPORARILY DISABLED. Unfortunately this doesn't work for PRs created from forked repositories (which is how we tend to create PRs).
|
|
||||||
# There is no known workaround yet. See https://github.community/t/how-to-use-github-token-for-prs-from-forks/16818
|
|
||||||
name: Pull Request opened
|
|
||||||
|
|
||||||
# Only run for newly opened PRs against the "main" branch
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened]
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
automation:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
# Assign the PR to whomever created it. This is useful for visualizing assignments on project boards
|
|
||||||
# See https://github.com/marketplace/actions/pull-request-assigner
|
|
||||||
- name: Assign PR to creator
|
|
||||||
uses: thomaseizinger/assign-pr-creator-action@v1.0.0
|
|
||||||
# Note, this authentication token is created automatically
|
|
||||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# Ignore errors. It is possible the PR was created by someone who cannot be assigned
|
|
||||||
continue-on-error: true
|
|
166
.github/workflows/build.yml
vendored
166
.github/workflows/build.yml
vendored
@@ -7,7 +7,8 @@ name: Build
|
|||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read # to fetch code (actions/checkout)
|
||||||
|
packages: read # to fetch private images from GitHub Container Registry (GHCR)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
@@ -33,21 +34,26 @@ jobs:
|
|||||||
#CHROME_VERSION: "90.0.4430.212-1"
|
#CHROME_VERSION: "90.0.4430.212-1"
|
||||||
# Bump Node heap size (OOM in CI after upgrading to Angular 15)
|
# Bump Node heap size (OOM in CI after upgrading to Angular 15)
|
||||||
NODE_OPTIONS: '--max-old-space-size=4096'
|
NODE_OPTIONS: '--max-old-space-size=4096'
|
||||||
|
# Project name to use when running "docker compose" prior to e2e tests
|
||||||
|
COMPOSE_PROJECT_NAME: 'ci'
|
||||||
|
# Docker Registry to use for Docker compose scripts below.
|
||||||
|
# We use GitHub's Container Registry to avoid aggressive rate limits at DockerHub.
|
||||||
|
DOCKER_REGISTRY: ghcr.io
|
||||||
strategy:
|
strategy:
|
||||||
# Create a matrix of Node versions to test against (in parallel)
|
# Create a matrix of Node versions to test against (in parallel)
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16.x, 18.x]
|
node-version: [18.x, 20.x]
|
||||||
# Do NOT exit immediately if one matrix job fails
|
# Do NOT exit immediately if one matrix job fails
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
# These are the actual CI steps to perform per job
|
# These are the actual CI steps to perform per job
|
||||||
steps:
|
steps:
|
||||||
# https://github.com/actions/checkout
|
# https://github.com/actions/checkout
|
||||||
- name: Checkout codebase
|
- name: Checkout codebase
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# https://github.com/actions/setup-node
|
# https://github.com/actions/setup-node
|
||||||
- name: Install Node.js ${{ matrix.node-version }}
|
- name: Install Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
@@ -72,7 +78,7 @@ jobs:
|
|||||||
id: yarn-cache-dir-path
|
id: yarn-cache-dir-path
|
||||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
- name: Cache Yarn dependencies
|
- name: Cache Yarn dependencies
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
# Cache entire Yarn cache directory (see previous step)
|
# Cache entire Yarn cache directory (see previous step)
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
@@ -99,26 +105,34 @@ jobs:
|
|||||||
# so that it can be shared with the 'codecov' job (see below)
|
# so that it can be shared with the 'codecov' job (see below)
|
||||||
# NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
|
# NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286
|
||||||
- name: Upload code coverage report to Artifact
|
- name: Upload code coverage report to Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
if: matrix.node-version == '18.x'
|
if: matrix.node-version == '18.x'
|
||||||
with:
|
with:
|
||||||
name: dspace-angular coverage report
|
name: coverage-report-${{ matrix.node-version }}
|
||||||
path: 'coverage/dspace-angular/lcov.info'
|
path: 'coverage/dspace-angular/lcov.info'
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
# Using docker-compose start backend using CI configuration
|
# Login to our Docker registry, so that we can access private Docker images using "docker compose" below.
|
||||||
|
- name: Login to ${{ env.DOCKER_REGISTRY }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.DOCKER_REGISTRY }}
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Using "docker compose" start backend using CI configuration
|
||||||
# and load assetstore from a cached copy
|
# and load assetstore from a cached copy
|
||||||
- name: Start DSpace REST Backend via Docker (for e2e tests)
|
- name: Start DSpace REST Backend via Docker (for e2e tests)
|
||||||
run: |
|
run: |
|
||||||
docker-compose -f ./docker/docker-compose-ci.yml up -d
|
docker compose -f ./docker/docker-compose-ci.yml up -d
|
||||||
docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli
|
docker compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli
|
||||||
docker container ls
|
docker container ls
|
||||||
|
|
||||||
# Run integration tests via Cypress.io
|
# Run integration tests via Cypress.io
|
||||||
# https://github.com/cypress-io/github-action
|
# https://github.com/cypress-io/github-action
|
||||||
# (NOTE: to run these e2e tests locally, just use 'ng e2e')
|
# (NOTE: to run these e2e tests locally, just use 'ng e2e')
|
||||||
- name: Run e2e tests (integration tests)
|
- name: Run e2e tests (integration tests)
|
||||||
uses: cypress-io/github-action@v5
|
uses: cypress-io/github-action@v6
|
||||||
with:
|
with:
|
||||||
# Run tests in Chrome, headless mode (default)
|
# Run tests in Chrome, headless mode (default)
|
||||||
browser: chrome
|
browser: chrome
|
||||||
@@ -133,19 +147,19 @@ jobs:
|
|||||||
# Cypress always creates a video of all e2e tests (whether they succeeded or failed)
|
# Cypress always creates a video of all e2e tests (whether they succeeded or failed)
|
||||||
# Save those in an Artifact
|
# Save those in an Artifact
|
||||||
- name: Upload e2e test videos to Artifacts
|
- name: Upload e2e test videos to Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: e2e-test-videos
|
name: e2e-test-videos-${{ matrix.node-version }}
|
||||||
path: cypress/videos
|
path: cypress/videos
|
||||||
|
|
||||||
# If e2e tests fail, Cypress creates a screenshot of what happened
|
# If e2e tests fail, Cypress creates a screenshot of what happened
|
||||||
# Save those in an Artifact
|
# Save those in an Artifact
|
||||||
- name: Upload e2e test failure screenshots to Artifacts
|
- name: Upload e2e test failure screenshots to Artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: e2e-test-screenshots
|
name: e2e-test-screenshots-${{ matrix.node-version }}
|
||||||
path: cypress/screenshots
|
path: cypress/screenshots
|
||||||
|
|
||||||
- name: Stop app (in case it stays up after e2e tests)
|
- name: Stop app (in case it stays up after e2e tests)
|
||||||
@@ -170,17 +184,120 @@ jobs:
|
|||||||
# Get homepage and verify that the <meta name="title"> tag includes "DSpace".
|
# Get homepage and verify that the <meta name="title"> tag includes "DSpace".
|
||||||
# If it does, then SSR is working, as this tag is created by our MetadataService.
|
# If it does, then SSR is working, as this tag is created by our MetadataService.
|
||||||
# This step also prints entire HTML of homepage for easier debugging if grep fails.
|
# This step also prints entire HTML of homepage for easier debugging if grep fails.
|
||||||
- name: Verify SSR (server-side rendering)
|
- name: Verify SSR (server-side rendering) on Homepage
|
||||||
run: |
|
run: |
|
||||||
result=$(wget -O- -q http://127.0.0.1:4000/home)
|
result=$(wget -O- -q http://127.0.0.1:4000/home)
|
||||||
echo "$result"
|
echo "$result"
|
||||||
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep DSpace
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep DSpace
|
||||||
|
|
||||||
|
# Get a specific community in our test data and verify that the "<h1>" tag includes "Publications" (the community name).
|
||||||
|
# If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Community page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/communities/0958c910-2037-42a9-81c7-dca80e3892b4)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<h1 [^>]*>[^><]*</h1>" | grep Publications
|
||||||
|
|
||||||
|
# Get a specific collection in our test data and verify that the "<h1>" tag includes "Articles" (the collection name).
|
||||||
|
# If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Collection page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/collections/282164f5-d325-4740-8dd1-fa4d6d3e7200)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<h1 [^>]*>[^><]*</h1>" | grep Articles
|
||||||
|
|
||||||
|
# Get a specific publication in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the title of this publication. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Publication page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/publication/6160810f-1e53-40db-81ef-f6621a727398)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "An Economic Model of Mortality Salience"
|
||||||
|
|
||||||
|
# Get a specific person in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the person. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Person page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/person/b1b2c768-bda1-448a-a073-fc541e8b24d9)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Simmons, Cameron"
|
||||||
|
|
||||||
|
# Get a specific project in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the project. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Project page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/project/46ccb608-a74c-4bf6-bc7a-e29cc7defea9)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "University Research Fellowship"
|
||||||
|
|
||||||
|
# Get a specific orgunit in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the orgunit. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on an OrgUnit page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/orgunit/9851674d-bd9a-467b-8d84-068deb568ccf)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Law and Development"
|
||||||
|
|
||||||
|
# Get a specific journal in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the journal. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Journal page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/journal/d4af6c3e-53d0-4757-81eb-566f3b45d63a)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology"
|
||||||
|
|
||||||
|
# Get a specific journal volume in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the volume. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Journal Volume page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/journalvolume/07c6249f-4bf7-494d-9ce3-6ffdb2aed538)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology Volume 28 (2017)"
|
||||||
|
|
||||||
|
# Get a specific journal issue in our test data and verify that the <meta name="title"> tag includes
|
||||||
|
# the name of the issue. If it does, then SSR is working.
|
||||||
|
- name: Verify SSR on a Journal Issue page
|
||||||
|
run: |
|
||||||
|
result=$(wget -O- -q http://127.0.0.1:4000/entities/journalissue/44c29473-5de2-48fa-b005-e5029aa1a50b)
|
||||||
|
echo "$result"
|
||||||
|
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Environmental & Architectural Phenomenology Vol. 28, No. 1"
|
||||||
|
|
||||||
|
# Verify 301 Handle redirect behavior
|
||||||
|
# Note: /handle/123456789/260 is the same test Publication used by our e2e tests
|
||||||
|
- name: Verify 301 redirect from '/handle' URLs
|
||||||
|
run: |
|
||||||
|
result=$(wget --server-response --quiet http://127.0.0.1:4000/handle/123456789/260 2>&1 | head -1 | awk '{print $2}')
|
||||||
|
echo "$result"
|
||||||
|
[[ "$result" -eq "301" ]]
|
||||||
|
|
||||||
|
# Verify 403 error code behavior
|
||||||
|
- name: Verify 403 error code from '/403'
|
||||||
|
run: |
|
||||||
|
result=$(wget --server-response --quiet http://127.0.0.1:4000/403 2>&1 | head -1 | awk '{print $2}')
|
||||||
|
echo "$result"
|
||||||
|
[[ "$result" -eq "403" ]]
|
||||||
|
|
||||||
|
# Verify 404 error code behavior
|
||||||
|
- name: Verify 404 error code from '/404' and on invalid pages
|
||||||
|
run: |
|
||||||
|
result=$(wget --server-response --quiet http://127.0.0.1:4000/404 2>&1 | head -1 | awk '{print $2}')
|
||||||
|
echo "$result"
|
||||||
|
result2=$(wget --server-response --quiet http://127.0.0.1:4000/invalidurl 2>&1 | head -1 | awk '{print $2}')
|
||||||
|
echo "$result2"
|
||||||
|
[[ "$result" -eq "404" && "$result2" -eq "404" ]]
|
||||||
|
|
||||||
|
# Verify 500 error code behavior
|
||||||
|
- name: Verify 500 error code from '/500'
|
||||||
|
run: |
|
||||||
|
result=$(wget --server-response --quiet http://127.0.0.1:4000/500 2>&1 | head -1 | awk '{print $2}')
|
||||||
|
echo "$result"
|
||||||
|
[[ "$result" -eq "500" ]]
|
||||||
|
|
||||||
- name: Stop running app
|
- name: Stop running app
|
||||||
run: kill -9 $(lsof -t -i:4000)
|
run: kill -9 $(lsof -t -i:4000)
|
||||||
|
|
||||||
- name: Shutdown Docker containers
|
- name: Shutdown Docker containers
|
||||||
run: docker-compose -f ./docker/docker-compose-ci.yml down
|
run: docker compose -f ./docker/docker-compose-ci.yml down
|
||||||
|
|
||||||
# Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test
|
# Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test
|
||||||
# job above. This is necessary because Codecov uploads seem to randomly fail at times.
|
# job above. This is necessary because Codecov uploads seem to randomly fail at times.
|
||||||
@@ -191,11 +308,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Download artifacts from previous 'tests' job
|
# Download artifacts from previous 'tests' job
|
||||||
- name: Download coverage artifacts
|
- name: Download coverage artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
|
|
||||||
# Now attempt upload to Codecov using its action.
|
# Now attempt upload to Codecov using its action.
|
||||||
# NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
|
# NOTE: We use a retry action to retry the Codecov upload if it fails the first time.
|
||||||
@@ -203,10 +320,15 @@ jobs:
|
|||||||
# Retry action: https://github.com/marketplace/actions/retry-action
|
# Retry action: https://github.com/marketplace/actions/retry-action
|
||||||
# Codecov action: https://github.com/codecov/codecov-action
|
# Codecov action: https://github.com/codecov/codecov-action
|
||||||
- name: Upload coverage to Codecov.io
|
- name: Upload coverage to Codecov.io
|
||||||
uses: Wandalen/wretry.action@v1.0.36
|
uses: Wandalen/wretry.action@v1.3.0
|
||||||
with:
|
with:
|
||||||
action: codecov/codecov-action@v3
|
action: codecov/codecov-action@v4
|
||||||
# Try upload 5 times max
|
# Ensure codecov-action throws an error when it fails to upload
|
||||||
|
# This allows us to auto-restart the action if an error is thrown
|
||||||
|
with: |
|
||||||
|
fail_ci_if_error: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
# Try re-running action 5 times max
|
||||||
attempt_limit: 5
|
attempt_limit: 5
|
||||||
# Run again in 30 seconds
|
# Run again in 30 seconds
|
||||||
attempt_delay: 30000
|
attempt_delay: 30000
|
||||||
|
12
.github/workflows/codescan.yml
vendored
12
.github/workflows/codescan.yml
vendored
@@ -5,12 +5,16 @@
|
|||||||
# because CodeQL requires a fresh build with all tests *disabled*.
|
# because CodeQL requires a fresh build with all tests *disabled*.
|
||||||
name: "Code Scanning"
|
name: "Code Scanning"
|
||||||
|
|
||||||
# Run this code scan for all pushes / PRs to main branch. Also run once a week.
|
# Run this code scan for all pushes / PRs to main or maintenance branches. Also run once a week.
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
- 'dspace-**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
- 'dspace-**'
|
||||||
# Don't run if PR is only updating static documentation
|
# Don't run if PR is only updating static documentation
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**/*.md'
|
- '**/*.md'
|
||||||
@@ -31,7 +35,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# https://github.com/actions/checkout
|
# https://github.com/actions/checkout
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
# https://github.com/github/codeql-action
|
# https://github.com/github/codeql-action
|
||||||
|
140
.github/workflows/docker.yml
vendored
140
.github/workflows/docker.yml
vendored
@@ -3,6 +3,9 @@ name: Docker images
|
|||||||
|
|
||||||
# Run this Build for all pushes to 'main' or maintenance branches, or tagged releases.
|
# Run this Build for all pushes to 'main' or maintenance branches, or tagged releases.
|
||||||
# Also run for PRs to ensure PR doesn't break Docker build process
|
# Also run for PRs to ensure PR doesn't break Docker build process
|
||||||
|
# NOTE: uses "reusable-docker-build.yml" in DSpace/DSpace to actually build each of the Docker images
|
||||||
|
# https://github.com/DSpace/DSpace/blob/dspace-7_x/.github/workflows/reusable-docker-build.yml
|
||||||
|
#
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -13,108 +16,45 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read # to fetch code (actions/checkout)
|
||||||
|
packages: write # to write images to GitHub Container Registry (GHCR)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
#############################################################
|
||||||
|
# Build/Push the 'dspace/dspace-angular' image
|
||||||
|
#############################################################
|
||||||
|
dspace-angular:
|
||||||
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
|
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
|
||||||
if: github.repository == 'dspace/dspace-angular'
|
if: github.repository == 'dspace/dspace-angular'
|
||||||
runs-on: ubuntu-latest
|
# Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
|
||||||
env:
|
uses: DSpace/DSpace/.github/workflows/reusable-docker-build.yml@dspace-7_x
|
||||||
# Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action)
|
with:
|
||||||
# For a new commit on default branch (main), use the literal tag 'dspace-7_x' on Docker image.
|
build_id: dspace-angular-dev
|
||||||
# For a new commit on other branches, use the branch name as the tag for Docker image.
|
image_name: dspace/dspace-angular
|
||||||
# For a new tag, copy that tag name as the tag for Docker image.
|
dockerfile_path: ./Dockerfile
|
||||||
IMAGE_TAGS: |
|
secrets:
|
||||||
type=raw,value=dspace-7_x,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }}
|
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
type=ref,event=tag
|
|
||||||
# Define default tag "flavor" for docker/metadata-action per
|
|
||||||
# https://github.com/docker/metadata-action#flavor-input
|
|
||||||
# We turn off 'latest' tag by default.
|
|
||||||
TAGS_FLAVOR: |
|
|
||||||
latest=false
|
|
||||||
# Architectures / Platforms for which we will build Docker images
|
|
||||||
# If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work.
|
|
||||||
# If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64.
|
|
||||||
PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }}
|
|
||||||
|
|
||||||
steps:
|
#############################################################
|
||||||
# https://github.com/actions/checkout
|
# Build/Push the 'dspace/dspace-angular' image ('-dist' tag)
|
||||||
- name: Checkout codebase
|
#############################################################
|
||||||
uses: actions/checkout@v3
|
dspace-angular-dist:
|
||||||
|
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
|
||||||
# https://github.com/docker/setup-buildx-action
|
if: github.repository == 'dspace/dspace-angular'
|
||||||
- name: Setup Docker Buildx
|
# Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: DSpace/DSpace/.github/workflows/reusable-docker-build.yml@dspace-7_x
|
||||||
|
with:
|
||||||
# https://github.com/docker/setup-qemu-action
|
build_id: dspace-angular-dist
|
||||||
- name: Set up QEMU emulation to build for multiple architectures
|
image_name: dspace/dspace-angular
|
||||||
uses: docker/setup-qemu-action@v2
|
dockerfile_path: ./Dockerfile.dist
|
||||||
|
# As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
|
||||||
# https://github.com/docker/login-action
|
# tagging logic as the primary 'dspace/dspace-angular' image above.
|
||||||
- name: Login to DockerHub
|
tags_flavor: suffix=-dist
|
||||||
# Only login if not a PR, as PRs only trigger a Docker build and not a push
|
secrets:
|
||||||
if: github.event_name != 'pull_request'
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
uses: docker/login-action@v2
|
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
||||||
with:
|
# Enable redeploy of sandbox & demo if the branch for this image matches the deployment branch of
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
# these sites as specified in reusable-docker-build.xml
|
||||||
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
|
REDEPLOY_SANDBOX_URL: ${{ secrets.REDEPLOY_SANDBOX_URL }}
|
||||||
|
REDEPLOY_DEMO_URL: ${{ secrets.REDEPLOY_DEMO_URL }}
|
||||||
###############################################
|
|
||||||
# Build/Push the 'dspace/dspace-angular' image
|
|
||||||
###############################################
|
|
||||||
# https://github.com/docker/metadata-action
|
|
||||||
# Get Metadata for docker_build step below
|
|
||||||
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular' image
|
|
||||||
id: meta_build
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: dspace/dspace-angular
|
|
||||||
tags: ${{ env.IMAGE_TAGS }}
|
|
||||||
flavor: ${{ env.TAGS_FLAVOR }}
|
|
||||||
|
|
||||||
# https://github.com/docker/build-push-action
|
|
||||||
- name: Build and push 'dspace-angular' image
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
platforms: ${{ env.PLATFORMS }}
|
|
||||||
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
|
|
||||||
# but we ONLY do an image push to DockerHub if it's NOT a PR
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
# Use tags / labels provided by 'docker/metadata-action' above
|
|
||||||
tags: ${{ steps.meta_build.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta_build.outputs.labels }}
|
|
||||||
|
|
||||||
#####################################################
|
|
||||||
# Build/Push the 'dspace/dspace-angular' image ('-dist' tag)
|
|
||||||
#####################################################
|
|
||||||
# https://github.com/docker/metadata-action
|
|
||||||
# Get Metadata for docker_build_dist step below
|
|
||||||
- name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular-dist' image
|
|
||||||
id: meta_build_dist
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: dspace/dspace-angular
|
|
||||||
tags: ${{ env.IMAGE_TAGS }}
|
|
||||||
# As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
|
|
||||||
# tagging logic as the primary 'dspace/dspace-angular' image above.
|
|
||||||
flavor: ${{ env.TAGS_FLAVOR }}
|
|
||||||
suffix=-dist
|
|
||||||
|
|
||||||
- name: Build and push 'dspace-angular-dist' image
|
|
||||||
id: docker_build_dist
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile.dist
|
|
||||||
platforms: ${{ env.PLATFORMS }}
|
|
||||||
# For pull requests, we run the Docker build (to ensure no PR changes break the build),
|
|
||||||
# but we ONLY do an image push to DockerHub if it's NOT a PR
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
# Use tags / labels provided by 'docker/metadata-action' above
|
|
||||||
tags: ${{ steps.meta_build_dist.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta_build_dist.outputs.labels }}
|
|
2
.github/workflows/issue_opened.yml
vendored
2
.github/workflows/issue_opened.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
# Only add to project board if issue is flagged as "needs triage" or has no labels
|
# Only add to project board if issue is flagged as "needs triage" or has no labels
|
||||||
# NOTE: By default we flag new issues as "needs triage" in our issue template
|
# NOTE: By default we flag new issues as "needs triage" in our issue template
|
||||||
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
|
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
|
||||||
uses: actions/add-to-project@v0.5.0
|
uses: actions/add-to-project@v1.0.0
|
||||||
# Note, the authentication token below is an ORG level Secret.
|
# Note, the authentication token below is an ORG level Secret.
|
||||||
# It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions
|
# It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions
|
||||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
|
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
|
||||||
|
9
.github/workflows/label_merge_conflicts.yml
vendored
9
.github/workflows/label_merge_conflicts.yml
vendored
@@ -1,11 +1,12 @@
|
|||||||
# This workflow checks open PRs for merge conflicts and labels them when conflicts are found
|
# This workflow checks open PRs for merge conflicts and labels them when conflicts are found
|
||||||
name: Check for merge conflicts
|
name: Check for merge conflicts
|
||||||
|
|
||||||
# Run whenever the "main" branch is updated
|
# Run this for all pushes (i.e. merges) to 'main' or maintenance branches
|
||||||
# NOTE: This means merge conflicts are only checked for when a PR is merged to main.
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
- 'dspace-**'
|
||||||
# So that the `conflict_label_name` is removed if conflicts are resolved,
|
# So that the `conflict_label_name` is removed if conflicts are resolved,
|
||||||
# we allow this to run for `pull_request_target` so that github secrets are available.
|
# we allow this to run for `pull_request_target` so that github secrets are available.
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
@@ -24,6 +25,8 @@ jobs:
|
|||||||
# See: https://github.com/prince-chrismc/label-merge-conflicts-action
|
# See: https://github.com/prince-chrismc/label-merge-conflicts-action
|
||||||
- name: Auto-label PRs with merge conflicts
|
- name: Auto-label PRs with merge conflicts
|
||||||
uses: prince-chrismc/label-merge-conflicts-action@v3
|
uses: prince-chrismc/label-merge-conflicts-action@v3
|
||||||
|
# Ignore any failures -- may occur (randomly?) for older, outdated PRs.
|
||||||
|
continue-on-error: true
|
||||||
# Add "merge conflict" label if a merge conflict is detected. Remove it when resolved.
|
# Add "merge conflict" label if a merge conflict is detected. Remove it when resolved.
|
||||||
# Note, the authentication token is created automatically
|
# Note, the authentication token is created automatically
|
||||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||||
|
46
.github/workflows/port_merged_pull_request.yml
vendored
Normal file
46
.github/workflows/port_merged_pull_request.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# This workflow will attempt to port a merged pull request to
|
||||||
|
# the branch specified in a "port to" label (if exists)
|
||||||
|
name: Port merged Pull Request
|
||||||
|
|
||||||
|
# Only run for merged PRs against the "main" or maintenance branches
|
||||||
|
# We allow this to run for `pull_request_target` so that github secrets are available
|
||||||
|
# (This is required when the PR comes from a forked repo)
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [ closed ]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- 'dspace-**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write # so action can add comments
|
||||||
|
pull-requests: write # so action can create pull requests
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
port_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Don't run on closed *unmerged* pull requests
|
||||||
|
if: github.event.pull_request.merged
|
||||||
|
steps:
|
||||||
|
# Checkout code
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
# Port PR to other branch (ONLY if labeled with "port to")
|
||||||
|
# See https://github.com/korthout/backport-action
|
||||||
|
- name: Create backport pull requests
|
||||||
|
uses: korthout/backport-action@v2
|
||||||
|
with:
|
||||||
|
# Trigger based on a "port to [branch]" label on PR
|
||||||
|
# (This label must specify the branch name to port to)
|
||||||
|
label_pattern: '^port to ([^ ]+)$'
|
||||||
|
# Title to add to the (newly created) port PR
|
||||||
|
pull_title: '[Port ${target_branch}] ${pull_title}'
|
||||||
|
# Description to add to the (newly created) port PR
|
||||||
|
pull_description: 'Port of #${pull_number} by @${pull_author} to `${target_branch}`.'
|
||||||
|
# Copy all labels from original PR to (newly created) port PR
|
||||||
|
# NOTE: The labels matching 'label_pattern' are automatically excluded
|
||||||
|
copy_labels_pattern: '.*'
|
||||||
|
# Skip any merge commits in the ported PR. This means only non-merge commits are cherry-picked to the new PR
|
||||||
|
merge_commits: 'skip'
|
||||||
|
# Use a personal access token (PAT) to create PR as 'dspace-bot' user.
|
||||||
|
# A PAT is required in order for the new PR to trigger its own actions (for CI checks)
|
||||||
|
github_token: ${{ secrets.PR_PORT_TOKEN }}
|
24
.github/workflows/pull_request_opened.yml
vendored
Normal file
24
.github/workflows/pull_request_opened.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# This workflow runs whenever a new pull request is created
|
||||||
|
name: Pull Request opened
|
||||||
|
|
||||||
|
# Only run for newly opened PRs against the "main" or maintenance branches
|
||||||
|
# We allow this to run for `pull_request_target` so that github secrets are available
|
||||||
|
# (This is required to assign a PR back to the creator when the PR comes from a forked repo)
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [ opened ]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- 'dspace-**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
automation:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Assign the PR to whomever created it. This is useful for visualizing assignments on project boards
|
||||||
|
# See https://github.com/toshimaru/auto-author-assign
|
||||||
|
- name: Assign PR to creator
|
||||||
|
uses: toshimaru/auto-author-assign@v2.1.0
|
@@ -1,7 +1,7 @@
|
|||||||
# This image will be published as dspace/dspace-angular
|
# This image will be published as dspace/dspace-angular
|
||||||
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
|
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
|
||||||
|
|
||||||
FROM node:18-alpine
|
FROM docker.io/node:18-alpine
|
||||||
|
|
||||||
# Ensure Python and other build tools are available
|
# Ensure Python and other build tools are available
|
||||||
# These are needed to install some node modules, especially on linux/arm64
|
# These are needed to install some node modules, especially on linux/arm64
|
||||||
@@ -24,5 +24,5 @@ ENV NODE_OPTIONS="--max_old_space_size=4096"
|
|||||||
# Listen / accept connections from all IP addresses.
|
# Listen / accept connections from all IP addresses.
|
||||||
# NOTE: At this time it is only possible to run Docker container in Production mode
|
# NOTE: At this time it is only possible to run Docker container in Production mode
|
||||||
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
|
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
|
||||||
ENV NODE_ENV development
|
ENV NODE_ENV=development
|
||||||
CMD yarn serve --host 0.0.0.0
|
CMD yarn serve --host 0.0.0.0
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
# Test build:
|
# Test build:
|
||||||
# docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-7_x-dist .
|
# docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-7_x-dist .
|
||||||
|
|
||||||
FROM node:18-alpine as build
|
FROM docker.io/node:18-alpine AS build
|
||||||
|
|
||||||
# Ensure Python and other build tools are available
|
# Ensure Python and other build tools are available
|
||||||
# These are needed to install some node modules, especially on linux/arm64
|
# These are needed to install some node modules, especially on linux/arm64
|
||||||
@@ -26,6 +26,6 @@ COPY --chown=node:node docker/dspace-ui.json /app/dspace-ui.json
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
USER node
|
USER node
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV=production
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
CMD pm2-runtime start dspace-ui.json --json
|
CMD pm2-runtime start dspace-ui.json --json
|
||||||
|
@@ -157,8 +157,8 @@ DSPACE_UI_SSL => DSPACE_SSL
|
|||||||
|
|
||||||
The same settings can also be overwritten by setting system environment variables instead, E.g.:
|
The same settings can also be overwritten by setting system environment variables instead, E.g.:
|
||||||
```bash
|
```bash
|
||||||
export DSPACE_HOST=api7.dspace.org
|
export DSPACE_HOST=demo.dspace.org
|
||||||
export DSPACE_UI_PORT=4200
|
export DSPACE_UI_PORT=4000
|
||||||
```
|
```
|
||||||
|
|
||||||
The priority works as follows: **environment variable** overrides **variable in `.env` file** overrides external config set by `DSPACE_APP_CONFIG_PATH` overrides **`config.(prod or dev).yml`**
|
The priority works as follows: **environment variable** overrides **variable in `.env` file** overrides external config set by `DSPACE_APP_CONFIG_PATH` overrides **`config.(prod or dev).yml`**
|
||||||
@@ -288,7 +288,7 @@ E2E tests (aka integration tests) use [Cypress.io](https://www.cypress.io/). Con
|
|||||||
The test files can be found in the `./cypress/integration/` folder.
|
The test files can be found in the `./cypress/integration/` folder.
|
||||||
|
|
||||||
Before you can run e2e tests, two things are REQUIRED:
|
Before you can run e2e tests, two things are REQUIRED:
|
||||||
1. You MUST be running the DSpace backend (i.e. REST API) locally. The e2e tests will *NOT* succeed if run against our demo REST API (https://api7.dspace.org/server/), as that server is uncontrolled and may have content added/removed at any time.
|
1. You MUST be running the DSpace backend (i.e. REST API) locally. The e2e tests will *NOT* succeed if run against our demo/sandbox REST API (https://demo.dspace.org/server/ or https://sandbox.dspace.org/server/), as those sites may have content added/removed at any time.
|
||||||
* After starting up your backend on localhost, make sure either your `config.prod.yml` or `config.dev.yml` has its `rest` settings defined to use that localhost backend.
|
* After starting up your backend on localhost, make sure either your `config.prod.yml` or `config.dev.yml` has its `rest` settings defined to use that localhost backend.
|
||||||
* If you'd prefer, you may instead use environment variables as described at [Configuring](#configuring). For example:
|
* If you'd prefer, you may instead use environment variables as described at [Configuring](#configuring). For example:
|
||||||
```
|
```
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
"lodash",
|
"lodash",
|
||||||
"jwt-decode",
|
"jwt-decode",
|
||||||
"uuid",
|
"uuid",
|
||||||
"webfontloader",
|
|
||||||
"zone.js"
|
"zone.js"
|
||||||
],
|
],
|
||||||
"outputPath": "dist/browser",
|
"outputPath": "dist/browser",
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# NOTE: will log all redux actions and transfers in console
|
# NOTE: will log all redux actions and transfers in console
|
||||||
debug: false
|
debug: false
|
||||||
|
|
||||||
# Angular Universal server settings
|
# Angular User Inteface settings
|
||||||
# NOTE: these settings define where Node.js will start your UI application. Therefore, these
|
# NOTE: these settings define where Node.js will start your UI application. Therefore, these
|
||||||
# "ui" settings usually specify a localhost port/URL which is later proxied to a public URL (using Apache or similar)
|
# "ui" settings usually specify a localhost port/URL which is later proxied to a public URL (using Apache or similar)
|
||||||
ui:
|
ui:
|
||||||
@@ -17,15 +17,61 @@ ui:
|
|||||||
# Trust X-FORWARDED-* headers from proxies (default = true)
|
# Trust X-FORWARDED-* headers from proxies (default = true)
|
||||||
useProxies: true
|
useProxies: true
|
||||||
|
|
||||||
|
# Angular Universal / Server Side Rendering (SSR) settings
|
||||||
|
universal:
|
||||||
|
# Whether to tell Angular to inline "critical" styles into the server-side rendered HTML.
|
||||||
|
# Determining which styles are critical is a relatively expensive operation; this option is
|
||||||
|
# disabled (false) by default to boost server performance at the expense of loading smoothness.
|
||||||
|
inlineCriticalCss: false
|
||||||
|
# Patterns to be run as regexes against the path of the page to check if SSR is allowed.
|
||||||
|
# If the path match any of the regexes it will be served directly in CSR.
|
||||||
|
# By default, excludes community and collection browse, global browse, global search, community list, statistics and various administrative tools.
|
||||||
|
excludePathPatterns:
|
||||||
|
- pattern: "^/communities/[a-f0-9-]{36}/browse(/.*)?$"
|
||||||
|
flag: "i"
|
||||||
|
- pattern: "^/collections/[a-f0-9-]{36}/browse(/.*)?$"
|
||||||
|
flag: "i"
|
||||||
|
- pattern: "^/browse/"
|
||||||
|
- pattern: "^/search$"
|
||||||
|
- pattern: "^/community-list$"
|
||||||
|
- pattern: "^/admin/"
|
||||||
|
- pattern: "^/processes/?"
|
||||||
|
- pattern: "^/notifications/"
|
||||||
|
- pattern: "^/statistics/?"
|
||||||
|
- pattern: "^/access-control/"
|
||||||
|
- pattern: "^/health$"
|
||||||
|
|
||||||
|
# Whether to enable rendering of Search component on SSR.
|
||||||
|
# If set to true the component will be included in the HTML returned from the server side rendering.
|
||||||
|
# If set to false the component will not be included in the HTML returned from the server side rendering.
|
||||||
|
enableSearchComponent: false
|
||||||
|
# Whether to enable rendering of Browse component on SSR.
|
||||||
|
# If set to true the component will be included in the HTML returned from the server side rendering.
|
||||||
|
# If set to false the component will not be included in the HTML returned from the server side rendering.
|
||||||
|
enableBrowseComponent: false
|
||||||
|
# Enable state transfer from the server-side application to the client-side application.
|
||||||
|
# Defaults to true.
|
||||||
|
# Note: When using an external application cache layer, it's recommended not to transfer the state to avoid caching it.
|
||||||
|
# Disabling it ensures that dynamic state information is not inadvertently cached, which can improve security and
|
||||||
|
# ensure that users always use the most up-to-date state.
|
||||||
|
transferState: true
|
||||||
|
# When a different REST base URL is used for the server-side application, the generated state contains references to
|
||||||
|
# REST resources with the internal URL configured. By default, these internal URLs are replaced with public URLs.
|
||||||
|
# Disable this setting to avoid URL replacement during SSR. In this the state is not transferred to avoid security issues.
|
||||||
|
replaceRestUrl: true
|
||||||
|
|
||||||
# The REST API server settings
|
# The REST API server settings
|
||||||
# NOTE: these settings define which (publicly available) REST API to use. They are usually
|
# NOTE: these settings define which (publicly available) REST API to use. They are usually
|
||||||
# 'synced' with the 'dspace.server.url' setting in your backend's local.cfg.
|
# 'synced' with the 'dspace.server.url' setting in your backend's local.cfg.
|
||||||
rest:
|
rest:
|
||||||
ssl: true
|
ssl: true
|
||||||
host: api7.dspace.org
|
host: demo.dspace.org
|
||||||
port: 443
|
port: 443
|
||||||
# NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
# NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||||
nameSpace: /server
|
nameSpace: /server
|
||||||
|
# Provide a different REST url to be used during SSR execution. It must contain the whole url including protocol, server port and
|
||||||
|
# server namespace (uncomment to use it).
|
||||||
|
#ssrBaseUrl: http://localhost:8080/server
|
||||||
|
|
||||||
# Caching settings
|
# Caching settings
|
||||||
cache:
|
cache:
|
||||||
@@ -75,7 +121,7 @@ cache:
|
|||||||
anonymousCache:
|
anonymousCache:
|
||||||
# Maximum number of pages to cache. Default is zero (0) which means anonymous user cache is disabled.
|
# Maximum number of pages to cache. Default is zero (0) which means anonymous user cache is disabled.
|
||||||
# As all pages are cached in server memory, increasing this value will increase memory needs.
|
# As all pages are cached in server memory, increasing this value will increase memory needs.
|
||||||
# Individual cached pages are usually small (<100KB), so a value of max=1000 would only require ~100MB of memory.
|
# Individual cached pages are usually small (<100KB), so a value of max=1000 would only require ~100MB of memory.
|
||||||
max: 0
|
max: 0
|
||||||
# Amount of time after which cached pages are considered stale (in ms). After becoming stale, the cached
|
# Amount of time after which cached pages are considered stale (in ms). After becoming stale, the cached
|
||||||
# copy is automatically refreshed on the next request.
|
# copy is automatically refreshed on the next request.
|
||||||
@@ -169,6 +215,12 @@ languages:
|
|||||||
- code: en
|
- code: en
|
||||||
label: English
|
label: English
|
||||||
active: true
|
active: true
|
||||||
|
- code: ar
|
||||||
|
label: العربية
|
||||||
|
active: true
|
||||||
|
- code: bn
|
||||||
|
label: বাংলা
|
||||||
|
active: true
|
||||||
- code: ca
|
- code: ca
|
||||||
label: Català
|
label: Català
|
||||||
active: true
|
active: true
|
||||||
@@ -178,24 +230,36 @@ languages:
|
|||||||
- code: de
|
- code: de
|
||||||
label: Deutsch
|
label: Deutsch
|
||||||
active: true
|
active: true
|
||||||
|
- code: el
|
||||||
|
label: Ελληνικά
|
||||||
|
active: true
|
||||||
- code: es
|
- code: es
|
||||||
label: Español
|
label: Español
|
||||||
active: true
|
active: true
|
||||||
|
- code: fi
|
||||||
|
label: Suomi
|
||||||
|
active: true
|
||||||
- code: fr
|
- code: fr
|
||||||
label: Français
|
label: Français
|
||||||
active: true
|
active: true
|
||||||
- code: gd
|
- code: gd
|
||||||
label: Gàidhlig
|
label: Gàidhlig
|
||||||
active: true
|
active: true
|
||||||
- code: it
|
- code: hi
|
||||||
label: Italiano
|
label: हिंदी
|
||||||
active: true
|
|
||||||
- code: lv
|
|
||||||
label: Latviešu
|
|
||||||
active: true
|
active: true
|
||||||
- code: hu
|
- code: hu
|
||||||
label: Magyar
|
label: Magyar
|
||||||
active: true
|
active: true
|
||||||
|
- code: it
|
||||||
|
label: Italiano
|
||||||
|
active: true
|
||||||
|
- code: kk
|
||||||
|
label: Қазақ
|
||||||
|
active: true
|
||||||
|
- code: lv
|
||||||
|
label: Latviešu
|
||||||
|
active: true
|
||||||
- code: nl
|
- code: nl
|
||||||
label: Nederlands
|
label: Nederlands
|
||||||
active: true
|
active: true
|
||||||
@@ -208,8 +272,11 @@ languages:
|
|||||||
- code: pt-BR
|
- code: pt-BR
|
||||||
label: Português do Brasil
|
label: Português do Brasil
|
||||||
active: true
|
active: true
|
||||||
- code: fi
|
- code: sr-lat
|
||||||
label: Suomi
|
label: Srpski (lat)
|
||||||
|
active: true
|
||||||
|
- code: sr-cyr
|
||||||
|
label: Српски
|
||||||
active: true
|
active: true
|
||||||
- code: sv
|
- code: sv
|
||||||
label: Svenska
|
label: Svenska
|
||||||
@@ -217,24 +284,12 @@ languages:
|
|||||||
- code: tr
|
- code: tr
|
||||||
label: Türkçe
|
label: Türkçe
|
||||||
active: true
|
active: true
|
||||||
- code: vi
|
|
||||||
label: Tiếng Việt
|
|
||||||
active: true
|
|
||||||
- code: kk
|
|
||||||
label: Қазақ
|
|
||||||
active: true
|
|
||||||
- code: bn
|
|
||||||
label: বাংলা
|
|
||||||
active: true
|
|
||||||
- code: hi
|
|
||||||
label: हिंदी
|
|
||||||
active: true
|
|
||||||
- code: el
|
|
||||||
label: Ελληνικά
|
|
||||||
active: true
|
|
||||||
- code: uk
|
- code: uk
|
||||||
label: Yкраї́нська
|
label: Yкраї́нська
|
||||||
active: true
|
active: true
|
||||||
|
- code: vi
|
||||||
|
label: Tiếng Việt
|
||||||
|
active: true
|
||||||
|
|
||||||
|
|
||||||
# Browse-By Pages
|
# Browse-By Pages
|
||||||
@@ -292,33 +347,33 @@ themes:
|
|||||||
#
|
#
|
||||||
# # A theme with a handle property will match the community, collection or item with the given
|
# # A theme with a handle property will match the community, collection or item with the given
|
||||||
# # handle, and all collections and/or items within it
|
# # handle, and all collections and/or items within it
|
||||||
# - name: 'custom',
|
# - name: custom
|
||||||
# handle: '10673/1233'
|
# handle: 10673/1233
|
||||||
#
|
#
|
||||||
# # A theme with a regex property will match the route using a regular expression. If it
|
# # A theme with a regex property will match the route using a regular expression. If it
|
||||||
# # matches the route for a community or collection it will also apply to all collections
|
# # matches the route for a community or collection it will also apply to all collections
|
||||||
# # and/or items within it
|
# # and/or items within it
|
||||||
# - name: 'custom',
|
# - name: custom
|
||||||
# regex: 'collections\/e8043bc2.*'
|
# regex: collections\/e8043bc2.*
|
||||||
#
|
#
|
||||||
# # A theme with a uuid property will match the community, collection or item with the given
|
# # A theme with a uuid property will match the community, collection or item with the given
|
||||||
# # ID, and all collections and/or items within it
|
# # ID, and all collections and/or items within it
|
||||||
# - name: 'custom',
|
# - name: custom
|
||||||
# uuid: '0958c910-2037-42a9-81c7-dca80e3892b4'
|
# uuid: 0958c910-2037-42a9-81c7-dca80e3892b4
|
||||||
#
|
#
|
||||||
# # The extends property specifies an ancestor theme (by name). Whenever a themed component is not found
|
# # The extends property specifies an ancestor theme (by name). Whenever a themed component is not found
|
||||||
# # in the current theme, its ancestor theme(s) will be checked recursively before falling back to default.
|
# # in the current theme, its ancestor theme(s) will be checked recursively before falling back to default.
|
||||||
# - name: 'custom-A',
|
# - name: custom-A
|
||||||
# extends: 'custom-B',
|
# extends: custom-B
|
||||||
# # Any of the matching properties above can be used
|
# # Any of the matching properties above can be used
|
||||||
# handle: '10673/34'
|
# handle: 10673/34
|
||||||
#
|
#
|
||||||
# - name: 'custom-B',
|
# - name: custom-B
|
||||||
# extends: 'custom',
|
# extends: custom
|
||||||
# handle: '10673/12'
|
# handle: 10673/12
|
||||||
#
|
#
|
||||||
# # A theme with only a name will match every route
|
# # A theme with only a name will match every route
|
||||||
# name: 'custom'
|
# name: custom
|
||||||
#
|
#
|
||||||
# # This theme will use the default bootstrap styling for DSpace components
|
# # This theme will use the default bootstrap styling for DSpace components
|
||||||
# - name: BASE_THEME_NAME
|
# - name: BASE_THEME_NAME
|
||||||
@@ -376,7 +431,30 @@ vocabularies:
|
|||||||
vocabulary: 'srsc'
|
vocabulary: 'srsc'
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query.
|
# Default collection/community sorting order at Advanced search, Create/update community and collection when there are not a query.
|
||||||
comcolSelectionSort:
|
comcolSelectionSort:
|
||||||
sortField: 'dc.title'
|
sortField: 'dc.title'
|
||||||
sortDirection: 'ASC'
|
sortDirection: 'ASC'
|
||||||
|
|
||||||
|
# Live Region configuration
|
||||||
|
# Live Region as defined by w3c, https://www.w3.org/TR/wai-aria-1.1/#terms:
|
||||||
|
# Live regions are perceivable regions of a web page that are typically updated as a
|
||||||
|
# result of an external event when user focus may be elsewhere.
|
||||||
|
#
|
||||||
|
# The DSpace live region is a component present at the bottom of all pages that is invisible by default, but is useful
|
||||||
|
# for screen readers. Any message pushed to the live region will be announced by the screen reader. These messages
|
||||||
|
# usually contain information about changes on the page that might not be in focus.
|
||||||
|
liveRegion:
|
||||||
|
# The duration after which messages disappear from the live region in milliseconds
|
||||||
|
messageTimeOutDurationMs: 30000
|
||||||
|
# The visibility of the live region. Setting this to true is only useful for debugging purposes.
|
||||||
|
isVisible: false
|
||||||
|
|
||||||
|
|
||||||
|
# Search settings
|
||||||
|
search:
|
||||||
|
# Number used to render n UI elements called loading skeletons that act as placeholders.
|
||||||
|
# These elements indicate that some content will be loaded in their stead.
|
||||||
|
# Since we don't know how many filters will be loaded before we receive a response from the server we use this parameter for the skeletons count.
|
||||||
|
# e.g. If we set 5 then 5 loading skeletons will be visualized before the actual filters are retrieved.
|
||||||
|
defaultFiltersCount: 5
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
rest:
|
rest:
|
||||||
ssl: true
|
ssl: true
|
||||||
host: api7.dspace.org
|
host: demo.dspace.org
|
||||||
port: 443
|
port: 443
|
||||||
nameSpace: /server
|
nameSpace: /server
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { defineConfig } from 'cypress';
|
import { defineConfig } from 'cypress';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
video: true,
|
||||||
videosFolder: 'cypress/videos',
|
videosFolder: 'cypress/videos',
|
||||||
screenshotsFolder: 'cypress/screenshots',
|
screenshotsFolder: 'cypress/screenshots',
|
||||||
fixturesFolder: 'cypress/fixtures',
|
fixturesFolder: 'cypress/fixtures',
|
||||||
@@ -9,27 +10,33 @@ export default defineConfig({
|
|||||||
openMode: 0,
|
openMode: 0,
|
||||||
},
|
},
|
||||||
env: {
|
env: {
|
||||||
// Global constants used in DSpace e2e tests (see also ./cypress/support/e2e.ts)
|
// Global DSpace environment variables used in all our Cypress e2e tests
|
||||||
// May be overridden in our cypress.json config file using specified environment variables.
|
// May be modified in this config, or overridden in a variety of ways.
|
||||||
|
// See Cypress environment variable docs: https://docs.cypress.io/guides/guides/environment-variables
|
||||||
// Default values listed here are all valid for the Demo Entities Data set available at
|
// Default values listed here are all valid for the Demo Entities Data set available at
|
||||||
// https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
// https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
||||||
// (This is the data set used in our CI environment)
|
// (This is the data set used in our CI environment)
|
||||||
|
|
||||||
// Admin account used for administrative tests
|
// Admin account used for administrative tests
|
||||||
DSPACE_TEST_ADMIN_USER: 'dspacedemo+admin@gmail.com',
|
DSPACE_TEST_ADMIN_USER: 'dspacedemo+admin@gmail.com',
|
||||||
|
DSPACE_TEST_ADMIN_USER_UUID: '335647b6-8a52-4ecb-a8c1-7ebabb199bda',
|
||||||
DSPACE_TEST_ADMIN_PASSWORD: 'dspace',
|
DSPACE_TEST_ADMIN_PASSWORD: 'dspace',
|
||||||
// Community/collection/publication used for view/edit tests
|
// Community/collection/publication used for view/edit tests
|
||||||
DSPACE_TEST_COMMUNITY: '0958c910-2037-42a9-81c7-dca80e3892b4',
|
DSPACE_TEST_COMMUNITY: '0958c910-2037-42a9-81c7-dca80e3892b4',
|
||||||
DSPACE_TEST_COLLECTION: '282164f5-d325-4740-8dd1-fa4d6d3e7200',
|
DSPACE_TEST_COLLECTION: '282164f5-d325-4740-8dd1-fa4d6d3e7200',
|
||||||
DSPACE_TEST_ENTITY_PUBLICATION: 'e98b0f27-5c19-49a0-960d-eb6ad5287067',
|
DSPACE_TEST_ENTITY_PUBLICATION: '6160810f-1e53-40db-81ef-f6621a727398',
|
||||||
// Search term (should return results) used in search tests
|
// Search term (should return results) used in search tests
|
||||||
DSPACE_TEST_SEARCH_TERM: 'test',
|
DSPACE_TEST_SEARCH_TERM: 'test',
|
||||||
// Collection used for submission tests
|
// Main Collection used for submission tests. Should be able to accept normal Item objects
|
||||||
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Sample Collection',
|
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Sample Collection',
|
||||||
DSPACE_TEST_SUBMIT_COLLECTION_UUID: '9d8334e9-25d3-4a67-9cea-3dffdef80144',
|
DSPACE_TEST_SUBMIT_COLLECTION_UUID: '9d8334e9-25d3-4a67-9cea-3dffdef80144',
|
||||||
|
// Collection used for Person entity submission tests. MUST be configured with EntityType=Person.
|
||||||
|
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'People',
|
||||||
// Account used to test basic submission process
|
// Account used to test basic submission process
|
||||||
DSPACE_TEST_SUBMIT_USER: 'dspacedemo+submit@gmail.com',
|
DSPACE_TEST_SUBMIT_USER: 'dspacedemo+submit@gmail.com',
|
||||||
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',
|
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',
|
||||||
|
// Administrator users group
|
||||||
|
DSPACE_ADMINISTRATOR_GROUP: 'e59f5659-bff9-451e-b28f-439e7bd467e4'
|
||||||
},
|
},
|
||||||
e2e: {
|
e2e: {
|
||||||
// Setup our plugins for e2e tests
|
// Setup our plugins for e2e tests
|
||||||
|
54
cypress/e2e/admin-add-new-modals.cy.ts
Normal file
54
cypress/e2e/admin-add-new-modals.cy.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Add New Modals', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin for sidebar to appear
|
||||||
|
cy.visit('/login');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Add new Community modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-new-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-new-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.new_community"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-create-community-parent-selector> for accessibility
|
||||||
|
testA11y('ds-create-community-parent-selector');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Add new Collection modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-new-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-new-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.new_collection"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-create-collection-parent-selector> for accessibility
|
||||||
|
testA11y('ds-create-collection-parent-selector');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Add new Item modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-new-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-new-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.new_item"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-create-item-parent-selector> for accessibility
|
||||||
|
testA11y('ds-create-item-parent-selector');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/admin-curation-tasks.cy.ts
Normal file
16
cypress/e2e/admin-curation-tasks.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Curation Tasks', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/curation-tasks');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-admin-curation-task').should('be.visible');
|
||||||
|
// Analyze <ds-admin-curation-task> for accessibility issues
|
||||||
|
testA11y('ds-admin-curation-task');
|
||||||
|
});
|
||||||
|
});
|
54
cypress/e2e/admin-edit-modals.cy.ts
Normal file
54
cypress/e2e/admin-edit-modals.cy.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Edit Modals', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin for sidebar to appear
|
||||||
|
cy.visit('/login');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Edit Community modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-edit-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-edit-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.edit_community"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-edit-community-selector> for accessibility
|
||||||
|
testA11y('ds-edit-community-selector');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Edit Collection modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-edit-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-edit-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.edit_collection"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-edit-collection-selector> for accessibility
|
||||||
|
testA11y('ds-edit-collection-selector');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Edit Item modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-edit-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-edit-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.edit_item"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-edit-item-selector> for accessibility
|
||||||
|
testA11y('ds-edit-item-selector');
|
||||||
|
});
|
||||||
|
});
|
39
cypress/e2e/admin-export-modals.cy.ts
Normal file
39
cypress/e2e/admin-export-modals.cy.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Export Modals', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin for sidebar to appear
|
||||||
|
cy.visit('/login');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Export metadata modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-export-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-export-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.export_metadata"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-export-metadata-selector> for accessibility
|
||||||
|
testA11y('ds-export-metadata-selector');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Export batch modal should pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').trigger('mouseover');
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on entry of menu
|
||||||
|
cy.get('#admin-menu-section-export-title').should('be.visible');
|
||||||
|
cy.get('#admin-menu-section-export-title').click();
|
||||||
|
|
||||||
|
cy.get('a[data-test="menu.section.export_batch"]').click();
|
||||||
|
|
||||||
|
// Analyze <ds-export-batch-selector> for accessibility
|
||||||
|
testA11y('ds-export-metadata-selector');
|
||||||
|
});
|
||||||
|
});
|
21
cypress/e2e/admin-search-page.cy.ts
Normal file
21
cypress/e2e/admin-search-page.cy.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Search Page', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/search');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
//Page must first be visible
|
||||||
|
cy.get('ds-admin-search-page').should('be.visible');
|
||||||
|
// At least one search result should be displayed
|
||||||
|
cy.get('[data-test="list-object"]').should('be.visible');
|
||||||
|
// Click each filter toggle to open *every* filter
|
||||||
|
// (As we want to scan filter section for accessibility issues as well)
|
||||||
|
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
||||||
|
// Analyze <ds-admin-search-page> for accessibility issues
|
||||||
|
testA11y('ds-admin-search-page');
|
||||||
|
});
|
||||||
|
});
|
28
cypress/e2e/admin-sidebar.cy.ts
Normal file
28
cypress/e2e/admin-sidebar.cy.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { Options } from 'cypress-axe';
|
||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Sidebar', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin for sidebar to appear
|
||||||
|
cy.visit('/login');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be pinnable and pass accessibility tests', () => {
|
||||||
|
// Pin the sidebar open
|
||||||
|
cy.get('#sidebar-collapse-toggle').click();
|
||||||
|
|
||||||
|
// Click on every expandable section to open all menus
|
||||||
|
cy.get('ds-expandable-admin-sidebar-section').click({multiple: true});
|
||||||
|
|
||||||
|
// Analyze <ds-admin-sidebar> for accessibility
|
||||||
|
testA11y('ds-admin-sidebar',
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// Currently all expandable sections have nested interactive elements
|
||||||
|
// See https://github.com/DSpace/dspace-angular/issues/2178
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
}
|
||||||
|
} as Options);
|
||||||
|
});
|
||||||
|
});
|
21
cypress/e2e/admin-workflow-page.cy.ts
Normal file
21
cypress/e2e/admin-workflow-page.cy.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Admin Workflow Page', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/workflow');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-admin-workflow-page').should('be.visible');
|
||||||
|
// At least one search result should be displayed
|
||||||
|
cy.get('[data-test="list-object"]').should('be.visible');
|
||||||
|
// Click each filter toggle to open *every* filter
|
||||||
|
// (As we want to scan filter section for accessibility issues as well)
|
||||||
|
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
||||||
|
// Analyze <ds-admin-workflow-page> for accessibility issues
|
||||||
|
testA11y('ds-admin-workflow-page');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/batch-import-page.cy.ts
Normal file
16
cypress/e2e/batch-import-page.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Batch Import Page', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see processes
|
||||||
|
cy.visit('/admin/batch-import');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Batch import form must first be visible
|
||||||
|
cy.get('ds-batch-import-page').should('be.visible');
|
||||||
|
// Analyze <ds-batch-import-page> for accessibility issues
|
||||||
|
testA11y('ds-batch-import-page');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/bitstreams-format.cy.ts
Normal file
16
cypress/e2e/bitstreams-format.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Bitstreams Formats', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/registries/bitstream-formats');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-bitstream-formats').should('be.visible');
|
||||||
|
// Analyze <ds-bitstream-formats> for accessibility issues
|
||||||
|
testA11y('ds-bitstream-formats');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,10 +1,9 @@
|
|||||||
import { TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Breadcrumbs', () => {
|
describe('Breadcrumbs', () => {
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
// Visit an Item, as those have more breadcrumbs
|
// Visit an Item, as those have more breadcrumbs
|
||||||
cy.visit('/entities/publication/'.concat(TEST_ENTITY_PUBLICATION));
|
cy.visit('/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')));
|
||||||
|
|
||||||
// Wait for breadcrumbs to be visible
|
// Wait for breadcrumbs to be visible
|
||||||
cy.get('ds-breadcrumbs').should('be.visible');
|
cy.get('ds-breadcrumbs').should('be.visible');
|
||||||
|
31
cypress/e2e/bulk-access.cy.ts
Normal file
31
cypress/e2e/bulk-access.cy.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
import { Options } from 'cypress-axe';
|
||||||
|
|
||||||
|
describe('Bulk Access', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/bulk-access');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-bulk-access').should('be.visible');
|
||||||
|
// At least one search result should be displayed
|
||||||
|
cy.get('[data-test="list-object"]').should('be.visible');
|
||||||
|
// Click each filter toggle to open *every* filter
|
||||||
|
// (As we want to scan filter section for accessibility issues as well)
|
||||||
|
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
||||||
|
// Analyze <ds-bulk-access> for accessibility issues
|
||||||
|
testA11y('ds-bulk-access', {
|
||||||
|
rules: {
|
||||||
|
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
|
||||||
|
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'aria-required-children': { enabled: false },
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
// Card titles fail this test currently
|
||||||
|
'heading-order': { enabled: false },
|
||||||
|
},
|
||||||
|
} as Options);
|
||||||
|
});
|
||||||
|
});
|
128
cypress/e2e/collection-edit.cy.ts
Normal file
128
cypress/e2e/collection-edit.cy.ts
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
const COLLECTION_EDIT_PAGE = '/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('/edit');
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// All tests start with visiting the Edit Collection Page
|
||||||
|
cy.visit(COLLECTION_EDIT_PAGE);
|
||||||
|
|
||||||
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Edit Metadata tab', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// <ds-edit-collection> tag must be loaded
|
||||||
|
cy.get('ds-edit-collection').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-edit-collection> for accessibility issues
|
||||||
|
testA11y('ds-edit-collection');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Assign Roles tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="roles"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-roles> tag must be loaded
|
||||||
|
cy.get('ds-collection-roles').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-collection-roles');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Content Source tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="source"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-source> tag must be loaded
|
||||||
|
cy.get('ds-collection-source').should('be.visible');
|
||||||
|
|
||||||
|
// Check the external source checkbox (to display all fields on the page)
|
||||||
|
cy.get('#externalSourceCheck').check();
|
||||||
|
|
||||||
|
// Wait for the source controls to appear
|
||||||
|
// cy.get('ds-collection-source-controls').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze entire page for accessibility issues
|
||||||
|
testA11y('ds-collection-source');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Curate tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="curate"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-curate> tag must be loaded
|
||||||
|
cy.get('ds-collection-curate').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-collection-curate');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Access Control tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="access-control"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-access-control> tag must be loaded
|
||||||
|
cy.get('ds-collection-access-control').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-collection-access-control');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Authorizations tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="authorizations"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-authorizations> tag must be loaded
|
||||||
|
cy.get('ds-collection-authorizations').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-collection-authorizations');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Collection > Item Mapper tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="mapper"]').click();
|
||||||
|
|
||||||
|
// <ds-collection-item-mapper> tag must be loaded
|
||||||
|
cy.get('ds-collection-item-mapper').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze entire page for accessibility issues
|
||||||
|
testA11y('ds-collection-item-mapper');
|
||||||
|
|
||||||
|
// Click on the "Map new Items" tab
|
||||||
|
cy.get('li[data-test="mapTab"] a').click();
|
||||||
|
|
||||||
|
// Make sure search form is now visible
|
||||||
|
cy.get('ds-search-form').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze entire page (again) for accessibility issues
|
||||||
|
testA11y('ds-collection-item-mapper');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('Edit Collection > Delete page', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="delete-button"]').click();
|
||||||
|
|
||||||
|
// <ds-delete-collection> tag must be loaded
|
||||||
|
cy.get('ds-delete-collection').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-delete-collection');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,15 +1,21 @@
|
|||||||
import { TEST_COLLECTION } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Collection Page', () => {
|
describe('Collection Page', () => {
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
cy.visit('/collections/'.concat(TEST_COLLECTION));
|
cy.intercept('POST', '/server/api/statistics/viewevents').as('viewevent');
|
||||||
|
|
||||||
// <ds-collection-page> tag must be loaded
|
// Visit Collections page
|
||||||
cy.get('ds-collection-page').should('be.visible');
|
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
|
||||||
|
|
||||||
// Analyze <ds-collection-page> for accessibility issues
|
// Wait for the "viewevent" to trigger on the Collection page.
|
||||||
testA11y('ds-collection-page');
|
// This ensures our <ds-collection-page> tag is fully loaded, as the <ds-view-event> tag is contained within it.
|
||||||
});
|
cy.wait('@viewevent');
|
||||||
|
|
||||||
|
// <ds-collection-page> tag must be loaded
|
||||||
|
cy.get('ds-collection-page').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-collection-page> for accessibility issues
|
||||||
|
testA11y('ds-collection-page');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COLLECTION } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Collection Statistics Page', () => {
|
describe('Collection Statistics Page', () => {
|
||||||
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(TEST_COLLECTION);
|
const COLLECTIONSTATISTICSPAGE = '/statistics/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION'));
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from a Collection page', () => {
|
it('should load if you click on "Statistics" from a Collection page', () => {
|
||||||
cy.visit('/collections/'.concat(TEST_COLLECTION));
|
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('ds-navbar ds-link-menu-item a[data-test="link-menu-item.menu.section.statistics"]').click();
|
||||||
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
|
cy.location('pathname').should('eq', COLLECTIONSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ describe('Collection Statistics Page', () => {
|
|||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(COLLECTIONSTATISTICSPAGE);
|
cy.visit(COLLECTIONSTATISTICSPAGE);
|
||||||
// Check just for existence because this table is empty in CI environment as it's historical data
|
// Check just for existence because this table is empty in CI environment as it's historical data
|
||||||
cy.get('.'.concat(TEST_COLLECTION).concat('_TotalVisitsPerMonth')).should('exist');
|
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COLLECTION')).concat('_TotalVisitsPerMonth')).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
|
86
cypress/e2e/community-edit.cy.ts
Normal file
86
cypress/e2e/community-edit.cy.ts
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
const COMMUNITY_EDIT_PAGE = '/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('/edit');
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// All tests start with visiting the Edit Community Page
|
||||||
|
cy.visit(COMMUNITY_EDIT_PAGE);
|
||||||
|
|
||||||
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Edit Metadata tab', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// <ds-edit-community> tag must be loaded
|
||||||
|
cy.get('ds-edit-community').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-edit-community> for accessibility issues
|
||||||
|
testA11y('ds-edit-community');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Assign Roles tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="roles"]').click();
|
||||||
|
|
||||||
|
// <ds-community-roles> tag must be loaded
|
||||||
|
cy.get('ds-community-roles').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-community-roles');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Curate tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="curate"]').click();
|
||||||
|
|
||||||
|
// <ds-community-curate> tag must be loaded
|
||||||
|
cy.get('ds-community-curate').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-community-curate');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Access Control tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="access-control"]').click();
|
||||||
|
|
||||||
|
// <ds-community-access-control> tag must be loaded
|
||||||
|
cy.get('ds-community-access-control').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-community-access-control');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Authorizations tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="authorizations"]').click();
|
||||||
|
|
||||||
|
// <ds-community-authorizations> tag must be loaded
|
||||||
|
cy.get('ds-community-authorizations').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-community-authorizations');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Community > Delete page', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="delete-button"]').click();
|
||||||
|
|
||||||
|
// <ds-delete-community> tag must be loaded
|
||||||
|
cy.get('ds-delete-community').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-delete-community');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,4 +1,3 @@
|
|||||||
import { Options } from 'cypress-axe';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Community List Page', () => {
|
describe('Community List Page', () => {
|
||||||
@@ -13,13 +12,6 @@ describe('Community List Page', () => {
|
|||||||
cy.get('[data-test="expand-button"]').click({ multiple: true });
|
cy.get('[data-test="expand-button"]').click({ multiple: true });
|
||||||
|
|
||||||
// Analyze <ds-community-list-page> for accessibility issues
|
// Analyze <ds-community-list-page> for accessibility issues
|
||||||
// Disable heading-order checks until it is fixed
|
testA11y('ds-community-list-page');
|
||||||
testA11y('ds-community-list-page',
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
'heading-order': { enabled: false }
|
|
||||||
}
|
|
||||||
} as Options
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
import { TEST_COMMUNITY } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Community Page', () => {
|
describe('Community Page', () => {
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
cy.visit('/communities/'.concat(TEST_COMMUNITY));
|
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
|
||||||
|
|
||||||
// <ds-community-page> tag must be loaded
|
// <ds-community-page> tag must be loaded
|
||||||
cy.get('ds-community-page').should('be.visible');
|
cy.get('ds-community-page').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-community-page> for accessibility issues
|
// Analyze <ds-community-page> for accessibility issues
|
||||||
testA11y('ds-community-page',);
|
testA11y('ds-community-page');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_COMMUNITY } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Community Statistics Page', () => {
|
describe('Community Statistics Page', () => {
|
||||||
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(TEST_COMMUNITY);
|
const COMMUNITYSTATISTICSPAGE = '/statistics/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY'));
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from a Community page', () => {
|
it('should load if you click on "Statistics" from a Community page', () => {
|
||||||
cy.visit('/communities/'.concat(TEST_COMMUNITY));
|
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('a[data-test="link-menu-item.menu.section.statistics"]').click();
|
||||||
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
|
cy.location('pathname').should('eq', COMMUNITYSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ describe('Community Statistics Page', () => {
|
|||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(COMMUNITYSTATISTICSPAGE);
|
cy.visit(COMMUNITYSTATISTICSPAGE);
|
||||||
// Check just for existence because this table is empty in CI environment as it's historical data
|
// Check just for existence because this table is empty in CI environment as it's historical data
|
||||||
cy.get('.'.concat(TEST_COMMUNITY).concat('_TotalVisitsPerMonth')).should('exist');
|
cy.get('.'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')).concat('_TotalVisitsPerMonth')).should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
|
16
cypress/e2e/create-eperson.cy.ts
Normal file
16
cypress/e2e/create-eperson.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Create Eperson', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/epeople/create');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Form must first be visible
|
||||||
|
cy.get('ds-eperson-form').should('be.visible');
|
||||||
|
// Analyze <ds-eperson-form> for accessibility issues
|
||||||
|
testA11y('ds-eperson-form');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/create-group.cy.ts
Normal file
16
cypress/e2e/create-group.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Create Group', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/groups/create');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Form must first be visible
|
||||||
|
cy.get('ds-group-form').should('be.visible');
|
||||||
|
// Analyze <ds-group-form> for accessibility issues
|
||||||
|
testA11y('ds-group-form');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/edit-eperson.cy.ts
Normal file
16
cypress/e2e/edit-eperson.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Edit Eperson', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/epeople/'.concat(Cypress.env('DSPACE_TEST_ADMIN_USER_UUID')).concat('/edit'));
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Form must first be visible
|
||||||
|
cy.get('ds-eperson-form').should('be.visible');
|
||||||
|
// Analyze <ds-eperson-form> for accessibility issues
|
||||||
|
testA11y('ds-eperson-form');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/edit-group.cy.ts
Normal file
16
cypress/e2e/edit-group.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Edit Group', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/groups/'.concat(Cypress.env('DSPACE_ADMINISTRATOR_GROUP')).concat('/edit'));
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Form must first be visible
|
||||||
|
cy.get('ds-group-form').should('be.visible');
|
||||||
|
// Analyze <ds-group-form> for accessibility issues
|
||||||
|
testA11y('ds-group-form');
|
||||||
|
});
|
||||||
|
});
|
13
cypress/e2e/end-user-agreement.cy.ts
Normal file
13
cypress/e2e/end-user-agreement.cy.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('End User Agreement', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.visit('/info/end-user-agreement');
|
||||||
|
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-end-user-agreement').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-end-user-agreement> for accessibility
|
||||||
|
testA11y('ds-end-user-agreement');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/epeople-registry.cy.ts
Normal file
16
cypress/e2e/epeople-registry.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Epeople registry', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/epeople');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Epeople registry page must first be visible
|
||||||
|
cy.get('ds-epeople-registry').should('be.visible');
|
||||||
|
// Analyze <ds-epeople-registry> for accessibility issues
|
||||||
|
testA11y('ds-epeople-registry');
|
||||||
|
});
|
||||||
|
});
|
13
cypress/e2e/feedback.cy.ts
Normal file
13
cypress/e2e/feedback.cy.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Feedback', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.visit('/info/feedback');
|
||||||
|
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-feedback').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-feedback> for accessibility
|
||||||
|
testA11y('ds-feedback');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/groups-registry.cy.ts
Normal file
16
cypress/e2e/groups-registry.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Groups registry', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/access-control/groups');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Epeople registry page must first be visible
|
||||||
|
cy.get('ds-groups-registry').should('be.visible');
|
||||||
|
// Analyze <ds-groups-registry> for accessibility issues
|
||||||
|
testA11y('ds-groups-registry');
|
||||||
|
});
|
||||||
|
});
|
@@ -8,12 +8,31 @@ describe('Header', () => {
|
|||||||
cy.get('ds-header').should('be.visible');
|
cy.get('ds-header').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-header> for accessibility
|
// Analyze <ds-header> for accessibility
|
||||||
testA11y({
|
testA11y('ds-header');
|
||||||
include: ['ds-header'],
|
});
|
||||||
exclude: [
|
|
||||||
['#search-navbar-container'], // search in navbar has duplicative ID. Will be fixed in #1174
|
it('should allow for changing language to German (for example)', () => {
|
||||||
['.dropdownLogin'] // "Log in" link has color contrast issues. Will be fixed in #1149
|
cy.visit('/');
|
||||||
],
|
|
||||||
});
|
// Click the language switcher (globe) in header
|
||||||
|
cy.get('a[data-test="lang-switch"]').click();
|
||||||
|
// Click on the "Deusch" language in dropdown
|
||||||
|
cy.get('#language-menu-list li').contains('Deutsch').click();
|
||||||
|
|
||||||
|
// HTML "lang" attribute should switch to "de"
|
||||||
|
cy.get('html').invoke('attr', 'lang').should('eq', 'de');
|
||||||
|
|
||||||
|
// Login menu should now be in German
|
||||||
|
cy.get('a[data-test="login-menu"]').contains('Anmelden');
|
||||||
|
|
||||||
|
// Change back to English from language switcher
|
||||||
|
cy.get('a[data-test="lang-switch"]').click();
|
||||||
|
cy.get('#language-menu-list li').contains('English').click();
|
||||||
|
|
||||||
|
// HTML "lang" attribute should switch to "en"
|
||||||
|
cy.get('html').invoke('attr', 'lang').should('eq', 'en');
|
||||||
|
|
||||||
|
// Login menu should now be in English
|
||||||
|
cy.get('a[data-test="login-menu"]').contains('Log In');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
62
cypress/e2e/health-page.cy.ts
Normal file
62
cypress/e2e/health-page.cy.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
import { Options } from 'cypress-axe';
|
||||||
|
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/health');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Health Page > Status Tab', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.intercept('GET', '/server/actuator/health').as('status');
|
||||||
|
cy.wait('@status');
|
||||||
|
|
||||||
|
cy.get('a[data-test="health-page.status-tab"]').click();
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-health-page').should('be.visible');
|
||||||
|
cy.get('ds-health-panel').should('be.visible');
|
||||||
|
|
||||||
|
// wait for all the ds-health-info-component components to be rendered
|
||||||
|
cy.get('div[role="tabpanel"]').each(($panel: HTMLDivElement) => {
|
||||||
|
cy.wrap($panel).find('ds-health-component').should('be.visible');
|
||||||
|
});
|
||||||
|
// Analyze <ds-health-page> for accessibility issues
|
||||||
|
testA11y('ds-health-page', {
|
||||||
|
rules: {
|
||||||
|
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
|
||||||
|
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'aria-required-children': { enabled: false },
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
},
|
||||||
|
} as Options);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Health Page > Info Tab', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.intercept('GET', '/server/actuator/info').as('info');
|
||||||
|
cy.wait('@info');
|
||||||
|
|
||||||
|
cy.get('a[data-test="health-page.info-tab"]').click();
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-health-page').should('be.visible');
|
||||||
|
cy.get('ds-health-info').should('be.visible');
|
||||||
|
|
||||||
|
// wait for all the ds-health-info-component components to be rendered
|
||||||
|
cy.get('div[role="tabpanel"]').each(($panel: HTMLDivElement) => {
|
||||||
|
cy.wrap($panel).find('ds-health-info-component').should('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Analyze <ds-health-info> for accessibility issues
|
||||||
|
testA11y('ds-health-info', {
|
||||||
|
rules: {
|
||||||
|
// All panels are accordions & fail "aria-required-children" and "nested-interactive".
|
||||||
|
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'aria-required-children': { enabled: false },
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
},
|
||||||
|
} as Options);
|
||||||
|
});
|
||||||
|
});
|
@@ -1,18 +1,18 @@
|
|||||||
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
import '../support/commands';
|
import '../support/commands';
|
||||||
|
|
||||||
describe('Site Statistics Page', () => {
|
describe('Site Statistics Page', () => {
|
||||||
it('should load if you click on "Statistics" from homepage', () => {
|
it('should load if you click on "Statistics" from homepage', () => {
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('a[data-test="link-menu-item.menu.section.statistics"]').click();
|
||||||
cy.location('pathname').should('eq', '/statistics');
|
cy.location('pathname').should('eq', '/statistics');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
// generate 2 view events on an Item's page
|
// generate 2 view events on an Item's page
|
||||||
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
|
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');
|
||||||
cy.generateViewEvent(TEST_ENTITY_PUBLICATION, 'item');
|
cy.generateViewEvent(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'), 'item');
|
||||||
|
|
||||||
cy.visit('/statistics');
|
cy.visit('/statistics');
|
||||||
|
|
||||||
|
180
cypress/e2e/item-edit.cy.ts
Normal file
180
cypress/e2e/item-edit.cy.ts
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
import { Options } from 'cypress-axe';
|
||||||
|
|
||||||
|
const ITEM_EDIT_PAGE = '/items/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')).concat('/edit');
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// All tests start with visiting the Edit Item Page
|
||||||
|
cy.visit(ITEM_EDIT_PAGE);
|
||||||
|
|
||||||
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Edit Metadata tab', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="metadata"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="metadata"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="metadata"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="metadata"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-edit-item-page> tag must be loaded
|
||||||
|
cy.get('ds-edit-item-page').should('be.visible');
|
||||||
|
|
||||||
|
// wait for all the ds-dso-edit-metadata-value components to be rendered
|
||||||
|
cy.get('ds-dso-edit-metadata-value div[role="row"]').each(($row: HTMLDivElement) => {
|
||||||
|
cy.wrap($row).find('div[role="cell"]').should('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Analyze <ds-edit-item-page> for accessibility issues
|
||||||
|
testA11y('ds-edit-item-page');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Status tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="status"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="status"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="status"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="status"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-status> tag must be loaded
|
||||||
|
cy.get('ds-item-status').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-status');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Bitstreams tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="bitstreams"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="bitstreams"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="bitstreams"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="bitstreams"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-bitstreams> tag must be loaded
|
||||||
|
cy.get('ds-item-bitstreams').should('be.visible');
|
||||||
|
|
||||||
|
// Table of item bitstreams must also be loaded
|
||||||
|
cy.get('div.item-bitstreams').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-bitstreams',
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// Currently Bitstreams page loads a pagination component per Bundle
|
||||||
|
// and they all use the same 'id="p-dad"'.
|
||||||
|
'duplicate-id': { enabled: false },
|
||||||
|
},
|
||||||
|
} as Options,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Curate tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="curate"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="curate"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="curate"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="curate"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-curate> tag must be loaded
|
||||||
|
cy.get('ds-item-curate').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-curate');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Relationships tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="relationships"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="relationships"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="relationships"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="relationships"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-relationships> tag must be loaded
|
||||||
|
cy.get('ds-item-relationships').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-relationships');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Version History tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="versionhistory"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="versionhistory"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="versionhistory"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="versionhistory"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-version-history> tag must be loaded
|
||||||
|
cy.get('ds-item-version-history').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-version-history');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Access Control tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="access-control"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="access-control"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="access-control"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="access-control"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-access-control> tag must be loaded
|
||||||
|
cy.get('ds-item-access-control').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze for accessibility issues
|
||||||
|
testA11y('ds-item-access-control');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Edit Item > Collection Mapper tab', () => {
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.get('a[data-test="mapper"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="mapper"]').click();
|
||||||
|
|
||||||
|
// Our selected tab should be both visible & active
|
||||||
|
cy.get('a[data-test="mapper"]').should('be.visible');
|
||||||
|
cy.get('a[data-test="mapper"]').should('have.class', 'active');
|
||||||
|
|
||||||
|
// <ds-item-collection-mapper> tag must be loaded
|
||||||
|
cy.get('ds-item-collection-mapper').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze entire page for accessibility issues
|
||||||
|
testA11y('ds-item-collection-mapper');
|
||||||
|
|
||||||
|
// Click on the "Map new collections" tab
|
||||||
|
cy.get('li[data-test="mapTab"] a').click();
|
||||||
|
|
||||||
|
// Make sure search form is now visible
|
||||||
|
cy.get('ds-search-form').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze entire page (again) for accessibility issues
|
||||||
|
testA11y('ds-item-collection-mapper');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,31 +1,45 @@
|
|||||||
import { Options } from 'cypress-axe';
|
|
||||||
import { TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Item Page', () => {
|
describe('Item Page', () => {
|
||||||
const ITEMPAGE = '/items/'.concat(TEST_ENTITY_PUBLICATION);
|
const ITEMPAGE = '/items/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'));
|
||||||
const ENTITYPAGE = '/entities/publication/'.concat(TEST_ENTITY_PUBLICATION);
|
const ENTITYPAGE = '/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'));
|
||||||
|
|
||||||
// Test that entities will redirect to /entities/[type]/[uuid] when accessed via /items/[uuid]
|
// Test that entities will redirect to /entities/[type]/[uuid] when accessed via /items/[uuid]
|
||||||
it('should redirect to the entity page when navigating to an item page', () => {
|
it('should redirect to the entity page when navigating to an item page', () => {
|
||||||
cy.visit(ITEMPAGE);
|
cy.visit(ITEMPAGE);
|
||||||
|
cy.wait(1000);
|
||||||
cy.location('pathname').should('eq', ENTITYPAGE);
|
cy.location('pathname').should('eq', ENTITYPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.intercept('POST', '/server/api/statistics/viewevents').as('viewevent');
|
||||||
|
|
||||||
cy.visit(ENTITYPAGE);
|
cy.visit(ENTITYPAGE);
|
||||||
|
|
||||||
|
// Wait for the "viewevent" to trigger on the Item page.
|
||||||
|
// This ensures our <ds-item-page> tag is fully loaded, as the <ds-view-event> tag is contained within it.
|
||||||
|
cy.wait('@viewevent');
|
||||||
|
|
||||||
// <ds-item-page> tag must be loaded
|
// <ds-item-page> tag must be loaded
|
||||||
cy.get('ds-item-page').should('be.visible');
|
cy.get('ds-item-page').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-item-page> for accessibility issues
|
// Analyze <ds-item-page> for accessibility issues
|
||||||
// Disable heading-order checks until it is fixed
|
testA11y('ds-item-page');
|
||||||
testA11y('ds-item-page',
|
});
|
||||||
{
|
|
||||||
rules: {
|
it('should pass accessibility tests on full item page', () => {
|
||||||
'heading-order': { enabled: false }
|
cy.intercept('POST', '/server/api/statistics/viewevents').as('viewevent');
|
||||||
}
|
|
||||||
} as Options
|
cy.visit(ENTITYPAGE + '/full');
|
||||||
);
|
|
||||||
|
// Wait for the "viewevent" to trigger on the Item page.
|
||||||
|
// This ensures our <ds-item-page> tag is fully loaded, as the <ds-view-event> tag is contained within it.
|
||||||
|
cy.wait('@viewevent');
|
||||||
|
|
||||||
|
// <ds-full-item-page> tag must be loaded
|
||||||
|
cy.get('ds-full-item-page').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-full-item-page> for accessibility issues
|
||||||
|
testA11y('ds-full-item-page');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import { REGEX_MATCH_NON_EMPTY_TEXT, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
import { REGEX_MATCH_NON_EMPTY_TEXT } from 'cypress/support/e2e';
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Item Statistics Page', () => {
|
describe('Item Statistics Page', () => {
|
||||||
const ITEMSTATISTICSPAGE = '/statistics/items/'.concat(TEST_ENTITY_PUBLICATION);
|
const ITEMSTATISTICSPAGE = '/statistics/items/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'));
|
||||||
|
|
||||||
it('should load if you click on "Statistics" from an Item/Entity page', () => {
|
it('should load if you click on "Statistics" from an Item/Entity page', () => {
|
||||||
cy.visit('/entities/publication/'.concat(TEST_ENTITY_PUBLICATION));
|
cy.visit('/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION')));
|
||||||
cy.get('ds-navbar ds-link-menu-item a[title="Statistics"]').click();
|
cy.get('a[data-test="link-menu-item.menu.section.statistics"]').click();
|
||||||
cy.location('pathname').should('eq', ITEMSTATISTICSPAGE);
|
cy.location('pathname').should('eq', ITEMSTATISTICSPAGE);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,8 +23,7 @@ describe('Item Statistics Page', () => {
|
|||||||
|
|
||||||
it('should contain a "Total visits per month" section', () => {
|
it('should contain a "Total visits per month" section', () => {
|
||||||
cy.visit(ITEMSTATISTICSPAGE);
|
cy.visit(ITEMSTATISTICSPAGE);
|
||||||
// Check just for existence because this table is empty in CI environment as it's historical data
|
cy.get('table[data-test="TotalVisitsPerMonth"]').should('be.visible');
|
||||||
cy.get('.'.concat(TEST_ENTITY_PUBLICATION).concat('_TotalVisitsPerMonth')).should('exist');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should pass accessibility tests', () => {
|
it('should pass accessibility tests', () => {
|
||||||
|
@@ -1,42 +1,42 @@
|
|||||||
import { TEST_ADMIN_PASSWORD, TEST_ADMIN_USER, TEST_ENTITY_PUBLICATION } from 'cypress/support/e2e';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
const page = {
|
const page = {
|
||||||
openLoginMenu() {
|
openLoginMenu() {
|
||||||
// Click the "Log In" dropdown menu in header
|
// Click the "Log In" dropdown menu in header
|
||||||
cy.get('ds-themed-navbar [data-test="login-menu"]').click();
|
cy.get('[data-test="login-menu"]').click();
|
||||||
},
|
},
|
||||||
openUserMenu() {
|
openUserMenu() {
|
||||||
// Once logged in, click the User menu in header
|
// Once logged in, click the User menu in header
|
||||||
cy.get('ds-themed-navbar [data-test="user-menu"]').click();
|
cy.get('[data-test="user-menu"]').click();
|
||||||
},
|
},
|
||||||
submitLoginAndPasswordByPressingButton(email, password) {
|
submitLoginAndPasswordByPressingButton(email, password) {
|
||||||
// Enter email
|
// Enter email
|
||||||
cy.get('ds-themed-navbar [data-test="email"]').type(email);
|
cy.get('[data-test="email"]').type(email);
|
||||||
// Enter password
|
// Enter password
|
||||||
cy.get('ds-themed-navbar [data-test="password"]').type(password);
|
cy.get('[data-test="password"]').type(password);
|
||||||
// Click login button
|
// Click login button
|
||||||
cy.get('ds-themed-navbar [data-test="login-button"]').click();
|
cy.get('[data-test="login-button"]').click();
|
||||||
},
|
},
|
||||||
submitLoginAndPasswordByPressingEnter(email, password) {
|
submitLoginAndPasswordByPressingEnter(email, password) {
|
||||||
// In opened Login modal, fill out email & password, then click Enter
|
// In opened Login modal, fill out email & password, then click Enter
|
||||||
cy.get('ds-themed-navbar [data-test="email"]').type(email);
|
cy.get('[data-test="email"]').type(email);
|
||||||
cy.get('ds-themed-navbar [data-test="password"]').type(password);
|
cy.get('[data-test="password"]').type(password);
|
||||||
cy.get('ds-themed-navbar [data-test="password"]').type('{enter}');
|
cy.get('[data-test="password"]').type('{enter}');
|
||||||
},
|
},
|
||||||
submitLogoutByPressingButton() {
|
submitLogoutByPressingButton() {
|
||||||
// This is the POST command that will actually log us out
|
// This is the POST command that will actually log us out
|
||||||
cy.intercept('POST', '/server/api/authn/logout').as('logout');
|
cy.intercept('POST', '/server/api/authn/logout').as('logout');
|
||||||
// Click logout button
|
// Click logout button
|
||||||
cy.get('ds-themed-navbar [data-test="logout-button"]').click();
|
cy.get('[data-test="logout-button"]').click();
|
||||||
// Wait until above POST command responds before continuing
|
// Wait until above POST command responds before continuing
|
||||||
// (This ensures next action waits until logout completes)
|
// (This ensures next action waits until logout completes)
|
||||||
cy.wait('@logout');
|
cy.wait('@logout');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Login Modal', () => {
|
describe('Login Modal', () => {
|
||||||
it('should login when clicking button & stay on same page', () => {
|
it('should login when clicking button & stay on same page', () => {
|
||||||
const ENTITYPAGE = '/entities/publication/'.concat(TEST_ENTITY_PUBLICATION);
|
const ENTITYPAGE = '/entities/publication/'.concat(Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION'));
|
||||||
cy.visit(ENTITYPAGE);
|
cy.visit(ENTITYPAGE);
|
||||||
|
|
||||||
// Login menu should exist
|
// Login menu should exist
|
||||||
@@ -46,7 +46,7 @@ describe('Login Modal', () => {
|
|||||||
page.openLoginMenu();
|
page.openLoginMenu();
|
||||||
cy.get('.form-login').should('be.visible');
|
cy.get('.form-login').should('be.visible');
|
||||||
|
|
||||||
page.submitLoginAndPasswordByPressingButton(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
page.submitLoginAndPasswordByPressingButton(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
cy.get('ds-log-in').should('not.exist');
|
cy.get('ds-log-in').should('not.exist');
|
||||||
|
|
||||||
// Verify we are still on the same page
|
// Verify we are still on the same page
|
||||||
@@ -66,8 +66,8 @@ describe('Login Modal', () => {
|
|||||||
cy.get('.form-login').should('be.visible');
|
cy.get('.form-login').should('be.visible');
|
||||||
|
|
||||||
// Login, and the <ds-log-in> tag should no longer exist
|
// Login, and the <ds-log-in> tag should no longer exist
|
||||||
page.submitLoginAndPasswordByPressingEnter(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
page.submitLoginAndPasswordByPressingEnter(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
cy.get('.form-login').should('not.exist');
|
cy.get('ds-log-in').should('not.exist');
|
||||||
|
|
||||||
// Verify we are still on homepage
|
// Verify we are still on homepage
|
||||||
cy.url().should('include', '/home');
|
cy.url().should('include', '/home');
|
||||||
@@ -80,7 +80,7 @@ describe('Login Modal', () => {
|
|||||||
|
|
||||||
it('should support logout', () => {
|
it('should support logout', () => {
|
||||||
// First authenticate & access homepage
|
// First authenticate & access homepage
|
||||||
cy.login(TEST_ADMIN_USER, TEST_ADMIN_PASSWORD);
|
cy.login(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
|
||||||
// Verify ds-log-in tag doesn't exist, but ds-log-out tag does exist
|
// Verify ds-log-in tag doesn't exist, but ds-log-out tag does exist
|
||||||
@@ -102,12 +102,15 @@ describe('Login Modal', () => {
|
|||||||
page.openLoginMenu();
|
page.openLoginMenu();
|
||||||
|
|
||||||
// Registration link should be visible
|
// Registration link should be visible
|
||||||
cy.get('ds-themed-navbar [data-test="register"]').should('be.visible');
|
cy.get('ds-themed-header [data-test="register"]').should('be.visible');
|
||||||
|
|
||||||
// Click registration link & you should go to registration page
|
// Click registration link & you should go to registration page
|
||||||
cy.get('ds-themed-navbar [data-test="register"]').click();
|
cy.get('ds-themed-header [data-test="register"]').click();
|
||||||
cy.location('pathname').should('eq', '/register');
|
cy.location('pathname').should('eq', '/register');
|
||||||
cy.get('ds-register-email').should('exist');
|
cy.get('ds-register-email').should('exist');
|
||||||
|
|
||||||
|
// Test accessibility of this page
|
||||||
|
testA11y('ds-register-email');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow forgot password', () => {
|
it('should allow forgot password', () => {
|
||||||
@@ -116,11 +119,32 @@ describe('Login Modal', () => {
|
|||||||
page.openLoginMenu();
|
page.openLoginMenu();
|
||||||
|
|
||||||
// Forgot password link should be visible
|
// Forgot password link should be visible
|
||||||
cy.get('ds-themed-navbar [data-test="forgot"]').should('be.visible');
|
cy.get('ds-themed-header [data-test="forgot"]').should('be.visible');
|
||||||
|
|
||||||
// Click link & you should go to Forgot Password page
|
// Click link & you should go to Forgot Password page
|
||||||
cy.get('ds-themed-navbar [data-test="forgot"]').click();
|
cy.get('ds-themed-header [data-test="forgot"]').click();
|
||||||
cy.location('pathname').should('eq', '/forgot');
|
cy.location('pathname').should('eq', '/forgot');
|
||||||
cy.get('ds-forgot-email').should('exist');
|
cy.get('ds-forgot-email').should('exist');
|
||||||
|
|
||||||
|
// Test accessibility of this page
|
||||||
|
testA11y('ds-forgot-email');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests in menus', () => {
|
||||||
|
cy.visit('/');
|
||||||
|
|
||||||
|
// Open login menu & verify accessibility
|
||||||
|
page.openLoginMenu();
|
||||||
|
cy.get('ds-log-in').should('exist');
|
||||||
|
testA11y('ds-log-in');
|
||||||
|
|
||||||
|
// Now login
|
||||||
|
page.submitLoginAndPasswordByPressingButton(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
cy.get('ds-log-in').should('not.exist');
|
||||||
|
|
||||||
|
// Open user menu, verify user menu accesibility
|
||||||
|
page.openUserMenu();
|
||||||
|
cy.get('ds-user-menu').should('be.visible');
|
||||||
|
testA11y('ds-user-menu');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
16
cypress/e2e/metadata-import-page.cy.ts
Normal file
16
cypress/e2e/metadata-import-page.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Metadata Import Page', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/metadata-import');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Metadata import form must first be visible
|
||||||
|
cy.get('ds-metadata-import-page').should('be.visible');
|
||||||
|
// Analyze <ds-metadata-import-page> for accessibility issues
|
||||||
|
testA11y('ds-metadata-import-page');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/metadata-registry.cy.ts
Normal file
16
cypress/e2e/metadata-registry.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Metadata Registry', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/registries/metadata');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-metadata-registry').should('be.visible');
|
||||||
|
// Analyze <ds-metadata-registry> for accessibility issues
|
||||||
|
testA11y('ds-metadata-registry');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/metadata-schema.cy.ts
Normal file
16
cypress/e2e/metadata-schema.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Metadata Schema', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/registries/metadata/dc');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-metadata-schema').should('be.visible');
|
||||||
|
// Analyze <ds-metadata-schema> for accessibility issues
|
||||||
|
testA11y('ds-metadata-schema');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,5 +1,3 @@
|
|||||||
import { Options } from 'cypress-axe';
|
|
||||||
import { TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD, TEST_SUBMIT_COLLECTION_NAME } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('My DSpace page', () => {
|
describe('My DSpace page', () => {
|
||||||
@@ -7,7 +5,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
cy.get('ds-my-dspace-page').should('be.visible');
|
cy.get('ds-my-dspace-page').should('be.visible');
|
||||||
|
|
||||||
@@ -19,28 +17,14 @@ describe('My DSpace page', () => {
|
|||||||
cy.get('.filter-toggle').click({ multiple: true });
|
cy.get('.filter-toggle').click({ multiple: true });
|
||||||
|
|
||||||
// Analyze <ds-my-dspace-page> for accessibility issues
|
// Analyze <ds-my-dspace-page> for accessibility issues
|
||||||
testA11y(
|
testA11y('ds-my-dspace-page');
|
||||||
{
|
|
||||||
include: ['ds-my-dspace-page'],
|
|
||||||
exclude: [
|
|
||||||
['nouislider'] // Date filter slider is missing ARIA labels. Will be fixed by #1175
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
// Search filters fail these two "moderate" impact rules
|
|
||||||
'heading-order': { enabled: false },
|
|
||||||
'landmark-unique': { enabled: false }
|
|
||||||
}
|
|
||||||
} as Options
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a working detailed view that passes accessibility tests', () => {
|
it('should have a working detailed view that passes accessibility tests', () => {
|
||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
cy.get('ds-my-dspace-page').should('be.visible');
|
cy.get('ds-my-dspace-page').should('be.visible');
|
||||||
|
|
||||||
@@ -49,16 +33,8 @@ describe('My DSpace page', () => {
|
|||||||
|
|
||||||
cy.get('ds-object-detail').should('be.visible');
|
cy.get('ds-object-detail').should('be.visible');
|
||||||
|
|
||||||
// Analyze <ds-search-page> for accessibility issues
|
// Analyze <ds-my-dspace-page> for accessibility issues
|
||||||
testA11y('ds-my-dspace-page',
|
testA11y('ds-my-dspace-page');
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
// Search filters fail these two "moderate" impact rules
|
|
||||||
'heading-order': { enabled: false },
|
|
||||||
'landmark-unique': { enabled: false }
|
|
||||||
}
|
|
||||||
} as Options
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// NOTE: Deleting existing submissions is exercised by submission.spec.ts
|
// NOTE: Deleting existing submissions is exercised by submission.spec.ts
|
||||||
@@ -66,7 +42,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
// Open the New Submission dropdown
|
// Open the New Submission dropdown
|
||||||
cy.get('button[data-test="submission-dropdown"]').click();
|
cy.get('button[data-test="submission-dropdown"]').click();
|
||||||
@@ -77,10 +53,10 @@ describe('My DSpace page', () => {
|
|||||||
cy.get('ds-create-item-parent-selector').should('be.visible');
|
cy.get('ds-create-item-parent-selector').should('be.visible');
|
||||||
|
|
||||||
// Type in a known Collection name in the search box
|
// Type in a known Collection name in the search box
|
||||||
cy.get('ds-authorized-collection-selector input[type="search"]').type(TEST_SUBMIT_COLLECTION_NAME);
|
cy.get('ds-authorized-collection-selector input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
|
||||||
|
|
||||||
// Click on the button matching that known Collection name
|
// Click on the button matching that known Collection name
|
||||||
cy.get('ds-authorized-collection-selector button[title="'.concat(TEST_SUBMIT_COLLECTION_NAME).concat('"]')).click();
|
cy.get('ds-authorized-collection-selector button[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME')).concat('"]')).click();
|
||||||
|
|
||||||
// New URL should include /workspaceitems, as we've started a new submission
|
// New URL should include /workspaceitems, as we've started a new submission
|
||||||
cy.url().should('include', '/workspaceitems');
|
cy.url().should('include', '/workspaceitems');
|
||||||
@@ -89,7 +65,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.get('ds-submission-edit').should('be.visible');
|
cy.get('ds-submission-edit').should('be.visible');
|
||||||
|
|
||||||
// A Collection menu button should exist & its value should be the selected collection
|
// A Collection menu button should exist & its value should be the selected collection
|
||||||
cy.get('#collectionControlsMenuButton span').should('have.text', TEST_SUBMIT_COLLECTION_NAME);
|
cy.get('#collectionControlsMenuButton span').should('have.text', Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
|
||||||
|
|
||||||
// Now that we've created a submission, we'll test that we can go back and Edit it.
|
// Now that we've created a submission, we'll test that we can go back and Edit it.
|
||||||
// Get our Submission URL, to parse out the ID of this new submission
|
// Get our Submission URL, to parse out the ID of this new submission
|
||||||
@@ -138,7 +114,7 @@ describe('My DSpace page', () => {
|
|||||||
cy.visit('/mydspace');
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
// Open the New Import dropdown
|
// Open the New Import dropdown
|
||||||
cy.get('button[data-test="import-dropdown"]').click();
|
cy.get('button[data-test="import-dropdown"]').click();
|
||||||
@@ -150,6 +126,9 @@ describe('My DSpace page', () => {
|
|||||||
|
|
||||||
// The external import searchbox should be visible
|
// The external import searchbox should be visible
|
||||||
cy.get('ds-submission-import-external-searchbar').should('be.visible');
|
cy.get('ds-submission-import-external-searchbar').should('be.visible');
|
||||||
|
|
||||||
|
// Test for accessibility issues
|
||||||
|
testA11y('ds-submission-import-external');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
16
cypress/e2e/new-process.cy.ts
Normal file
16
cypress/e2e/new-process.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('New Process', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/processes/new');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Process form must first be visible
|
||||||
|
cy.get('ds-new-process').should('be.visible');
|
||||||
|
// Analyze <ds-new-process> for accessibility issues
|
||||||
|
testA11y('ds-new-process');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,8 +1,13 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('PageNotFound', () => {
|
describe('PageNotFound', () => {
|
||||||
it('should contain element ds-pagenotfound when navigating to page that doesnt exist', () => {
|
it('should contain element ds-pagenotfound when navigating to page that doesnt exist', () => {
|
||||||
// request an invalid page (UUIDs at root path aren't valid)
|
// request an invalid page (UUIDs at root path aren't valid)
|
||||||
cy.visit('/e9019a69-d4f1-4773-b6a3-bd362caa46f2', { failOnStatusCode: false });
|
cy.visit('/e9019a69-d4f1-4773-b6a3-bd362caa46f2', { failOnStatusCode: false });
|
||||||
cy.get('ds-pagenotfound').should('be.visible');
|
cy.get('ds-pagenotfound').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-pagenotfound> for accessibility issues
|
||||||
|
testA11y('ds-pagenotfound');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not contain element ds-pagenotfound when navigating to existing page', () => {
|
it('should not contain element ds-pagenotfound when navigating to existing page', () => {
|
||||||
|
13
cypress/e2e/privacy.cy.ts
Normal file
13
cypress/e2e/privacy.cy.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Privacy', () => {
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
cy.visit('/info/privacy');
|
||||||
|
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-privacy').should('be.visible');
|
||||||
|
|
||||||
|
// Analyze <ds-privacy> for accessibility
|
||||||
|
testA11y('ds-privacy');
|
||||||
|
});
|
||||||
|
});
|
17
cypress/e2e/processes-overview.cy.ts
Normal file
17
cypress/e2e/processes-overview.cy.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Processes Overview', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/processes');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
|
||||||
|
// Process overview must first be visible
|
||||||
|
cy.get('ds-process-overview').should('be.visible');
|
||||||
|
// Analyze <ds-process-overview> for accessibility issues
|
||||||
|
testA11y('ds-process-overview');
|
||||||
|
});
|
||||||
|
});
|
16
cypress/e2e/profile-page.cy.ts
Normal file
16
cypress/e2e/profile-page.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('Profile page', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/profile');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Process form must first be visible
|
||||||
|
cy.get('ds-profile-page').should('be.visible');
|
||||||
|
// Analyze <ds-profile-page> for accessibility issues
|
||||||
|
testA11y('ds-profile-page');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,23 +1,21 @@
|
|||||||
import { TEST_SEARCH_TERM } from 'cypress/support/e2e';
|
|
||||||
|
|
||||||
const page = {
|
const page = {
|
||||||
fillOutQueryInNavBar(query) {
|
fillOutQueryInNavBar(query) {
|
||||||
// Click the magnifying glass
|
// Click the magnifying glass
|
||||||
cy.get('ds-themed-navbar [data-test="header-search-icon"]').click();
|
cy.get('ds-themed-header [data-test="header-search-icon"]').click();
|
||||||
// Fill out a query in input that appears
|
// Fill out a query in input that appears
|
||||||
cy.get('ds-themed-navbar [data-test="header-search-box"]').type(query);
|
cy.get('ds-themed-header [data-test="header-search-box"]').type(query);
|
||||||
},
|
},
|
||||||
submitQueryByPressingEnter() {
|
submitQueryByPressingEnter() {
|
||||||
cy.get('ds-themed-navbar [data-test="header-search-box"]').type('{enter}');
|
cy.get('ds-themed-header [data-test="header-search-box"]').type('{enter}');
|
||||||
},
|
},
|
||||||
submitQueryByPressingIcon() {
|
submitQueryByPressingIcon() {
|
||||||
cy.get('ds-themed-navbar [data-test="header-search-icon"]').click();
|
cy.get('ds-themed-header [data-test="header-search-icon"]').click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Search from Navigation Bar', () => {
|
describe('Search from Navigation Bar', () => {
|
||||||
// NOTE: these tests currently assume this query will return results!
|
// NOTE: these tests currently assume this query will return results!
|
||||||
const query = TEST_SEARCH_TERM;
|
const query = Cypress.env('DSPACE_TEST_SEARCH_TERM');
|
||||||
|
|
||||||
it('should go to search page with correct query if submitted (from home)', () => {
|
it('should go to search page with correct query if submitted (from home)', () => {
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { Options } from 'cypress-axe';
|
import { Options } from 'cypress-axe';
|
||||||
import { TEST_SEARCH_TERM } from 'cypress/support/e2e';
|
|
||||||
import { testA11y } from 'cypress/support/utils';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
describe('Search Page', () => {
|
describe('Search Page', () => {
|
||||||
|
// NOTE: these tests currently assume this query will return results!
|
||||||
|
const query = Cypress.env('DSPACE_TEST_SEARCH_TERM');
|
||||||
|
|
||||||
it('should redirect to the correct url when query was set and submit button was triggered', () => {
|
it('should redirect to the correct url when query was set and submit button was triggered', () => {
|
||||||
const queryString = 'Another interesting query string';
|
const queryString = 'Another interesting query string';
|
||||||
cy.visit('/search');
|
cy.visit('/search');
|
||||||
@@ -13,8 +15,8 @@ describe('Search Page', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should load results and pass accessibility tests', () => {
|
it('should load results and pass accessibility tests', () => {
|
||||||
cy.visit('/search?query='.concat(TEST_SEARCH_TERM));
|
cy.visit('/search?query='.concat(query));
|
||||||
cy.get('[data-test="search-box"]').should('have.value', TEST_SEARCH_TERM);
|
cy.get('[data-test="search-box"]').should('have.value', query);
|
||||||
|
|
||||||
// <ds-search-page> tag must be loaded
|
// <ds-search-page> tag must be loaded
|
||||||
cy.get('ds-search-page').should('be.visible');
|
cy.get('ds-search-page').should('be.visible');
|
||||||
@@ -27,25 +29,11 @@ describe('Search Page', () => {
|
|||||||
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
cy.get('[data-test="filter-toggle"]').click({ multiple: true });
|
||||||
|
|
||||||
// Analyze <ds-search-page> for accessibility issues
|
// Analyze <ds-search-page> for accessibility issues
|
||||||
testA11y(
|
testA11y('ds-search-page');
|
||||||
{
|
|
||||||
include: ['ds-search-page'],
|
|
||||||
exclude: [
|
|
||||||
['nouislider'] // Date filter slider is missing ARIA labels. Will be fixed by #1175
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
rules: {
|
|
||||||
// Search filters fail these two "moderate" impact rules
|
|
||||||
'heading-order': { enabled: false },
|
|
||||||
'landmark-unique': { enabled: false }
|
|
||||||
}
|
|
||||||
} as Options
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a working grid view that passes accessibility tests', () => {
|
it('should have a working grid view that passes accessibility tests', () => {
|
||||||
cy.visit('/search?query='.concat(TEST_SEARCH_TERM));
|
cy.visit('/search?query='.concat(query));
|
||||||
|
|
||||||
// Click button in sidebar to display grid view
|
// Click button in sidebar to display grid view
|
||||||
cy.get('ds-search-sidebar [data-test="grid-view"]').click();
|
cy.get('ds-search-sidebar [data-test="grid-view"]').click();
|
||||||
@@ -60,9 +48,8 @@ describe('Search Page', () => {
|
|||||||
testA11y('ds-search-page',
|
testA11y('ds-search-page',
|
||||||
{
|
{
|
||||||
rules: {
|
rules: {
|
||||||
// Search filters fail these two "moderate" impact rules
|
// Card titles fail this test currently
|
||||||
'heading-order': { enabled: false },
|
'heading-order': { enabled: false }
|
||||||
'landmark-unique': { enabled: false }
|
|
||||||
}
|
}
|
||||||
} as Options
|
} as Options
|
||||||
);
|
);
|
||||||
|
@@ -1,14 +1,16 @@
|
|||||||
import { TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD, TEST_SUBMIT_COLLECTION_NAME, TEST_SUBMIT_COLLECTION_UUID } from 'cypress/support/e2e';
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
//import { TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD, TEST_SUBMIT_COLLECTION_NAME, TEST_SUBMIT_COLLECTION_UUID, TEST_ADMIN_USER, TEST_ADMIN_PASSWORD } from 'cypress/support/e2e';
|
||||||
|
import { Options } from 'cypress-axe';
|
||||||
|
|
||||||
describe('New Submission page', () => {
|
describe('New Submission page', () => {
|
||||||
// NOTE: We already test that new submissions can be started from MyDSpace in my-dspace.spec.ts
|
|
||||||
|
|
||||||
|
// NOTE: We already test that new Item submissions can be started from MyDSpace in my-dspace.spec.ts
|
||||||
it('should create a new submission when using /submit path & pass accessibility', () => {
|
it('should create a new submission when using /submit path & pass accessibility', () => {
|
||||||
// Test that calling /submit with collection & entityType will create a new submission
|
// Test that calling /submit with collection & entityType will create a new submission
|
||||||
cy.visit('/submit?collection='.concat(TEST_SUBMIT_COLLECTION_UUID).concat('&entityType=none'));
|
cy.visit('/submit?collection='.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID')).concat('&entityType=none'));
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
// Should redirect to /workspaceitems, as we've started a new submission
|
// Should redirect to /workspaceitems, as we've started a new submission
|
||||||
cy.url().should('include', '/workspaceitems');
|
cy.url().should('include', '/workspaceitems');
|
||||||
@@ -17,7 +19,7 @@ describe('New Submission page', () => {
|
|||||||
cy.get('ds-submission-edit').should('be.visible');
|
cy.get('ds-submission-edit').should('be.visible');
|
||||||
|
|
||||||
// A Collection menu button should exist & it's value should be the selected collection
|
// A Collection menu button should exist & it's value should be the selected collection
|
||||||
cy.get('#collectionControlsMenuButton span').should('have.text', TEST_SUBMIT_COLLECTION_NAME);
|
cy.get('#collectionControlsMenuButton span').should('have.text', Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
|
||||||
|
|
||||||
// 4 sections should be visible by default
|
// 4 sections should be visible by default
|
||||||
cy.get('div#section_traditionalpageone').should('be.visible');
|
cy.get('div#section_traditionalpageone').should('be.visible');
|
||||||
@@ -25,6 +27,25 @@ describe('New Submission page', () => {
|
|||||||
cy.get('div#section_upload').should('be.visible');
|
cy.get('div#section_upload').should('be.visible');
|
||||||
cy.get('div#section_license').should('be.visible');
|
cy.get('div#section_license').should('be.visible');
|
||||||
|
|
||||||
|
// Test entire page for accessibility
|
||||||
|
testA11y('ds-submission-edit',
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// Author & Subject fields have invalid "aria-multiline" attrs.
|
||||||
|
// See https://github.com/DSpace/dspace-angular/issues/1272
|
||||||
|
'aria-allowed-attr': { enabled: false },
|
||||||
|
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
|
||||||
|
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'aria-required-children': { enabled: false },
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
// All select boxes fail to have a name / aria-label.
|
||||||
|
// This is a bug in ng-dynamic-forms and may require https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'select-name': { enabled: false },
|
||||||
|
}
|
||||||
|
|
||||||
|
} as Options
|
||||||
|
);
|
||||||
|
|
||||||
// Discard button should work
|
// Discard button should work
|
||||||
// Clicking it will display a confirmation, which we will confirm with another click
|
// Clicking it will display a confirmation, which we will confirm with another click
|
||||||
cy.get('button#discard').click();
|
cy.get('button#discard').click();
|
||||||
@@ -33,10 +54,10 @@ describe('New Submission page', () => {
|
|||||||
|
|
||||||
it('should block submission & show errors if required fields are missing', () => {
|
it('should block submission & show errors if required fields are missing', () => {
|
||||||
// Create a new submission
|
// Create a new submission
|
||||||
cy.visit('/submit?collection='.concat(TEST_SUBMIT_COLLECTION_UUID).concat('&entityType=none'));
|
cy.visit('/submit?collection='.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID')).concat('&entityType=none'));
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
// Attempt an immediate deposit without filling out any fields
|
// Attempt an immediate deposit without filling out any fields
|
||||||
cy.get('button#deposit').click();
|
cy.get('button#deposit').click();
|
||||||
@@ -93,10 +114,10 @@ describe('New Submission page', () => {
|
|||||||
|
|
||||||
it('should allow for deposit if all required fields completed & file uploaded', () => {
|
it('should allow for deposit if all required fields completed & file uploaded', () => {
|
||||||
// Create a new submission
|
// Create a new submission
|
||||||
cy.visit('/submit?collection='.concat(TEST_SUBMIT_COLLECTION_UUID).concat('&entityType=none'));
|
cy.visit('/submit?collection='.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID')).concat('&entityType=none'));
|
||||||
|
|
||||||
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
cy.loginViaForm(TEST_SUBMIT_USER, TEST_SUBMIT_USER_PASSWORD);
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
|
||||||
|
|
||||||
// Fill out all required fields (Title, Date)
|
// Fill out all required fields (Title, Date)
|
||||||
cy.get('input#dc_title').type('DSpace logo uploaded via e2e tests');
|
cy.get('input#dc_title').type('DSpace logo uploaded via e2e tests');
|
||||||
@@ -116,7 +137,7 @@ describe('New Submission page', () => {
|
|||||||
|
|
||||||
// Upload our DSpace logo via drag & drop onto submission form
|
// Upload our DSpace logo via drag & drop onto submission form
|
||||||
// cy.get('div#section_upload')
|
// cy.get('div#section_upload')
|
||||||
cy.get('div.ds-document-drop-zone').selectFile('src/assets/images/dspace-logo.png', {
|
cy.get('div.ds-document-drop-zone').selectFile('src/assets/images/dspace-logo.svg', {
|
||||||
action: 'drag-drop'
|
action: 'drag-drop'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -131,4 +152,76 @@ describe('New Submission page', () => {
|
|||||||
cy.get('ds-notification div.alert-success').should('be.visible');
|
cy.get('ds-notification div.alert-success').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('is possible to submit a new "Person" and that form passes accessibility', () => {
|
||||||
|
// To submit a different entity type, we'll start from MyDSpace
|
||||||
|
cy.visit('/mydspace');
|
||||||
|
|
||||||
|
// This page is restricted, so we will be shown the login form. Fill it out & submit.
|
||||||
|
// NOTE: At this time, we MUST login as admin to submit Person objects
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
|
||||||
|
// Open the New Submission dropdown
|
||||||
|
cy.get('button[data-test="submission-dropdown"]').click();
|
||||||
|
// Click on the "Person" type in that dropdown
|
||||||
|
cy.get('#entityControlsDropdownMenu button[title="Person"]').click();
|
||||||
|
|
||||||
|
// This should display the <ds-create-item-parent-selector> (popup window)
|
||||||
|
cy.get('ds-create-item-parent-selector').should('be.visible');
|
||||||
|
|
||||||
|
// Type in a known Collection name in the search box
|
||||||
|
cy.get('ds-authorized-collection-selector input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME'));
|
||||||
|
|
||||||
|
// Click on the button matching that known Collection name
|
||||||
|
cy.get('ds-authorized-collection-selector button[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME')).concat('"]')).click();
|
||||||
|
|
||||||
|
// New URL should include /workspaceitems, as we've started a new submission
|
||||||
|
cy.url().should('include', '/workspaceitems');
|
||||||
|
|
||||||
|
// The Submission edit form tag should be visible
|
||||||
|
cy.get('ds-submission-edit').should('be.visible');
|
||||||
|
|
||||||
|
// A Collection menu button should exist & its value should be the selected collection
|
||||||
|
cy.get('#collectionControlsMenuButton span').should('have.text', Cypress.env('DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME'));
|
||||||
|
|
||||||
|
// 3 sections should be visible by default
|
||||||
|
cy.get('div#section_personStep').should('be.visible');
|
||||||
|
cy.get('div#section_upload').should('be.visible');
|
||||||
|
cy.get('div#section_license').should('be.visible');
|
||||||
|
|
||||||
|
// Test entire page for accessibility
|
||||||
|
testA11y('ds-submission-edit',
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// All panels are accordians & fail "aria-required-children" and "nested-interactive".
|
||||||
|
// Seem to require updating ng-bootstrap and https://github.com/DSpace/dspace-angular/issues/2216
|
||||||
|
'aria-required-children': { enabled: false },
|
||||||
|
'nested-interactive': { enabled: false },
|
||||||
|
}
|
||||||
|
|
||||||
|
} as Options
|
||||||
|
);
|
||||||
|
|
||||||
|
// Click the lookup button next to "Publication" field
|
||||||
|
cy.get('button[data-test="lookup-button"]').click();
|
||||||
|
|
||||||
|
// A popup modal window should be visible
|
||||||
|
cy.get('ds-dynamic-lookup-relation-modal').should('be.visible');
|
||||||
|
|
||||||
|
// Popup modal should also pass accessibility tests
|
||||||
|
//testA11y('ds-dynamic-lookup-relation-modal');
|
||||||
|
testA11y({
|
||||||
|
include: ['ds-dynamic-lookup-relation-modal'],
|
||||||
|
exclude: [
|
||||||
|
['ul.nav-tabs'] // Tabs at top of model have several issues which seem to be caused by ng-bootstrap
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close popup window
|
||||||
|
cy.get('ds-dynamic-lookup-relation-modal button.close').click();
|
||||||
|
|
||||||
|
// Back on the form, click the discard button to remove new submission
|
||||||
|
// Clicking it will display a confirmation, which we will confirm with another click
|
||||||
|
cy.get('button#discard').click();
|
||||||
|
cy.get('button#discard_submit').click();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
16
cypress/e2e/system-wide-alert.cy.ts
Normal file
16
cypress/e2e/system-wide-alert.cy.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { testA11y } from 'cypress/support/utils';
|
||||||
|
|
||||||
|
describe('System Wide Alert', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Must login as an Admin to see the page
|
||||||
|
cy.visit('/admin/system-wide-alert');
|
||||||
|
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should pass accessibility tests', () => {
|
||||||
|
// Page must first be visible
|
||||||
|
cy.get('ds-system-wide-alert-form').should('be.visible');
|
||||||
|
// Analyze <ds-system-wide-alert-form> for accessibility issues
|
||||||
|
testA11y('ds-system-wide-alert-form');
|
||||||
|
});
|
||||||
|
});
|
@@ -1,5 +1,11 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
// These two global variables are used to store information about the REST API used
|
||||||
|
// by these e2e tests. They are filled out prior to running any tests in the before()
|
||||||
|
// method of e2e.ts. They can then be accessed by any tests via the getters below.
|
||||||
|
let REST_BASE_URL: string;
|
||||||
|
let REST_DOMAIN: string;
|
||||||
|
|
||||||
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress
|
// Plugins enable you to tap into, modify, or extend the internal behavior of Cypress
|
||||||
// For more info, visit https://on.cypress.io/plugins-api
|
// For more info, visit https://on.cypress.io/plugins-api
|
||||||
module.exports = (on, config) => {
|
module.exports = (on, config) => {
|
||||||
@@ -30,6 +36,24 @@ module.exports = (on, config) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
},
|
||||||
|
// Save value of REST Base URL, looked up before all tests.
|
||||||
|
// This allows other tests to use it easily via getRestBaseURL() below.
|
||||||
|
saveRestBaseURL(url: string) {
|
||||||
|
return (REST_BASE_URL = url);
|
||||||
|
},
|
||||||
|
// Retrieve currently saved value of REST Base URL
|
||||||
|
getRestBaseURL() {
|
||||||
|
return REST_BASE_URL ;
|
||||||
|
},
|
||||||
|
// Save value of REST Domain, looked up before all tests.
|
||||||
|
// This allows other tests to use it easily via getRestBaseDomain() below.
|
||||||
|
saveRestBaseDomain(domain: string) {
|
||||||
|
return (REST_DOMAIN = domain);
|
||||||
|
},
|
||||||
|
// Retrieve currently saved value of REST Domain
|
||||||
|
getRestBaseDomain() {
|
||||||
|
return REST_DOMAIN ;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@@ -5,11 +5,7 @@
|
|||||||
|
|
||||||
import { AuthTokenInfo, TOKENITEM } from 'src/app/core/auth/models/auth-token-info.model';
|
import { AuthTokenInfo, TOKENITEM } from 'src/app/core/auth/models/auth-token-info.model';
|
||||||
import { DSPACE_XSRF_COOKIE, XSRF_REQUEST_HEADER } from 'src/app/core/xsrf/xsrf.constants';
|
import { DSPACE_XSRF_COOKIE, XSRF_REQUEST_HEADER } from 'src/app/core/xsrf/xsrf.constants';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
// NOTE: FALLBACK_TEST_REST_BASE_URL is only used if Cypress cannot read the REST API BaseURL
|
|
||||||
// from the Angular UI's config.json. See 'login()'.
|
|
||||||
export const FALLBACK_TEST_REST_BASE_URL = 'http://localhost:8080/server';
|
|
||||||
export const FALLBACK_TEST_REST_DOMAIN = 'localhost';
|
|
||||||
|
|
||||||
// Declare Cypress namespace to help with Intellisense & code completion in IDEs
|
// Declare Cypress namespace to help with Intellisense & code completion in IDEs
|
||||||
// ALL custom commands MUST be listed here for code completion to work
|
// ALL custom commands MUST be listed here for code completion to work
|
||||||
@@ -41,6 +37,13 @@ declare global {
|
|||||||
* @param dsoType type of DSpace Object (e.g. "item", "collection", "community")
|
* @param dsoType type of DSpace Object (e.g. "item", "collection", "community")
|
||||||
*/
|
*/
|
||||||
generateViewEvent(uuid: string, dsoType: string): typeof generateViewEvent;
|
generateViewEvent(uuid: string, dsoType: string): typeof generateViewEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new CSRF token and add to required Cookie. CSRF Token is returned
|
||||||
|
* in chainable in order to allow it to be sent also in required CSRF header.
|
||||||
|
* @returns Chainable reference to allow CSRF token to also be sent in header.
|
||||||
|
*/
|
||||||
|
createCSRFCookie(): Chainable<any>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,59 +57,32 @@ declare global {
|
|||||||
* @param password password to login as
|
* @param password password to login as
|
||||||
*/
|
*/
|
||||||
function login(email: string, password: string): void {
|
function login(email: string, password: string): void {
|
||||||
// Cypress doesn't have access to the running application in Node.js.
|
// Create a fake CSRF cookie/token to use in POST
|
||||||
// So, it's not possible to inject or load the AppConfig or environment of the Angular UI.
|
cy.createCSRFCookie().then((csrfToken: string) => {
|
||||||
// Instead, we'll read our running application's config.json, which contains the configs &
|
// get our REST API's base URL, also needed for POST
|
||||||
// is regenerated at runtime each time the Angular UI application starts up.
|
cy.task('getRestBaseURL').then((baseRestUrl: string) => {
|
||||||
cy.task('readUIConfig').then((str: string) => {
|
// Now, send login POST request including that CSRF token
|
||||||
// Parse config into a JSON object
|
cy.request({
|
||||||
const config = JSON.parse(str);
|
method: 'POST',
|
||||||
|
url: baseRestUrl + '/api/authn/login',
|
||||||
|
headers: { [XSRF_REQUEST_HEADER]: csrfToken},
|
||||||
|
form: true, // indicates the body should be form urlencoded
|
||||||
|
body: { user: email, password: password }
|
||||||
|
}).then((resp) => {
|
||||||
|
// We expect a successful login
|
||||||
|
expect(resp.status).to.eq(200);
|
||||||
|
// We expect to have a valid authorization header returned (with our auth token)
|
||||||
|
expect(resp.headers).to.have.property('authorization');
|
||||||
|
|
||||||
// Find the URL of our REST API. Have a fallback ready, just in case 'rest.baseUrl' cannot be found.
|
// Initialize our AuthTokenInfo object from the authorization header.
|
||||||
let baseRestUrl = FALLBACK_TEST_REST_BASE_URL;
|
const authheader = resp.headers.authorization as string;
|
||||||
if (!config.rest.baseUrl) {
|
const authinfo: AuthTokenInfo = new AuthTokenInfo(authheader);
|
||||||
console.warn("Could not load 'rest.baseUrl' from config.json. Falling back to " + FALLBACK_TEST_REST_BASE_URL);
|
|
||||||
} else {
|
|
||||||
//console.log("Found 'rest.baseUrl' in config.json. Using this REST API for login: ".concat(config.rest.baseUrl));
|
|
||||||
baseRestUrl = config.rest.baseUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now find domain of our REST API, again with a fallback.
|
// Save our AuthTokenInfo object to our dsAuthInfo UI cookie
|
||||||
let baseDomain = FALLBACK_TEST_REST_DOMAIN;
|
// This ensures the UI will recognize we are logged in on next "visit()"
|
||||||
if (!config.rest.host) {
|
cy.setCookie(TOKENITEM, JSON.stringify(authinfo));
|
||||||
console.warn("Could not load 'rest.host' from config.json. Falling back to " + FALLBACK_TEST_REST_DOMAIN);
|
});
|
||||||
} else {
|
|
||||||
baseDomain = config.rest.host;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a fake CSRF Token. Set it in the required server-side cookie
|
|
||||||
const csrfToken = 'fakeLoginCSRFToken';
|
|
||||||
cy.setCookie(DSPACE_XSRF_COOKIE, csrfToken, { 'domain': baseDomain });
|
|
||||||
|
|
||||||
// Now, send login POST request including that CSRF token
|
|
||||||
cy.request({
|
|
||||||
method: 'POST',
|
|
||||||
url: baseRestUrl + '/api/authn/login',
|
|
||||||
headers: { [XSRF_REQUEST_HEADER]: csrfToken},
|
|
||||||
form: true, // indicates the body should be form urlencoded
|
|
||||||
body: { user: email, password: password }
|
|
||||||
}).then((resp) => {
|
|
||||||
// We expect a successful login
|
|
||||||
expect(resp.status).to.eq(200);
|
|
||||||
// We expect to have a valid authorization header returned (with our auth token)
|
|
||||||
expect(resp.headers).to.have.property('authorization');
|
|
||||||
|
|
||||||
// Initialize our AuthTokenInfo object from the authorization header.
|
|
||||||
const authheader = resp.headers.authorization as string;
|
|
||||||
const authinfo: AuthTokenInfo = new AuthTokenInfo(authheader);
|
|
||||||
|
|
||||||
// Save our AuthTokenInfo object to our dsAuthInfo UI cookie
|
|
||||||
// This ensures the UI will recognize we are logged in on next "visit()"
|
|
||||||
cy.setCookie(TOKENITEM, JSON.stringify(authinfo));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove cookie with fake CSRF token, as it's no longer needed
|
|
||||||
cy.clearCookie(DSPACE_XSRF_COOKIE);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Add as a Cypress command (i.e. assign to 'cy.login')
|
// Add as a Cypress command (i.e. assign to 'cy.login')
|
||||||
@@ -118,12 +94,12 @@ Cypress.Commands.add('login', login);
|
|||||||
* @param password password to login as
|
* @param password password to login as
|
||||||
*/
|
*/
|
||||||
function loginViaForm(email: string, password: string): void {
|
function loginViaForm(email: string, password: string): void {
|
||||||
// Enter email
|
// Enter email
|
||||||
cy.get('ds-log-in [data-test="email"]').type(email);
|
cy.get('[data-test="email"]').type(email);
|
||||||
// Enter password
|
// Enter password
|
||||||
cy.get('ds-log-in [data-test="password"]').type(password);
|
cy.get('[data-test="password"]').type(password);
|
||||||
// Click login button
|
// Click login button
|
||||||
cy.get('ds-log-in [data-test="login-button"]').click();
|
cy.get('[data-test="login-button"]').click();
|
||||||
}
|
}
|
||||||
// Add as a Cypress command (i.e. assign to 'cy.loginViaForm')
|
// Add as a Cypress command (i.e. assign to 'cy.loginViaForm')
|
||||||
Cypress.Commands.add('loginViaForm', loginViaForm);
|
Cypress.Commands.add('loginViaForm', loginViaForm);
|
||||||
@@ -141,54 +117,53 @@ Cypress.Commands.add('loginViaForm', loginViaForm);
|
|||||||
* @param dsoType type of DSpace Object (e.g. "item", "collection", "community")
|
* @param dsoType type of DSpace Object (e.g. "item", "collection", "community")
|
||||||
*/
|
*/
|
||||||
function generateViewEvent(uuid: string, dsoType: string): void {
|
function generateViewEvent(uuid: string, dsoType: string): void {
|
||||||
// Cypress doesn't have access to the running application in Node.js.
|
// Create a fake CSRF cookie/token to use in POST
|
||||||
// So, it's not possible to inject or load the AppConfig or environment of the Angular UI.
|
cy.createCSRFCookie().then((csrfToken: string) => {
|
||||||
// Instead, we'll read our running application's config.json, which contains the configs &
|
// get our REST API's base URL, also needed for POST
|
||||||
// is regenerated at runtime each time the Angular UI application starts up.
|
cy.task('getRestBaseURL').then((baseRestUrl: string) => {
|
||||||
cy.task('readUIConfig').then((str: string) => {
|
// Now, send 'statistics/viewevents' POST request including that fake CSRF token in required header
|
||||||
// Parse config into a JSON object
|
cy.request({
|
||||||
const config = JSON.parse(str);
|
method: 'POST',
|
||||||
|
url: baseRestUrl + '/api/statistics/viewevents',
|
||||||
// Find the URL of our REST API. Have a fallback ready, just in case 'rest.baseUrl' cannot be found.
|
headers: {
|
||||||
let baseRestUrl = FALLBACK_TEST_REST_BASE_URL;
|
[XSRF_REQUEST_HEADER] : csrfToken,
|
||||||
if (!config.rest.baseUrl) {
|
// use a known public IP address to avoid being seen as a "bot"
|
||||||
console.warn("Could not load 'rest.baseUrl' from config.json. Falling back to " + FALLBACK_TEST_REST_BASE_URL);
|
'X-Forwarded-For': '1.1.1.1',
|
||||||
} else {
|
// Use a user-agent of a Firefox browser on Windows. This again avoids being seen as a "bot"
|
||||||
baseRestUrl = config.rest.baseUrl;
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0',
|
||||||
}
|
},
|
||||||
|
//form: true, // indicates the body should be form urlencoded
|
||||||
// Now find domain of our REST API, again with a fallback.
|
body: { targetId: uuid, targetType: dsoType },
|
||||||
let baseDomain = FALLBACK_TEST_REST_DOMAIN;
|
}).then((resp) => {
|
||||||
if (!config.rest.host) {
|
// We expect a 201 (which means statistics event was created)
|
||||||
console.warn("Could not load 'rest.host' from config.json. Falling back to " + FALLBACK_TEST_REST_DOMAIN);
|
expect(resp.status).to.eq(201);
|
||||||
} else {
|
});
|
||||||
baseDomain = config.rest.host;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a fake CSRF Token. Set it in the required server-side cookie
|
|
||||||
const csrfToken = 'fakeGenerateViewEventCSRFToken';
|
|
||||||
cy.setCookie(DSPACE_XSRF_COOKIE, csrfToken, { 'domain': baseDomain });
|
|
||||||
|
|
||||||
// Now, send 'statistics/viewevents' POST request including that fake CSRF token in required header
|
|
||||||
cy.request({
|
|
||||||
method: 'POST',
|
|
||||||
url: baseRestUrl + '/api/statistics/viewevents',
|
|
||||||
headers: {
|
|
||||||
[XSRF_REQUEST_HEADER] : csrfToken,
|
|
||||||
// use a known public IP address to avoid being seen as a "bot"
|
|
||||||
'X-Forwarded-For': '1.1.1.1',
|
|
||||||
},
|
|
||||||
//form: true, // indicates the body should be form urlencoded
|
|
||||||
body: { targetId: uuid, targetType: dsoType },
|
|
||||||
}).then((resp) => {
|
|
||||||
// We expect a 201 (which means statistics event was created)
|
|
||||||
expect(resp.status).to.eq(201);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove cookie with fake CSRF token, as it's no longer needed
|
|
||||||
cy.clearCookie(DSPACE_XSRF_COOKIE);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Add as a Cypress command (i.e. assign to 'cy.generateViewEvent')
|
// Add as a Cypress command (i.e. assign to 'cy.generateViewEvent')
|
||||||
Cypress.Commands.add('generateViewEvent', generateViewEvent);
|
Cypress.Commands.add('generateViewEvent', generateViewEvent);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used by tests to generate a random XSRF/CSRF token and save it to
|
||||||
|
* the required XSRF/CSRF cookie for usage when sending POST requests or similar.
|
||||||
|
* The generated CSRF token is returned in a Chainable to allow it to be also sent
|
||||||
|
* in the CSRF HTTP Header.
|
||||||
|
* @returns a Cypress Chainable which can be used to get the generated CSRF Token
|
||||||
|
*/
|
||||||
|
function createCSRFCookie(): Cypress.Chainable {
|
||||||
|
// Generate a new token which is a random UUID
|
||||||
|
const csrfToken: string = uuidv4();
|
||||||
|
|
||||||
|
// Save it to our required cookie
|
||||||
|
cy.task('getRestBaseDomain').then((baseDomain: string) => {
|
||||||
|
// Create a fake CSRF Token. Set it in the required server-side cookie
|
||||||
|
cy.setCookie(DSPACE_XSRF_COOKIE, csrfToken, { 'domain': baseDomain });
|
||||||
|
});
|
||||||
|
|
||||||
|
// return the generated token wrapped in a chainable
|
||||||
|
return cy.wrap(csrfToken);
|
||||||
|
}
|
||||||
|
// Add as a Cypress command (i.e. assign to 'cy.createCSRFCookie')
|
||||||
|
Cypress.Commands.add('createCSRFCookie', createCSRFCookie);
|
||||||
|
@@ -19,45 +19,54 @@ import './commands';
|
|||||||
// Import Cypress Axe tools for all tests
|
// Import Cypress Axe tools for all tests
|
||||||
// https://github.com/component-driven/cypress-axe
|
// https://github.com/component-driven/cypress-axe
|
||||||
import 'cypress-axe';
|
import 'cypress-axe';
|
||||||
|
import { DSPACE_XSRF_COOKIE } from 'src/app/core/xsrf/xsrf.constants';
|
||||||
|
|
||||||
|
|
||||||
|
// Runs once before all tests
|
||||||
|
before(() => {
|
||||||
|
// Cypress doesn't have access to the running application in Node.js.
|
||||||
|
// So, it's not possible to inject or load the AppConfig or environment of the Angular UI.
|
||||||
|
// Instead, we'll read our running application's config.json, which contains the configs &
|
||||||
|
// is regenerated at runtime each time the Angular UI application starts up.
|
||||||
|
cy.task('readUIConfig').then((str: string) => {
|
||||||
|
// Parse config into a JSON object
|
||||||
|
const config = JSON.parse(str);
|
||||||
|
|
||||||
|
// Find URL of our REST API & save to global variable via task
|
||||||
|
let baseRestUrl = FALLBACK_TEST_REST_BASE_URL;
|
||||||
|
if (!config.rest.baseUrl) {
|
||||||
|
console.warn("Could not load 'rest.baseUrl' from config.json. Falling back to " + FALLBACK_TEST_REST_BASE_URL);
|
||||||
|
} else {
|
||||||
|
baseRestUrl = config.rest.baseUrl;
|
||||||
|
}
|
||||||
|
cy.task('saveRestBaseURL', baseRestUrl);
|
||||||
|
|
||||||
|
// Find domain of our REST API & save to global variable via task.
|
||||||
|
let baseDomain = FALLBACK_TEST_REST_DOMAIN;
|
||||||
|
if (!config.rest.host) {
|
||||||
|
console.warn("Could not load 'rest.host' from config.json. Falling back to " + FALLBACK_TEST_REST_DOMAIN);
|
||||||
|
} else {
|
||||||
|
baseDomain = config.rest.host;
|
||||||
|
}
|
||||||
|
cy.task('saveRestBaseDomain', baseDomain);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Runs once before the first test in each "block"
|
// Runs once before the first test in each "block"
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Pre-agree to all Klaro cookies by setting the klaro-anonymous cookie
|
// Pre-agree to all Klaro cookies by setting the klaro-anonymous cookie
|
||||||
// This just ensures it doesn't get in the way of matching other objects in the page.
|
// This just ensures it doesn't get in the way of matching other objects in the page.
|
||||||
cy.setCookie('klaro-anonymous', '{%22authentication%22:true%2C%22preferences%22:true%2C%22acknowledgement%22:true%2C%22google-analytics%22:true%2C%22google-recaptcha%22:true}');
|
cy.setCookie('klaro-anonymous', '{%22authentication%22:true%2C%22preferences%22:true%2C%22acknowledgement%22:true%2C%22google-analytics%22:true%2C%22google-recaptcha%22:true}');
|
||||||
|
|
||||||
|
// Remove any CSRF cookies saved from prior tests
|
||||||
|
cy.clearCookie(DSPACE_XSRF_COOKIE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// For better stability between tests, we visit "about:blank" (i.e. blank page) after each test.
|
// NOTE: FALLBACK_TEST_REST_BASE_URL is only used if Cypress cannot read the REST API BaseURL
|
||||||
// This ensures any remaining/outstanding XHR requests are killed, so they don't affect the next test.
|
// from the Angular UI's config.json. See 'before()' above.
|
||||||
// Borrowed from: https://glebbahmutov.com/blog/visit-blank-page-between-tests/
|
const FALLBACK_TEST_REST_BASE_URL = 'http://localhost:8080/server';
|
||||||
/*afterEach(() => {
|
const FALLBACK_TEST_REST_DOMAIN = 'localhost';
|
||||||
cy.window().then((win) => {
|
|
||||||
win.location.href = 'about:blank';
|
|
||||||
});
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
// Global constants used in tests
|
|
||||||
// May be overridden in our cypress.json config file using specified environment variables.
|
|
||||||
// Default values listed here are all valid for the Demo Entities Data set available at
|
|
||||||
// https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
|
||||||
// (This is the data set used in our CI environment)
|
|
||||||
|
|
||||||
// Admin account used for administrative tests
|
|
||||||
export const TEST_ADMIN_USER = Cypress.env('DSPACE_TEST_ADMIN_USER') || 'dspacedemo+admin@gmail.com';
|
|
||||||
export const TEST_ADMIN_PASSWORD = Cypress.env('DSPACE_TEST_ADMIN_PASSWORD') || 'dspace';
|
|
||||||
// Community/collection/publication used for view/edit tests
|
|
||||||
export const TEST_COLLECTION = Cypress.env('DSPACE_TEST_COLLECTION') || '282164f5-d325-4740-8dd1-fa4d6d3e7200';
|
|
||||||
export const TEST_COMMUNITY = Cypress.env('DSPACE_TEST_COMMUNITY') || '0958c910-2037-42a9-81c7-dca80e3892b4';
|
|
||||||
export const TEST_ENTITY_PUBLICATION = Cypress.env('DSPACE_TEST_ENTITY_PUBLICATION') || 'e98b0f27-5c19-49a0-960d-eb6ad5287067';
|
|
||||||
// Search term (should return results) used in search tests
|
|
||||||
export const TEST_SEARCH_TERM = Cypress.env('DSPACE_TEST_SEARCH_TERM') || 'test';
|
|
||||||
// Collection used for submission tests
|
|
||||||
export const TEST_SUBMIT_COLLECTION_NAME = Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME') || 'Sample Collection';
|
|
||||||
export const TEST_SUBMIT_COLLECTION_UUID = Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_UUID') || '9d8334e9-25d3-4a67-9cea-3dffdef80144';
|
|
||||||
export const TEST_SUBMIT_USER = Cypress.env('DSPACE_TEST_SUBMIT_USER') || 'dspacedemo+submit@gmail.com';
|
|
||||||
export const TEST_SUBMIT_USER_PASSWORD = Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD') || 'dspace';
|
|
||||||
|
|
||||||
|
|
||||||
// USEFUL REGEX for testing
|
// USEFUL REGEX for testing
|
||||||
|
|
||||||
|
@@ -101,8 +101,8 @@ and the backend at http://localhost:8080/server/
|
|||||||
|
|
||||||
## Run DSpace Angular dist build with DSpace Demo site backend
|
## Run DSpace Angular dist build with DSpace Demo site backend
|
||||||
|
|
||||||
This allows you to run the Angular UI in *production* mode, pointing it at the demo backend
|
This allows you to run the Angular UI in *production* mode, pointing it at the demo or sandbox backend
|
||||||
(https://api7.dspace.org/server/).
|
(https://demo.dspace.org/server/ or https://sandbox.dspace.org/server/).
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose -f docker/docker-compose-dist.yml pull
|
docker-compose -f docker/docker-compose-dist.yml pull
|
||||||
|
@@ -12,15 +12,8 @@
|
|||||||
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/cli.assetstore.yml
|
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/cli.assetstore.yml
|
||||||
#
|
#
|
||||||
# Therefore, it should be kept in sync with that file
|
# Therefore, it should be kept in sync with that file
|
||||||
version: "3.7"
|
|
||||||
|
|
||||||
networks:
|
|
||||||
dspacenet:
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
dspace-cli:
|
dspace-cli:
|
||||||
networks:
|
|
||||||
dspacenet: {}
|
|
||||||
environment:
|
environment:
|
||||||
# This assetstore zip is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
# This assetstore zip is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
||||||
- LOADASSETS=https://github.com/DSpace-Labs/AIP-Files/releases/download/demo-entities-data/assetstore.tar.gz
|
- LOADASSETS=https://github.com/DSpace-Labs/AIP-Files/releases/download/demo-entities-data/assetstore.tar.gz
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/cli.ingest.yml
|
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/cli.ingest.yml
|
||||||
#
|
#
|
||||||
# Therefore, it should be kept in sync with that file
|
# Therefore, it should be kept in sync with that file
|
||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
dspace-cli:
|
dspace-cli:
|
||||||
environment:
|
environment:
|
||||||
|
@@ -12,11 +12,16 @@
|
|||||||
# https://github.com/DSpace/DSpace/blob/main/docker-compose-cli.yml
|
# https://github.com/DSpace/DSpace/blob/main/docker-compose-cli.yml
|
||||||
#
|
#
|
||||||
# Therefore, it should be kept in sync with that file
|
# Therefore, it should be kept in sync with that file
|
||||||
version: "3.7"
|
networks:
|
||||||
|
# Default to using network named 'dspacenet' from docker-compose-rest.yml.
|
||||||
|
# Its full name will be prepended with the project name (e.g. "-p d7" means it will be named "d7_dspacenet")
|
||||||
|
# If COMPOSITE_PROJECT_NAME is missing, default value will be "docker" (name of folder this file is in)
|
||||||
|
default:
|
||||||
|
name: ${COMPOSE_PROJECT_NAME:-docker}_dspacenet
|
||||||
|
external: true
|
||||||
services:
|
services:
|
||||||
dspace-cli:
|
dspace-cli:
|
||||||
image: "${DOCKER_OWNER:-dspace}/dspace-cli:${DSPACE_VER:-dspace-7_x}"
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-cli:${DSPACE_VER:-dspace-7_x}"
|
||||||
container_name: dspace-cli
|
container_name: dspace-cli
|
||||||
environment:
|
environment:
|
||||||
# Below syntax may look odd, but it is how to override dspace.cfg settings via env variables.
|
# Below syntax may look odd, but it is how to override dspace.cfg settings via env variables.
|
||||||
@@ -30,16 +35,12 @@ services:
|
|||||||
# solr.server: Ensure we are using the 'dspacesolr' image for Solr
|
# solr.server: Ensure we are using the 'dspacesolr' image for Solr
|
||||||
solr__P__server: http://dspacesolr:8983/solr
|
solr__P__server: http://dspacesolr:8983/solr
|
||||||
volumes:
|
volumes:
|
||||||
- "assetstore:/dspace/assetstore"
|
# Keep DSpace assetstore directory between reboots
|
||||||
|
- assetstore:/dspace/assetstore
|
||||||
entrypoint: /dspace/bin/dspace
|
entrypoint: /dspace/bin/dspace
|
||||||
command: help
|
command: help
|
||||||
networks:
|
|
||||||
- dspacenet
|
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
assetstore:
|
assetstore:
|
||||||
|
|
||||||
networks:
|
|
||||||
dspacenet:
|
|
||||||
|
@@ -12,11 +12,9 @@
|
|||||||
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/db.entities.yml
|
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/db.entities.yml
|
||||||
#
|
#
|
||||||
# # Therefore, it should be kept in sync with that file
|
# # Therefore, it should be kept in sync with that file
|
||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
dspacedb:
|
dspacedb:
|
||||||
image: dspace/dspace-postgres-pgcrypto:loadsql
|
image: ${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-postgres-pgcrypto:${DSPACE_VER:-dspace-7_x}-loadsql
|
||||||
environment:
|
environment:
|
||||||
# This LOADSQL should be kept in sync with the URL in DSpace/DSpace
|
# This LOADSQL should be kept in sync with the URL in DSpace/DSpace
|
||||||
# This SQL is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
# This SQL is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
# This is used by our GitHub CI at .github/workflows/build.yml
|
# This is used by our GitHub CI at .github/workflows/build.yml
|
||||||
# It is based heavily on the Backend's Docker Compose:
|
# It is based heavily on the Backend's Docker Compose:
|
||||||
# https://github.com/DSpace/DSpace/blob/main/docker-compose.yml
|
# https://github.com/DSpace/DSpace/blob/main/docker-compose.yml
|
||||||
version: '3.7'
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
dspacenet:
|
||||||
services:
|
services:
|
||||||
@@ -33,11 +32,12 @@ services:
|
|||||||
# Tell Statistics to commit all views immediately instead of waiting on Solr's autocommit.
|
# Tell Statistics to commit all views immediately instead of waiting on Solr's autocommit.
|
||||||
# This allows us to generate statistics in e2e tests so that statistics pages can be tested thoroughly.
|
# This allows us to generate statistics in e2e tests so that statistics pages can be tested thoroughly.
|
||||||
solr__D__statistics__P__autoCommit: 'false'
|
solr__D__statistics__P__autoCommit: 'false'
|
||||||
|
LOGGING_CONFIG: /dspace/config/log4j2-container.xml
|
||||||
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-7_x-test}"
|
||||||
depends_on:
|
depends_on:
|
||||||
- dspacedb
|
- dspacedb
|
||||||
image: dspace/dspace:dspace-7_x-test
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
ports:
|
ports:
|
||||||
- published: 8080
|
- published: 8080
|
||||||
target: 8080
|
target: 8080
|
||||||
@@ -45,8 +45,6 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
- assetstore:/dspace/assetstore
|
- assetstore:/dspace/assetstore
|
||||||
# Mount DSpace's solr configs to a volume, so that we can share to 'dspacesolr' container (see below)
|
|
||||||
- solr_configs:/dspace/solr
|
|
||||||
# Ensure that the database is ready BEFORE starting tomcat
|
# Ensure that the database is ready BEFORE starting tomcat
|
||||||
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||||
# 2. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
|
# 2. Then, run database migration to init database tables (including any out-of-order ignored migrations, if any)
|
||||||
@@ -62,29 +60,30 @@ services:
|
|||||||
# NOTE: This is customized to use our loadsql image, so that we are using a database with existing test data
|
# NOTE: This is customized to use our loadsql image, so that we are using a database with existing test data
|
||||||
dspacedb:
|
dspacedb:
|
||||||
container_name: dspacedb
|
container_name: dspacedb
|
||||||
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-postgres-pgcrypto:${DSPACE_VER:-dspace-7_x}-loadsql"
|
||||||
environment:
|
environment:
|
||||||
# This LOADSQL should be kept in sync with the LOADSQL in
|
# This LOADSQL should be kept in sync with the LOADSQL in
|
||||||
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/db.entities.yml
|
# https://github.com/DSpace/DSpace/blob/main/dspace/src/main/docker-compose/db.entities.yml
|
||||||
# This SQL is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
# This SQL is available from https://github.com/DSpace-Labs/AIP-Files/releases/tag/demo-entities-data
|
||||||
LOADSQL: https://github.com/DSpace-Labs/AIP-Files/releases/download/demo-entities-data/dspace7-entities-data.sql
|
LOADSQL: https://github.com/DSpace-Labs/AIP-Files/releases/download/demo-entities-data/dspace7-entities-data.sql
|
||||||
PGDATA: /pgdata
|
PGDATA: /pgdata
|
||||||
image: dspace/dspace-postgres-pgcrypto:loadsql
|
POSTGRES_PASSWORD: dspace
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
|
ports:
|
||||||
|
- published: 5432
|
||||||
|
target: 5432
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
|
# Keep Postgres data directory between reboots
|
||||||
- pgdata:/pgdata
|
- pgdata:/pgdata
|
||||||
# DSpace Solr container
|
# DSpace Solr container
|
||||||
dspacesolr:
|
dspacesolr:
|
||||||
container_name: dspacesolr
|
container_name: dspacesolr
|
||||||
# Uses official Solr image at https://hub.docker.com/_/solr/
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-solr:${DSPACE_VER:-dspace-7_x}"
|
||||||
image: solr:8.11-slim
|
|
||||||
# Needs main 'dspace' container to start first to guarantee access to solr_configs
|
|
||||||
depends_on:
|
|
||||||
- dspace
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
ports:
|
ports:
|
||||||
- published: 8983
|
- published: 8983
|
||||||
target: 8983
|
target: 8983
|
||||||
@@ -92,9 +91,6 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
working_dir: /var/solr/data
|
working_dir: /var/solr/data
|
||||||
volumes:
|
volumes:
|
||||||
# Mount our "solr_configs" volume available under the Solr's configsets folder (in a 'dspace' subfolder)
|
|
||||||
# This copies the Solr configs from main 'dspace' container into 'dspacesolr' via that volume
|
|
||||||
- solr_configs:/opt/solr/server/solr/configsets/dspace
|
|
||||||
# Keep Solr data directory between reboots
|
# Keep Solr data directory between reboots
|
||||||
- solr_data:/var/solr/data
|
- solr_data:/var/solr/data
|
||||||
# Initialize all DSpace Solr cores using the mounted configsets (see above), then start Solr
|
# Initialize all DSpace Solr cores using the mounted configsets (see above), then start Solr
|
||||||
@@ -103,14 +99,16 @@ services:
|
|||||||
- '-c'
|
- '-c'
|
||||||
- |
|
- |
|
||||||
init-var-solr
|
init-var-solr
|
||||||
precreate-core authority /opt/solr/server/solr/configsets/dspace/authority
|
precreate-core authority /opt/solr/server/solr/configsets/authority
|
||||||
precreate-core oai /opt/solr/server/solr/configsets/dspace/oai
|
cp -r /opt/solr/server/solr/configsets/authority/* authority
|
||||||
precreate-core search /opt/solr/server/solr/configsets/dspace/search
|
precreate-core oai /opt/solr/server/solr/configsets/oai
|
||||||
precreate-core statistics /opt/solr/server/solr/configsets/dspace/statistics
|
cp -r /opt/solr/server/solr/configsets/oai/* oai
|
||||||
|
precreate-core search /opt/solr/server/solr/configsets/search
|
||||||
|
cp -r /opt/solr/server/solr/configsets/search/* search
|
||||||
|
precreate-core statistics /opt/solr/server/solr/configsets/statistics
|
||||||
|
cp -r /opt/solr/server/solr/configsets/statistics/* statistics
|
||||||
exec solr -f
|
exec solr -f
|
||||||
volumes:
|
volumes:
|
||||||
assetstore:
|
assetstore:
|
||||||
pgdata:
|
pgdata:
|
||||||
solr_data:
|
solr_data:
|
||||||
# Special volume used to share Solr configs from 'dspace' to 'dspacesolr' container (see above)
|
|
||||||
solr_configs:
|
|
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
# Docker Compose for running the DSpace Angular UI dist build
|
# Docker Compose for running the DSpace Angular UI dist build
|
||||||
# for previewing with the DSpace Demo site backend
|
# for previewing with the DSpace Demo site backend
|
||||||
version: '3.7'
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
dspacenet:
|
||||||
services:
|
services:
|
||||||
@@ -24,10 +23,10 @@ services:
|
|||||||
# This is because Server Side Rendering (SSR) currently requires a public URL,
|
# This is because Server Side Rendering (SSR) currently requires a public URL,
|
||||||
# see this bug: https://github.com/DSpace/dspace-angular/issues/1485
|
# see this bug: https://github.com/DSpace/dspace-angular/issues/1485
|
||||||
DSPACE_REST_SSL: 'true'
|
DSPACE_REST_SSL: 'true'
|
||||||
DSPACE_REST_HOST: api7.dspace.org
|
DSPACE_REST_HOST: demo.dspace.org
|
||||||
DSPACE_REST_PORT: 443
|
DSPACE_REST_PORT: 443
|
||||||
DSPACE_REST_NAMESPACE: /server
|
DSPACE_REST_NAMESPACE: /server
|
||||||
image: dspace/dspace-angular:dspace-7_x-dist
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-angular:${DSPACE_VER:-dspace-7_x}-dist"
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: Dockerfile.dist
|
dockerfile: Dockerfile.dist
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
# This is based heavily on the docker-compose.yml that is available in the DSpace/DSpace
|
# This is based heavily on the docker-compose.yml that is available in the DSpace/DSpace
|
||||||
# (Backend) at:
|
# (Backend) at:
|
||||||
# https://github.com/DSpace/DSpace/blob/main/docker-compose.yml
|
# https://github.com/DSpace/DSpace/blob/main/docker-compose.yml
|
||||||
version: '3.7'
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
dspacenet:
|
||||||
ipam:
|
ipam:
|
||||||
@@ -29,8 +28,9 @@ services:
|
|||||||
# __D__ => "-" (e.g. google__D__metadata => google-metadata)
|
# __D__ => "-" (e.g. google__D__metadata => google-metadata)
|
||||||
# dspace.dir, dspace.server.url, dspace.ui.url and dspace.name
|
# dspace.dir, dspace.server.url, dspace.ui.url and dspace.name
|
||||||
dspace__P__dir: /dspace
|
dspace__P__dir: /dspace
|
||||||
dspace__P__server__P__url: http://localhost:8080/server
|
# Uncomment to set a non-default value for dspace.server.url or dspace.ui.url
|
||||||
dspace__P__ui__P__url: http://localhost:4000
|
# dspace__P__server__P__url: http://localhost:8080/server
|
||||||
|
# dspace__P__ui__P__url: http://localhost:4000
|
||||||
dspace__P__name: 'DSpace Started with Docker Compose'
|
dspace__P__name: 'DSpace Started with Docker Compose'
|
||||||
# db.url: Ensure we are using the 'dspacedb' image for our database
|
# db.url: Ensure we are using the 'dspacedb' image for our database
|
||||||
db__P__url: 'jdbc:postgresql://dspacedb:5432/dspace'
|
db__P__url: 'jdbc:postgresql://dspacedb:5432/dspace'
|
||||||
@@ -39,11 +39,12 @@ services:
|
|||||||
# proxies.trusted.ipranges: This setting is required for a REST API running in Docker to trust requests
|
# proxies.trusted.ipranges: This setting is required for a REST API running in Docker to trust requests
|
||||||
# from the host machine. This IP range MUST correspond to the 'dspacenet' subnet defined above.
|
# from the host machine. This IP range MUST correspond to the 'dspacenet' subnet defined above.
|
||||||
proxies__P__trusted__P__ipranges: '172.23.0'
|
proxies__P__trusted__P__ipranges: '172.23.0'
|
||||||
image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-7_x-test}"
|
LOGGING_CONFIG: /dspace/config/log4j2-container.xml
|
||||||
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-7_x-test}"
|
||||||
depends_on:
|
depends_on:
|
||||||
- dspacedb
|
- dspacedb
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
ports:
|
ports:
|
||||||
- published: 8080
|
- published: 8080
|
||||||
target: 8080
|
target: 8080
|
||||||
@@ -51,8 +52,6 @@ services:
|
|||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
- assetstore:/dspace/assetstore
|
- assetstore:/dspace/assetstore
|
||||||
# Mount DSpace's solr configs to a volume, so that we can share to 'dspacesolr' container (see below)
|
|
||||||
- solr_configs:/dspace/solr
|
|
||||||
# Ensure that the database is ready BEFORE starting tomcat
|
# Ensure that the database is ready BEFORE starting tomcat
|
||||||
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||||
# 2. Then, run database migration to init database tables
|
# 2. Then, run database migration to init database tables
|
||||||
@@ -67,27 +66,27 @@ services:
|
|||||||
# DSpace database container
|
# DSpace database container
|
||||||
dspacedb:
|
dspacedb:
|
||||||
container_name: dspacedb
|
container_name: dspacedb
|
||||||
|
# Uses a custom Postgres image with pgcrypto installed
|
||||||
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-postgres-pgcrypto:${DSPACE_VER:-dspace-7_x}"
|
||||||
environment:
|
environment:
|
||||||
PGDATA: /pgdata
|
PGDATA: /pgdata
|
||||||
image: dspace/dspace-postgres-pgcrypto
|
POSTGRES_PASSWORD: dspace
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
ports:
|
ports:
|
||||||
- published: 5432
|
- published: 5432
|
||||||
target: 5432
|
target: 5432
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
volumes:
|
volumes:
|
||||||
|
# Keep Postgres data directory between reboots
|
||||||
- pgdata:/pgdata
|
- pgdata:/pgdata
|
||||||
# DSpace Solr container
|
# DSpace Solr container
|
||||||
dspacesolr:
|
dspacesolr:
|
||||||
container_name: dspacesolr
|
container_name: dspacesolr
|
||||||
image: "${DOCKER_OWNER:-dspace}/dspace-solr:${DSPACE_VER:-dspace-7_x}"
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-solr:${DSPACE_VER:-dspace-7_x}"
|
||||||
# Needs main 'dspace' container to start first to guarantee access to solr_configs
|
|
||||||
depends_on:
|
|
||||||
- dspace
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
- dspacenet
|
||||||
ports:
|
ports:
|
||||||
- published: 8983
|
- published: 8983
|
||||||
target: 8983
|
target: 8983
|
||||||
@@ -120,5 +119,3 @@ volumes:
|
|||||||
assetstore:
|
assetstore:
|
||||||
pgdata:
|
pgdata:
|
||||||
solr_data:
|
solr_data:
|
||||||
# Special volume used to share Solr configs from 'dspace' to 'dspacesolr' container (see above)
|
|
||||||
solr_configs:
|
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
# Docker Compose for running the DSpace Angular UI for testing/development
|
# Docker Compose for running the DSpace Angular UI for testing/development
|
||||||
# Requires also running a REST API backend (either locally or remotely),
|
# Requires also running a REST API backend (either locally or remotely),
|
||||||
# for example via 'docker-compose-rest.yml'
|
# for example via 'docker-compose-rest.yml'
|
||||||
version: '3.7'
|
|
||||||
networks:
|
networks:
|
||||||
dspacenet:
|
dspacenet:
|
||||||
services:
|
services:
|
||||||
@@ -24,7 +23,7 @@ services:
|
|||||||
DSPACE_REST_HOST: localhost
|
DSPACE_REST_HOST: localhost
|
||||||
DSPACE_REST_PORT: 8080
|
DSPACE_REST_PORT: 8080
|
||||||
DSPACE_REST_NAMESPACE: /server
|
DSPACE_REST_NAMESPACE: /server
|
||||||
image: dspace/dspace-angular:dspace-7_x
|
image: "${DOCKER_REGISTRY:-docker.io}/${DOCKER_OWNER:-dspace}/dspace-angular:${DSPACE_VER:-dspace-7_x}"
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
@@ -48,7 +48,7 @@ dspace-angular connects to your DSpace installation by using its REST endpoint.
|
|||||||
```yaml
|
```yaml
|
||||||
rest:
|
rest:
|
||||||
ssl: true
|
ssl: true
|
||||||
host: api7.dspace.org
|
host: demo.dspace.org
|
||||||
port: 443
|
port: 443
|
||||||
nameSpace: /server
|
nameSpace: /server
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ rest:
|
|||||||
Alternately you can set the following environment variables. If any of these are set, it will override all configuration files:
|
Alternately you can set the following environment variables. If any of these are set, it will override all configuration files:
|
||||||
```
|
```
|
||||||
DSPACE_REST_SSL=true
|
DSPACE_REST_SSL=true
|
||||||
DSPACE_REST_HOST=api7.dspace.org
|
DSPACE_REST_HOST=demo.dspace.org
|
||||||
DSPACE_REST_PORT=443
|
DSPACE_REST_PORT=443
|
||||||
DSPACE_REST_NAMESPACE=/server
|
DSPACE_REST_NAMESPACE=/server
|
||||||
```
|
```
|
||||||
|
154
package.json
154
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dspace-angular",
|
"name": "dspace-angular",
|
||||||
"version": "7.6.0",
|
"version": "7.6.4-next",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"config:watch": "nodemon",
|
"config:watch": "nodemon",
|
||||||
@@ -12,17 +12,16 @@
|
|||||||
"preserve": "yarn base-href",
|
"preserve": "yarn base-href",
|
||||||
"serve": "ts-node --project ./tsconfig.ts-node.json scripts/serve.ts",
|
"serve": "ts-node --project ./tsconfig.ts-node.json scripts/serve.ts",
|
||||||
"serve:ssr": "node dist/server/main",
|
"serve:ssr": "node dist/server/main",
|
||||||
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
|
||||||
"build": "ng build --configuration development",
|
"build": "ng build --configuration development",
|
||||||
"build:stats": "ng build --stats-json",
|
"build:stats": "ng build --stats-json",
|
||||||
"build:prod": "yarn run build:ssr",
|
"build:prod": "cross-env NODE_ENV=production yarn run build:ssr",
|
||||||
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
|
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
|
||||||
"test": "ng test --source-map=true --watch=false --configuration test",
|
"test": "ng test --source-map=true --watch=false --configuration test",
|
||||||
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",
|
"test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",
|
||||||
"test:headless": "ng test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
|
"test:headless": "ng test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"lint-fix": "ng lint --fix=true",
|
"lint-fix": "ng lint --fix=true",
|
||||||
"e2e": "ng e2e",
|
"e2e": "cross-env NODE_ENV=production ng e2e",
|
||||||
"clean:dev:config": "rimraf src/assets/config.json",
|
"clean:dev:config": "rimraf src/assets/config.json",
|
||||||
"clean:coverage": "rimraf coverage",
|
"clean:coverage": "rimraf coverage",
|
||||||
"clean:dist": "rimraf dist",
|
"clean:dist": "rimraf dist",
|
||||||
@@ -49,27 +48,20 @@
|
|||||||
"https": false
|
"https": false
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"resolutions": {
|
|
||||||
"minimist": "^1.2.5",
|
|
||||||
"webdriver-manager": "^12.1.8",
|
|
||||||
"ts-node": "10.2.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^15.2.8",
|
"@angular/animations": "^15.2.10",
|
||||||
"@angular/cdk": "^15.2.8",
|
"@angular/cdk": "^15.2.9",
|
||||||
"@angular/common": "^15.2.8",
|
"@angular/common": "^15.2.10",
|
||||||
"@angular/compiler": "^15.2.8",
|
"@angular/compiler": "^15.2.10",
|
||||||
"@angular/core": "^15.2.8",
|
"@angular/core": "^15.2.10",
|
||||||
"@angular/forms": "^15.2.8",
|
"@angular/forms": "^15.2.10",
|
||||||
"@angular/localize": "15.2.8",
|
"@angular/localize": "15.2.10",
|
||||||
"@angular/platform-browser": "^15.2.8",
|
"@angular/platform-browser": "^15.2.10",
|
||||||
"@angular/platform-browser-dynamic": "^15.2.8",
|
"@angular/platform-browser-dynamic": "^15.2.10",
|
||||||
"@angular/platform-server": "^15.2.8",
|
"@angular/platform-server": "^15.2.10",
|
||||||
"@angular/router": "^15.2.8",
|
"@angular/router": "^15.2.10",
|
||||||
"@babel/runtime": "7.21.0",
|
"@babel/runtime": "7.27.1",
|
||||||
"@kolkov/ngx-gallery": "^2.0.1",
|
"@kolkov/ngx-gallery": "^2.0.1",
|
||||||
"@material-ui/core": "^4.11.0",
|
|
||||||
"@material-ui/icons": "^4.11.3",
|
|
||||||
"@ng-bootstrap/ng-bootstrap": "^11.0.0",
|
"@ng-bootstrap/ng-bootstrap": "^11.0.0",
|
||||||
"@ng-dynamic-forms/core": "^15.0.0",
|
"@ng-dynamic-forms/core": "^15.0.0",
|
||||||
"@ng-dynamic-forms/ui-ng-bootstrap": "^15.0.0",
|
"@ng-dynamic-forms/ui-ng-bootstrap": "^15.0.0",
|
||||||
@@ -79,129 +71,129 @@
|
|||||||
"@nguniversal/express-engine": "^15.2.1",
|
"@nguniversal/express-engine": "^15.2.1",
|
||||||
"@ngx-translate/core": "^14.0.0",
|
"@ngx-translate/core": "^14.0.0",
|
||||||
"@nicky-lenaers/ngx-scroll-to": "^14.0.0",
|
"@nicky-lenaers/ngx-scroll-to": "^14.0.0",
|
||||||
"@types/grecaptcha": "^3.0.4",
|
|
||||||
"angular-idle-preload": "3.0.0",
|
"angular-idle-preload": "3.0.0",
|
||||||
"angulartics2": "^12.2.0",
|
"angulartics2": "^12.2.1",
|
||||||
"axios": "^0.27.2",
|
"axios": "^1.9.0",
|
||||||
"bootstrap": "^4.6.1",
|
"bootstrap": "^4.6.1",
|
||||||
"cerialize": "0.1.18",
|
"cerialize": "0.1.18",
|
||||||
"cli-progress": "^3.12.0",
|
"cli-progress": "^3.12.0",
|
||||||
"colors": "^1.4.0",
|
"colors": "^1.4.0",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.8.0",
|
||||||
"cookie-parser": "1.4.6",
|
"cookie-parser": "1.4.7",
|
||||||
"core-js": "^3.30.1",
|
"core-js": "^3.42.0",
|
||||||
"date-fns": "^2.29.3",
|
"date-fns": "^2.30.0",
|
||||||
"date-fns-tz": "^1.3.7",
|
"date-fns-tz": "^1.3.7",
|
||||||
"deepmerge": "^4.3.1",
|
"deepmerge": "^4.3.1",
|
||||||
"ejs": "^3.1.9",
|
"ejs": "^3.1.10",
|
||||||
"express": "^4.18.2",
|
"express": "^4.21.2",
|
||||||
"express-rate-limit": "^5.1.3",
|
"express-rate-limit": "^5.1.3",
|
||||||
"fast-json-patch": "^3.1.1",
|
"fast-json-patch": "^3.1.1",
|
||||||
"filesize": "^6.1.0",
|
"filesize": "^6.1.0",
|
||||||
"http-proxy-middleware": "^1.0.5",
|
"http-proxy-middleware": "^2.0.9",
|
||||||
"isbot": "^3.6.10",
|
"http-terminator": "^3.2.0",
|
||||||
|
"isbot": "^5.1.28",
|
||||||
"js-cookie": "2.2.1",
|
"js-cookie": "2.2.1",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"jsonschema": "1.4.1",
|
"jsonschema": "1.5.0",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"klaro": "^0.7.18",
|
"klaro": "^0.7.21",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lru-cache": "^7.14.1",
|
"lru-cache": "^7.14.1",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.2",
|
||||||
"markdown-it-mathjax3": "^4.3.2",
|
"markdown-it-mathjax3": "^4.3.2",
|
||||||
"mirador": "^3.3.0",
|
"mirador": "^3.4.3",
|
||||||
"mirador-dl-plugin": "^0.13.0",
|
"mirador-dl-plugin": "^0.13.0",
|
||||||
"mirador-share-plugin": "^0.11.0",
|
"mirador-share-plugin": "^0.16.0",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"ng-mocks": "^14.10.0",
|
|
||||||
"ng2-file-upload": "1.4.0",
|
"ng2-file-upload": "1.4.0",
|
||||||
"ng2-nouislider": "^1.8.3",
|
"ng2-nouislider": "^2.0.0",
|
||||||
"ngx-infinite-scroll": "^15.0.0",
|
"ngx-infinite-scroll": "^15.0.0",
|
||||||
"ngx-pagination": "6.0.3",
|
"ngx-pagination": "6.0.3",
|
||||||
|
"ngx-skeleton-loader": "^7.0.0",
|
||||||
"ngx-sortablejs": "^11.1.0",
|
"ngx-sortablejs": "^11.1.0",
|
||||||
"ngx-ui-switch": "^14.0.3",
|
"ngx-ui-switch": "^14.1.0",
|
||||||
"nouislider": "^14.6.3",
|
"nouislider": "^15.8.1",
|
||||||
"pem": "1.14.7",
|
"pem": "1.14.8",
|
||||||
"prop-types": "^15.8.1",
|
"reflect-metadata": "^0.2.2",
|
||||||
"react-copy-to-clipboard": "^5.1.0",
|
"rxjs": "^7.8.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"sanitize-html": "^2.16.0",
|
||||||
"rxjs": "^7.8.0",
|
"sortablejs": "1.15.6",
|
||||||
"sanitize-html": "^2.10.0",
|
|
||||||
"sortablejs": "1.15.0",
|
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"webfontloader": "1.6.28",
|
"zone.js": "~0.13.3"
|
||||||
"zone.js": "~0.11.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-builders/custom-webpack": "~15.0.0",
|
"@angular-builders/custom-webpack": "~15.0.0",
|
||||||
"@angular-devkit/build-angular": "^15.2.6",
|
"@angular-devkit/build-angular": "^15.2.11",
|
||||||
"@angular-eslint/builder": "15.2.1",
|
"@angular-eslint/builder": "15.2.1",
|
||||||
"@angular-eslint/eslint-plugin": "15.2.1",
|
"@angular-eslint/eslint-plugin": "15.2.1",
|
||||||
"@angular-eslint/eslint-plugin-template": "15.2.1",
|
"@angular-eslint/eslint-plugin-template": "15.2.1",
|
||||||
"@angular-eslint/schematics": "15.2.1",
|
"@angular-eslint/schematics": "15.2.1",
|
||||||
"@angular-eslint/template-parser": "15.2.1",
|
"@angular-eslint/template-parser": "15.2.1",
|
||||||
"@angular/cli": "^15.2.6",
|
"@angular/cli": "^16.2.16",
|
||||||
"@angular/compiler-cli": "^15.2.8",
|
"@angular/compiler-cli": "^15.2.10",
|
||||||
"@angular/language-service": "^15.2.8",
|
"@angular/language-service": "^15.2.10",
|
||||||
"@cypress/schematic": "^1.5.0",
|
"@cypress/schematic": "^1.5.0",
|
||||||
"@fortawesome/fontawesome-free": "^6.4.0",
|
"@fortawesome/fontawesome-free": "^6.7.2",
|
||||||
|
"@material-ui/core": "^4.12.4",
|
||||||
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@ngrx/store-devtools": "^15.4.0",
|
"@ngrx/store-devtools": "^15.4.0",
|
||||||
"@ngtools/webpack": "^15.2.6",
|
"@ngtools/webpack": "^15.2.6",
|
||||||
"@nguniversal/builders": "^15.2.1",
|
"@nguniversal/builders": "^15.2.1",
|
||||||
"@types/deep-freeze": "0.1.2",
|
"@types/deep-freeze": "0.1.5",
|
||||||
"@types/ejs": "^3.1.2",
|
"@types/ejs": "^3.1.5",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.21",
|
||||||
|
"@types/grecaptcha": "^3.0.9",
|
||||||
"@types/jasmine": "~3.6.0",
|
"@types/jasmine": "~3.6.0",
|
||||||
"@types/js-cookie": "2.2.6",
|
"@types/js-cookie": "2.2.6",
|
||||||
"@types/lodash": "^4.14.194",
|
"@types/lodash": "^4.17.16",
|
||||||
"@types/node": "^14.14.9",
|
"@types/node": "^14.18.63",
|
||||||
"@types/sanitize-html": "^2.9.0",
|
"@types/sanitize-html": "^2.16.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
"@typescript-eslint/parser": "^5.59.1",
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
"axe-core": "^4.7.0",
|
"axe-core": "^4.10.3",
|
||||||
"compression-webpack-plugin": "^9.2.0",
|
"compression-webpack-plugin": "^9.2.0",
|
||||||
"copy-webpack-plugin": "^6.4.1",
|
"copy-webpack-plugin": "^6.4.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cypress": "12.10.0",
|
"csstype": "^3.1.3",
|
||||||
"cypress-axe": "^1.4.0",
|
"cypress": "^13.17.0",
|
||||||
|
"cypress-axe": "^1.6.0",
|
||||||
"deep-freeze": "0.0.1",
|
"deep-freeze": "0.0.1",
|
||||||
"eslint": "^8.39.0",
|
"eslint": "^8.39.0",
|
||||||
"eslint-plugin-deprecation": "^1.4.1",
|
"eslint-plugin-deprecation": "^1.5.0",
|
||||||
"eslint-plugin-import": "^2.27.5",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jsdoc": "^39.6.4",
|
"eslint-plugin-jsdoc": "^45.0.0",
|
||||||
"eslint-plugin-jsonc": "^2.6.0",
|
"eslint-plugin-jsonc": "^2.20.1",
|
||||||
"eslint-plugin-lodash": "^7.4.0",
|
"eslint-plugin-lodash": "^7.4.0",
|
||||||
"eslint-plugin-unused-imports": "^2.0.0",
|
"eslint-plugin-unused-imports": "^2.0.0",
|
||||||
"express-static-gzip": "^2.1.7",
|
"express-static-gzip": "^2.2.0",
|
||||||
"jasmine-core": "^3.8.0",
|
"jasmine-core": "^3.8.0",
|
||||||
"jasmine-marbles": "0.9.2",
|
"jasmine-marbles": "0.9.2",
|
||||||
"karma": "^6.4.2",
|
"karma": "^6.4.4",
|
||||||
"karma-chrome-launcher": "~3.2.0",
|
"karma-chrome-launcher": "~3.2.0",
|
||||||
"karma-coverage-istanbul-reporter": "~3.0.3",
|
"karma-coverage-istanbul-reporter": "~3.0.3",
|
||||||
"karma-jasmine": "~4.0.0",
|
"karma-jasmine": "~4.0.0",
|
||||||
"karma-jasmine-html-reporter": "^1.5.0",
|
"karma-jasmine-html-reporter": "^1.5.0",
|
||||||
"karma-mocha-reporter": "2.2.5",
|
"karma-mocha-reporter": "2.2.5",
|
||||||
|
"ng-mocks": "^14.13.4",
|
||||||
"ngx-mask": "^13.1.7",
|
"ngx-mask": "^13.1.7",
|
||||||
"nodemon": "^2.0.22",
|
"nodemon": "^2.0.22",
|
||||||
"postcss": "^8.4",
|
"postcss": "^8.5",
|
||||||
"postcss-apply": "0.12.0",
|
|
||||||
"postcss-import": "^14.0.0",
|
"postcss-import": "^14.0.0",
|
||||||
"postcss-loader": "^4.0.3",
|
"postcss-loader": "^4.0.3",
|
||||||
"postcss-preset-env": "^7.4.2",
|
"postcss-preset-env": "^7.4.2",
|
||||||
"postcss-responsive-type": "1.0.0",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
"react-dom": "^16.14.0",
|
"react-dom": "^16.14.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs-spy": "^8.0.2",
|
"sass": "~1.89.0",
|
||||||
"sass": "~1.62.0",
|
|
||||||
"sass-loader": "^12.6.0",
|
"sass-loader": "^12.6.0",
|
||||||
"sass-resources-loader": "^2.2.5",
|
"sass-resources-loader": "^2.2.5",
|
||||||
"ts-node": "^8.10.2",
|
"ts-node": "^8.10.2",
|
||||||
"typescript": "~4.8.4",
|
"typescript": "~4.8.4",
|
||||||
"webpack": "5.76.1",
|
"webpack": "5.76.1",
|
||||||
"webpack-bundle-analyzer": "^4.8.0",
|
|
||||||
"webpack-cli": "^4.2.0",
|
"webpack-cli": "^4.2.0",
|
||||||
"webpack-dev-server": "^4.13.3"
|
"webpack-dev-server": "^4.15.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
require('postcss-import')(),
|
require('postcss-import')(),
|
||||||
require('postcss-preset-env')(),
|
require('postcss-preset-env')()
|
||||||
require('postcss-apply')(),
|
|
||||||
require('postcss-responsive-type')()
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
78
server.ts
78
server.ts
@@ -28,10 +28,11 @@ import * as expressStaticGzip from 'express-static-gzip';
|
|||||||
/* eslint-enable import/no-namespace */
|
/* eslint-enable import/no-namespace */
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import LRU from 'lru-cache';
|
import LRU from 'lru-cache';
|
||||||
import isbot from 'isbot';
|
import { isbot } from 'isbot';
|
||||||
import { createCertificate } from 'pem';
|
import { createCertificate } from 'pem';
|
||||||
import { createServer } from 'https';
|
import { createServer } from 'https';
|
||||||
import { json } from 'body-parser';
|
import { json } from 'body-parser';
|
||||||
|
import { createHttpTerminator } from 'http-terminator';
|
||||||
|
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@@ -54,6 +55,7 @@ import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
|
|||||||
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
||||||
import { logStartupMessage } from './startup-message';
|
import { logStartupMessage } from './startup-message';
|
||||||
import { TOKENITEM } from './src/app/core/auth/models/auth-token-info.model';
|
import { TOKENITEM } from './src/app/core/auth/models/auth-token-info.model';
|
||||||
|
import { SsrExcludePatterns } from './src/config/universal-config.interface';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -78,6 +80,9 @@ let anonymousCache: LRU<string, any>;
|
|||||||
// extend environment with app config for server
|
// extend environment with app config for server
|
||||||
extendEnvironmentWithAppConfig(environment, appConfig);
|
extendEnvironmentWithAppConfig(environment, appConfig);
|
||||||
|
|
||||||
|
// The REST server base URL
|
||||||
|
const REST_BASE_URL = environment.rest.ssrBaseUrl || environment.rest.baseUrl;
|
||||||
|
|
||||||
// The Express app is exported so that it can be used by serverless Functions.
|
// The Express app is exported so that it can be used by serverless Functions.
|
||||||
export function app() {
|
export function app() {
|
||||||
|
|
||||||
@@ -130,6 +135,7 @@ export function app() {
|
|||||||
server.engine('html', (_, options, callback) =>
|
server.engine('html', (_, options, callback) =>
|
||||||
ngExpressEngine({
|
ngExpressEngine({
|
||||||
bootstrap: ServerAppModule,
|
bootstrap: ServerAppModule,
|
||||||
|
inlineCriticalCss: environment.universal.inlineCriticalCss,
|
||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: REQUEST,
|
provide: REQUEST,
|
||||||
@@ -174,7 +180,7 @@ export function app() {
|
|||||||
* Proxy the sitemaps
|
* Proxy the sitemaps
|
||||||
*/
|
*/
|
||||||
router.use('/sitemap**', createProxyMiddleware({
|
router.use('/sitemap**', createProxyMiddleware({
|
||||||
target: `${environment.rest.baseUrl}/sitemaps`,
|
target: `${REST_BASE_URL}/sitemaps`,
|
||||||
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
}));
|
}));
|
||||||
@@ -183,7 +189,7 @@ export function app() {
|
|||||||
* Proxy the linksets
|
* Proxy the linksets
|
||||||
*/
|
*/
|
||||||
router.use('/signposting**', createProxyMiddleware({
|
router.use('/signposting**', createProxyMiddleware({
|
||||||
target: `${environment.rest.baseUrl}`,
|
target: `${REST_BASE_URL}`,
|
||||||
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
}));
|
}));
|
||||||
@@ -236,7 +242,7 @@ export function app() {
|
|||||||
* The callback function to serve server side angular
|
* The callback function to serve server side angular
|
||||||
*/
|
*/
|
||||||
function ngApp(req, res) {
|
function ngApp(req, res) {
|
||||||
if (environment.universal.preboot) {
|
if (environment.universal.preboot && req.method === 'GET' && (req.path === '/' || !isExcludedFromSsr(req.path, environment.universal.excludePathPatterns))) {
|
||||||
// Render the page to user via SSR (server side rendering)
|
// Render the page to user via SSR (server side rendering)
|
||||||
serverSideRender(req, res);
|
serverSideRender(req, res);
|
||||||
} else {
|
} else {
|
||||||
@@ -267,6 +273,11 @@ function serverSideRender(req, res, sendToUser: boolean = true) {
|
|||||||
requestUrl: req.originalUrl,
|
requestUrl: req.originalUrl,
|
||||||
}, (err, data) => {
|
}, (err, data) => {
|
||||||
if (hasNoValue(err) && hasValue(data)) {
|
if (hasNoValue(err) && hasValue(data)) {
|
||||||
|
// Replace REST URL with UI URL
|
||||||
|
if (environment.universal.replaceRestUrl && REST_BASE_URL !== environment.rest.baseUrl) {
|
||||||
|
data = data.replace(new RegExp(REST_BASE_URL, 'g'), environment.rest.baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
// save server side rendered page to cache (if any are enabled)
|
// save server side rendered page to cache (if any are enabled)
|
||||||
saveToCache(req, data);
|
saveToCache(req, data);
|
||||||
if (sendToUser) {
|
if (sendToUser) {
|
||||||
@@ -320,22 +331,23 @@ function initCache() {
|
|||||||
if (botCacheEnabled()) {
|
if (botCacheEnabled()) {
|
||||||
// Initialize a new "least-recently-used" item cache (where least recently used pages are removed first)
|
// Initialize a new "least-recently-used" item cache (where least recently used pages are removed first)
|
||||||
// See https://www.npmjs.com/package/lru-cache
|
// See https://www.npmjs.com/package/lru-cache
|
||||||
// When enabled, each page defaults to expiring after 1 day
|
// When enabled, each page defaults to expiring after 1 day (defined in default-app-config.ts)
|
||||||
botCache = new LRU( {
|
botCache = new LRU( {
|
||||||
max: environment.cache.serverSide.botCache.max,
|
max: environment.cache.serverSide.botCache.max,
|
||||||
ttl: environment.cache.serverSide.botCache.timeToLive || 24 * 60 * 60 * 1000, // 1 day
|
ttl: environment.cache.serverSide.botCache.timeToLive,
|
||||||
allowStale: environment.cache.serverSide.botCache.allowStale ?? true // if object is stale, return stale value before deleting
|
allowStale: environment.cache.serverSide.botCache.allowStale
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anonymousCacheEnabled()) {
|
if (anonymousCacheEnabled()) {
|
||||||
// NOTE: While caches may share SSR pages, this cache must be kept separately because the timeToLive
|
// NOTE: While caches may share SSR pages, this cache must be kept separately because the timeToLive
|
||||||
// may expire pages more frequently.
|
// may expire pages more frequently.
|
||||||
// When enabled, each page defaults to expiring after 10 seconds (to minimize anonymous users seeing out-of-date content)
|
// When enabled, each page defaults to expiring after 10 seconds (defined in default-app-config.ts)
|
||||||
|
// to minimize anonymous users seeing out-of-date content
|
||||||
anonymousCache = new LRU( {
|
anonymousCache = new LRU( {
|
||||||
max: environment.cache.serverSide.anonymousCache.max,
|
max: environment.cache.serverSide.anonymousCache.max,
|
||||||
ttl: environment.cache.serverSide.anonymousCache.timeToLive || 10 * 1000, // 10 seconds
|
ttl: environment.cache.serverSide.anonymousCache.timeToLive,
|
||||||
allowStale: environment.cache.serverSide.anonymousCache.allowStale ?? true // if object is stale, return stale value before deleting
|
allowStale: environment.cache.serverSide.anonymousCache.allowStale
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,7 +499,7 @@ function saveToCache(req, page: any) {
|
|||||||
*/
|
*/
|
||||||
function hasNotSucceeded(statusCode) {
|
function hasNotSucceeded(statusCode) {
|
||||||
const rgx = new RegExp(/^20+/);
|
const rgx = new RegExp(/^20+/);
|
||||||
return !rgx.test(statusCode)
|
return !rgx.test(statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function retrieveHeaders(response) {
|
function retrieveHeaders(response) {
|
||||||
@@ -525,23 +537,46 @@ function serverStarted() {
|
|||||||
* @param keys SSL credentials
|
* @param keys SSL credentials
|
||||||
*/
|
*/
|
||||||
function createHttpsServer(keys) {
|
function createHttpsServer(keys) {
|
||||||
createServer({
|
const listener = createServer({
|
||||||
key: keys.serviceKey,
|
key: keys.serviceKey,
|
||||||
cert: keys.certificate
|
cert: keys.certificate
|
||||||
}, app).listen(environment.ui.port, environment.ui.host, () => {
|
}, app).listen(environment.ui.port, environment.ui.host, () => {
|
||||||
serverStarted();
|
serverStarted();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Graceful shutdown when signalled
|
||||||
|
const terminator = createHttpTerminator({server: listener});
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
void (async ()=> {
|
||||||
|
console.debug('Closing HTTPS server on signal');
|
||||||
|
await terminator.terminate().catch(e => { console.error(e); });
|
||||||
|
console.debug('HTTPS server closed');
|
||||||
|
})();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an HTTP server with the configured port and host.
|
||||||
|
*/
|
||||||
function run() {
|
function run() {
|
||||||
const port = environment.ui.port || 4000;
|
const port = environment.ui.port || 4000;
|
||||||
const host = environment.ui.host || '/';
|
const host = environment.ui.host || '/';
|
||||||
|
|
||||||
// Start up the Node server
|
// Start up the Node server
|
||||||
const server = app();
|
const server = app();
|
||||||
server.listen(port, host, () => {
|
const listener = server.listen(port, host, () => {
|
||||||
serverStarted();
|
serverStarted();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Graceful shutdown when signalled
|
||||||
|
const terminator = createHttpTerminator({server: listener});
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
void (async () => {
|
||||||
|
console.debug('Closing HTTP server on signal');
|
||||||
|
await terminator.terminate().catch(e => { console.error(e); });
|
||||||
|
console.debug('HTTP server closed.');return undefined;
|
||||||
|
})();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
@@ -591,11 +626,26 @@ function start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if SSR should be skipped for path
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
* @param excludePathPattern
|
||||||
|
*/
|
||||||
|
function isExcludedFromSsr(path: string, excludePathPattern: SsrExcludePatterns[]): boolean {
|
||||||
|
const patterns = excludePathPattern.map(p =>
|
||||||
|
new RegExp(p.pattern, p.flag || '')
|
||||||
|
);
|
||||||
|
return patterns.some((regex) => {
|
||||||
|
return regex.test(path)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The callback function to serve health check requests
|
* The callback function to serve health check requests
|
||||||
*/
|
*/
|
||||||
function healthCheck(req, res) {
|
function healthCheck(req, res) {
|
||||||
const baseUrl = `${environment.rest.baseUrl}${environment.actuators.endpointPath}`;
|
const baseUrl = `${REST_BASE_URL}${environment.actuators.endpointPath}`;
|
||||||
axios.get(baseUrl)
|
axios.get(baseUrl)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
res.status(response.status).send(response.data);
|
res.status(response.status).send(response.data);
|
||||||
|
@@ -1,12 +1,22 @@
|
|||||||
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
import { URLCombiner } from '../core/url-combiner/url-combiner';
|
||||||
import { getAccessControlModuleRoute } from '../app-routing-paths';
|
import { getAccessControlModuleRoute } from '../app-routing-paths';
|
||||||
|
|
||||||
export const GROUP_EDIT_PATH = 'groups';
|
export const EPERSON_PATH = 'epeople';
|
||||||
|
|
||||||
|
export function getEPersonsRoute(): string {
|
||||||
|
return new URLCombiner(getAccessControlModuleRoute(), EPERSON_PATH).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getEPersonEditRoute(id: string): string {
|
||||||
|
return new URLCombiner(getEPersonsRoute(), id, 'edit').toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GROUP_PATH = 'groups';
|
||||||
|
|
||||||
export function getGroupsRoute() {
|
export function getGroupsRoute() {
|
||||||
return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH).toString();
|
return new URLCombiner(getAccessControlModuleRoute(), GROUP_PATH).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGroupEditRoute(id: string) {
|
export function getGroupEditRoute(id: string) {
|
||||||
return new URLCombiner(getAccessControlModuleRoute(), GROUP_EDIT_PATH, id).toString();
|
return new URLCombiner(getGroupsRoute(), id, 'edit').toString();
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ import { RouterModule } from '@angular/router';
|
|||||||
import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.component';
|
import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.component';
|
||||||
import { GroupFormComponent } from './group-registry/group-form/group-form.component';
|
import { GroupFormComponent } from './group-registry/group-form/group-form.component';
|
||||||
import { GroupsRegistryComponent } from './group-registry/groups-registry.component';
|
import { GroupsRegistryComponent } from './group-registry/groups-registry.component';
|
||||||
import { GROUP_EDIT_PATH } from './access-control-routing-paths';
|
import { EPERSON_PATH, GROUP_PATH } from './access-control-routing-paths';
|
||||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
import { GroupPageGuard } from './group-registry/group-page.guard';
|
import { GroupPageGuard } from './group-registry/group-page.guard';
|
||||||
import {
|
import {
|
||||||
@@ -13,12 +13,14 @@ import {
|
|||||||
SiteAdministratorGuard
|
SiteAdministratorGuard
|
||||||
} from '../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
} from '../core/data/feature-authorization/feature-authorization-guard/site-administrator.guard';
|
||||||
import { BulkAccessComponent } from './bulk-access/bulk-access.component';
|
import { BulkAccessComponent } from './bulk-access/bulk-access.component';
|
||||||
|
import { EPersonFormComponent } from './epeople-registry/eperson-form/eperson-form.component';
|
||||||
|
import { EPersonResolver } from './epeople-registry/eperson-resolver.service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild([
|
RouterModule.forChild([
|
||||||
{
|
{
|
||||||
path: 'epeople',
|
path: EPERSON_PATH,
|
||||||
component: EPeopleRegistryComponent,
|
component: EPeopleRegistryComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
breadcrumb: I18nBreadcrumbResolver
|
breadcrumb: I18nBreadcrumbResolver
|
||||||
@@ -27,7 +29,26 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
|
|||||||
canActivate: [SiteAdministratorGuard]
|
canActivate: [SiteAdministratorGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: GROUP_EDIT_PATH,
|
path: `${EPERSON_PATH}/create`,
|
||||||
|
component: EPersonFormComponent,
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: { title: 'admin.access-control.epeople.add.title', breadcrumbKey: 'admin.access-control.epeople.add' },
|
||||||
|
canActivate: [SiteAdministratorGuard],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: `${EPERSON_PATH}/:id/edit`,
|
||||||
|
component: EPersonFormComponent,
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
|
ePerson: EPersonResolver,
|
||||||
|
},
|
||||||
|
data: { title: 'admin.access-control.epeople.edit.title', breadcrumbKey: 'admin.access-control.epeople.edit' },
|
||||||
|
canActivate: [SiteAdministratorGuard],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: GROUP_PATH,
|
||||||
component: GroupsRegistryComponent,
|
component: GroupsRegistryComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
breadcrumb: I18nBreadcrumbResolver
|
breadcrumb: I18nBreadcrumbResolver
|
||||||
@@ -36,7 +57,7 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
|
|||||||
canActivate: [GroupAdministratorGuard]
|
canActivate: [GroupAdministratorGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${GROUP_EDIT_PATH}/newGroup`,
|
path: `${GROUP_PATH}/create`,
|
||||||
component: GroupFormComponent,
|
component: GroupFormComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
breadcrumb: I18nBreadcrumbResolver
|
breadcrumb: I18nBreadcrumbResolver
|
||||||
@@ -45,7 +66,7 @@ import { BulkAccessComponent } from './bulk-access/bulk-access.component';
|
|||||||
canActivate: [GroupAdministratorGuard]
|
canActivate: [GroupAdministratorGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${GROUP_EDIT_PATH}/:groupId`,
|
path: `${GROUP_PATH}/:groupId/edit`,
|
||||||
component: GroupFormComponent,
|
component: GroupFormComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
breadcrumb: I18nBreadcrumbResolver
|
breadcrumb: I18nBreadcrumbResolver
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
<ngb-accordion #acc="ngbAccordion" [activeIds]="'browse'">
|
<ngb-accordion #acc="ngbAccordion" [activeIds]="'browse'">
|
||||||
<ngb-panel [id]="'browse'">
|
<ngb-panel [id]="'browse'">
|
||||||
<ng-template ngbPanelHeader>
|
<ng-template ngbPanelHeader>
|
||||||
<div class="w-100 d-flex justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle('browse')"
|
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle('browse')"
|
||||||
data-test="browse">
|
data-test="browse">
|
||||||
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()"
|
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()"
|
||||||
[attr.aria-expanded]="!acc.isExpanded('browse')"
|
[attr.aria-expanded]="acc.isExpanded('browse')"
|
||||||
aria-controls="collapsePanels">
|
aria-controls="bulk-access-browse-panel-content">
|
||||||
{{ 'admin.access-control.bulk-access-browse.header' | translate }}
|
{{ 'admin.access-control.bulk-access-browse.header' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<div class="text-right d-flex">
|
<div class="text-right d-flex gap-2">
|
||||||
<div class="ml-3 d-inline-block">
|
<div class="d-flex my-auto">
|
||||||
<span *ngIf="acc.isExpanded('browse')" class="fas fa-chevron-up fa-fw"></span>
|
<span *ngIf="acc.isExpanded('browse')" class="fas fa-chevron-up fa-fw"></span>
|
||||||
<span *ngIf="!acc.isExpanded('browse')" class="fas fa-chevron-down fa-fw"></span>
|
<span *ngIf="!acc.isExpanded('browse')" class="fas fa-chevron-down fa-fw"></span>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,51 +17,52 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template ngbPanelContent>
|
<ng-template ngbPanelContent>
|
||||||
<ul ngbNav #nav="ngbNav" [(activeId)]="activateId" class="nav-pills">
|
<div id="bulk-access-browse-panel-content">
|
||||||
<li [ngbNavItem]="'search'">
|
<ul ngbNav #nav="ngbNav" [(activeId)]="activateId" class="nav-pills">
|
||||||
<a ngbNavLink>{{'admin.access-control.bulk-access-browse.search.header' | translate}}</a>
|
<li [ngbNavItem]="'search'" role="presentation">
|
||||||
<ng-template ngbNavContent>
|
<a ngbNavLink>{{'admin.access-control.bulk-access-browse.search.header' | translate}}</a>
|
||||||
<div class="mx-n3">
|
<ng-template ngbNavContent>
|
||||||
<ds-themed-search [configuration]="'administrativeBulkAccess'"
|
<div class="mx-n3">
|
||||||
[selectable]="true"
|
<ds-themed-search [configuration]="'administrativeBulkAccess'"
|
||||||
[selectionConfig]="{ repeatable: true, listId: listId }"
|
[selectable]="true"
|
||||||
[showThumbnails]="false"></ds-themed-search>
|
[selectionConfig]="{ repeatable: true, listId: listId }"
|
||||||
</div>
|
[showThumbnails]="false"></ds-themed-search>
|
||||||
</ng-template>
|
</div>
|
||||||
</li>
|
</ng-template>
|
||||||
<li [ngbNavItem]="'selected'">
|
</li>
|
||||||
<a ngbNavLink>
|
<li [ngbNavItem]="'selected'" role="presentation">
|
||||||
{{'admin.access-control.bulk-access-browse.selected.header' | translate: {number: ((objectsSelected$ | async)?.payload?.totalElements) ? (objectsSelected$ | async)?.payload?.totalElements : '0'} }}
|
<a ngbNavLink>
|
||||||
</a>
|
{{'admin.access-control.bulk-access-browse.selected.header' | translate: {number: ((objectsSelected$ | async)?.payload?.totalElements) ? (objectsSelected$ | async)?.payload?.totalElements : '0'} }}
|
||||||
<ng-template ngbNavContent>
|
</a>
|
||||||
<ds-pagination
|
<ng-template ngbNavContent>
|
||||||
[paginationOptions]="(paginationOptions$ | async)"
|
<ds-pagination
|
||||||
[pageInfoState]="(objectsSelected$|async)?.payload.pageInfo"
|
[paginationOptions]="(paginationOptions$ | async)"
|
||||||
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
|
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
|
||||||
[objects]="(objectsSelected$|async)"
|
[objects]="(objectsSelected$|async)"
|
||||||
[showPaginator]="false"
|
[showPaginator]="false"
|
||||||
(prev)="pagePrev()"
|
(prev)="pagePrev()"
|
||||||
(next)="pageNext()">
|
(next)="pageNext()">
|
||||||
<ul *ngIf="(objectsSelected$|async)?.hasSucceeded" class="list-unstyled ml-4">
|
<ul *ngIf="(objectsSelected$|async)?.hasSucceeded" class="list-unstyled ml-4">
|
||||||
<li *ngFor='let object of (objectsSelected$|async)?.payload?.page | paginate: { itemsPerPage: (paginationOptions$ | async).pageSize,
|
<li *ngFor='let object of (objectsSelected$|async)?.payload?.page | paginate: { itemsPerPage: (paginationOptions$ | async).pageSize,
|
||||||
currentPage: (paginationOptions$ | async).currentPage, totalItems: (objectsSelected$|async)?.payload?.page.length }; let i = index; let last = last '
|
currentPage: (paginationOptions$ | async).currentPage, totalItems: (objectsSelected$|async)?.payload?.page.length }; let i = index; let last = last '
|
||||||
class="mt-4 mb-4 d-flex"
|
class="mt-4 mb-4 d-flex"
|
||||||
[attr.data-test]="'list-object' | dsBrowserOnly">
|
[attr.data-test]="'list-object' | dsBrowserOnly">
|
||||||
<ds-selectable-list-item-control [index]="i"
|
<ds-selectable-list-item-control [index]="i"
|
||||||
[object]="object"
|
[object]="object"
|
||||||
[selectionConfig]="{ repeatable: true, listId: listId }"></ds-selectable-list-item-control>
|
[selectionConfig]="{ repeatable: true, listId: listId }"></ds-selectable-list-item-control>
|
||||||
<ds-listable-object-component-loader [listID]="listId"
|
<ds-listable-object-component-loader [listID]="listId"
|
||||||
[index]="i"
|
[index]="i"
|
||||||
[object]="object"
|
[object]="object"
|
||||||
[showThumbnails]="false"
|
[showThumbnails]="false"
|
||||||
[viewMode]="'list'"></ds-listable-object-component-loader>
|
[viewMode]="'list'"></ds-listable-object-component-loader>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ds-pagination>
|
</ds-pagination>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div [ngbNavOutlet]="nav" class="mt-5"></div>
|
<div [ngbNavOutlet]="nav" class="mt-5"></div>
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngb-panel>
|
</ngb-panel>
|
||||||
</ngb-accordion>
|
</ngb-accordion>
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
|
<h1>{{ 'admin.access-control.bulk-access.title' | translate }}</h1>
|
||||||
<ds-bulk-access-browse [listId]="listId"></ds-bulk-access-browse>
|
<ds-bulk-access-browse [listId]="listId"></ds-bulk-access-browse>
|
||||||
<div class="clearfix mb-3"></div>
|
<div class="clearfix mb-3"></div>
|
||||||
<ds-bulk-access-settings #dsBulkSettings ></ds-bulk-access-settings>
|
<ds-bulk-access-settings #dsBulkSettings ></ds-bulk-access-settings>
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
<button class="btn btn-outline-primary mr-3" (click)="reset()">
|
<button class="btn btn-outline-primary mr-3" (click)="reset()">
|
||||||
{{ 'access-control-cancel' | translate }}
|
{{ 'access-control-cancel' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-primary" [disabled]="!canExport()" (click)="submit()">
|
<button class="btn btn-primary" [dsBtnDisabled]="!canExport()" (click)="submit()">
|
||||||
{{ 'access-control-execute' | translate }}
|
{{ 'access-control-execute' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA, Component } from '@angular/core';
|
||||||
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -57,10 +57,15 @@ describe('BulkAccessComponent', () => {
|
|||||||
'file': { }
|
'file': { }
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockSettings: any = jasmine.createSpyObj('AccessControlFormContainerComponent', {
|
@Component({
|
||||||
getValue: jasmine.createSpy('getValue'),
|
selector: 'ds-bulk-access-settings',
|
||||||
reset: jasmine.createSpy('reset')
|
template: ''
|
||||||
});
|
})
|
||||||
|
class MockBulkAccessSettingsComponent {
|
||||||
|
isFormValid = jasmine.createSpy('isFormValid').and.returnValue(false);
|
||||||
|
getValue = jasmine.createSpy('getValue');
|
||||||
|
reset = jasmine.createSpy('reset');
|
||||||
|
}
|
||||||
const selection: any[] = [{ indexableObject: { uuid: '1234' } }, { indexableObject: { uuid: '5678' } }];
|
const selection: any[] = [{ indexableObject: { uuid: '1234' } }, { indexableObject: { uuid: '5678' } }];
|
||||||
const selectableListState: SelectableListState = { id: 'test', selection };
|
const selectableListState: SelectableListState = { id: 'test', selection };
|
||||||
const expectedIdList = ['1234', '5678'];
|
const expectedIdList = ['1234', '5678'];
|
||||||
@@ -73,7 +78,10 @@ describe('BulkAccessComponent', () => {
|
|||||||
RouterTestingModule,
|
RouterTestingModule,
|
||||||
TranslateModule.forRoot()
|
TranslateModule.forRoot()
|
||||||
],
|
],
|
||||||
declarations: [ BulkAccessComponent ],
|
declarations: [
|
||||||
|
BulkAccessComponent,
|
||||||
|
MockBulkAccessSettingsComponent,
|
||||||
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: BulkAccessControlService, useValue: bulkAccessControlServiceMock },
|
{ provide: BulkAccessControlService, useValue: bulkAccessControlServiceMock },
|
||||||
{ provide: NotificationsService, useValue: NotificationsServiceStub },
|
{ provide: NotificationsService, useValue: NotificationsServiceStub },
|
||||||
@@ -102,7 +110,6 @@ describe('BulkAccessComponent', () => {
|
|||||||
|
|
||||||
(component as any).selectableListService.getSelectableList.and.returnValue(of(selectableListStateEmpty));
|
(component as any).selectableListService.getSelectableList.and.returnValue(of(selectableListStateEmpty));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.settings = mockSettings;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
@@ -119,13 +126,12 @@ describe('BulkAccessComponent', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when there are elements selected', () => {
|
describe('when there are elements selected and step two form is invalid', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
(component as any).selectableListService.getSelectableList.and.returnValue(of(selectableListState));
|
(component as any).selectableListService.getSelectableList.and.returnValue(of(selectableListState));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.settings = mockSettings;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create', () => {
|
it('should create', () => {
|
||||||
@@ -136,9 +142,9 @@ describe('BulkAccessComponent', () => {
|
|||||||
expect(component.objectsSelected$.value).toEqual(expectedIdList);
|
expect(component.objectsSelected$.value).toEqual(expectedIdList);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should enable the execute button when there are objects selected', () => {
|
it('should not enable the execute button when there are objects selected and step two form is invalid', () => {
|
||||||
component.objectsSelected$.next(['1234']);
|
component.objectsSelected$.next(['1234']);
|
||||||
expect(component.canExport()).toBe(true);
|
expect(component.canExport()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the settings reset method when reset is called', () => {
|
it('should call the settings reset method when reset is called', () => {
|
||||||
@@ -146,6 +152,23 @@ describe('BulkAccessComponent', () => {
|
|||||||
expect(component.settings.reset).toHaveBeenCalled();
|
expect(component.settings.reset).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when there are elements selectedted and the step two form is valid', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
|
||||||
|
(component as any).selectableListService.getSelectableList.and.returnValue(of(selectableListState));
|
||||||
|
fixture.detectChanges();
|
||||||
|
(component as any).settings.isFormValid.and.returnValue(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should enable the execute button when there are objects selected and step two form is valid', () => {
|
||||||
|
component.objectsSelected$.next(['1234']);
|
||||||
|
expect(component.canExport()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('should call the bulkAccessControlService executeScript method when submit is called', () => {
|
it('should call the bulkAccessControlService executeScript method when submit is called', () => {
|
||||||
(component.settings as any).getValue.and.returnValue(mockFormState);
|
(component.settings as any).getValue.and.returnValue(mockFormState);
|
||||||
bulkAccessControlService.createPayloadFile.and.returnValue(mockFile);
|
bulkAccessControlService.createPayloadFile.and.returnValue(mockFile);
|
||||||
|
@@ -37,7 +37,7 @@ export class BulkAccessComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private bulkAccessControlService: BulkAccessControlService,
|
private bulkAccessControlService: BulkAccessControlService,
|
||||||
private selectableListService: SelectableListService
|
private selectableListService: SelectableListService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export class BulkAccessComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canExport(): boolean {
|
canExport(): boolean {
|
||||||
return this.objectsSelected$.value?.length > 0;
|
return this.objectsSelected$.value?.length > 0 && this.settings?.isFormValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
<ngb-accordion #acc="ngbAccordion" [activeIds]="'settings'">
|
<ngb-accordion #acc="ngbAccordion" [activeIds]="'settings'">
|
||||||
<ngb-panel [id]="'settings'">
|
<ngb-panel [id]="'settings'">
|
||||||
<ng-template ngbPanelHeader>
|
<ng-template ngbPanelHeader>
|
||||||
<div class="w-100 d-flex justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle('settings')" data-test="settings">
|
<div class="w-100 d-flex gap-3 justify-content-between collapse-toggle" ngbPanelToggle (click)="acc.toggle('settings')" data-test="settings">
|
||||||
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="!acc.isExpanded('browse')"
|
<button type="button" class="btn btn-link p-0" (click)="$event.preventDefault()" [attr.aria-expanded]="acc.isExpanded('settings')"
|
||||||
aria-controls="collapsePanels">
|
aria-controls="bulk-access-settings-panel-content">
|
||||||
{{ 'admin.access-control.bulk-access-settings.header' | translate }}
|
{{ 'admin.access-control.bulk-access-settings.header' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<div class="text-right d-flex">
|
<div class="text-right d-flex gap-2">
|
||||||
<div class="ml-3 d-inline-block">
|
<div class="d-flex my-auto">
|
||||||
<span *ngIf="acc.isExpanded('settings')" class="fas fa-chevron-up fa-fw"></span>
|
<span *ngIf="acc.isExpanded('settings')" class="fas fa-chevron-up fa-fw"></span>
|
||||||
<span *ngIf="!acc.isExpanded('settings')" class="fas fa-chevron-down fa-fw"></span>
|
<span *ngIf="!acc.isExpanded('settings')" class="fas fa-chevron-down fa-fw"></span>
|
||||||
</div>
|
</div>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template ngbPanelContent>
|
<ng-template ngbPanelContent>
|
||||||
<ds-access-control-form-container #dsAccessControlForm [showSubmit]="false"></ds-access-control-form-container>
|
<ds-access-control-form-container id="bulk-access-settings-panel-content" #dsAccessControlForm [showSubmit]="false"></ds-access-control-form-container>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngb-panel>
|
</ngb-panel>
|
||||||
</ngb-accordion>
|
</ngb-accordion>
|
||||||
|
@@ -31,4 +31,8 @@ export class BulkAccessSettingsComponent {
|
|||||||
this.controlForm.reset();
|
this.controlForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isFormValid() {
|
||||||
|
return this.controlForm.isValid();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,98 +2,92 @@
|
|||||||
<div class="epeople-registry row">
|
<div class="epeople-registry row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="d-flex justify-content-between border-bottom mb-3">
|
<div class="d-flex justify-content-between border-bottom mb-3">
|
||||||
<h2 id="header" class="pb-2">{{labelPrefix + 'head' | translate}}</h2>
|
<h1 id="header" class="pb-2">{{labelPrefix + 'head' | translate}}</h1>
|
||||||
|
|
||||||
<div *ngIf="!isEPersonFormShown">
|
<div>
|
||||||
<button class="mr-auto btn btn-success addEPerson-button"
|
<button class="mr-auto btn btn-success addEPerson-button"
|
||||||
(click)="isEPersonFormShown = true">
|
[routerLink]="'create'">
|
||||||
<i class="fas fa-plus"></i>
|
<i class="fas fa-plus"></i>
|
||||||
<span class="d-none d-sm-inline ml-1">{{labelPrefix + 'button.add' | translate}}</span>
|
<span class="d-none d-sm-inline ml-1">{{labelPrefix + 'button.add' | translate}}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ds-eperson-form *ngIf="isEPersonFormShown" (submitForm)="reset()"
|
<h2 id="search" class="border-bottom pb-2">
|
||||||
(cancelForm)="isEPersonFormShown = false"></ds-eperson-form>
|
{{labelPrefix + 'search.head' | translate}}
|
||||||
|
</h2>
|
||||||
<div *ngIf="!isEPersonFormShown">
|
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
||||||
<h3 id="search" class="border-bottom pb-2">{{labelPrefix + 'search.head' | translate}}
|
<div>
|
||||||
|
<select name="scope" id="scope" formControlName="scope" class="form-control" aria-label="Search scope">
|
||||||
</h3>
|
<option value="metadata">{{labelPrefix + 'search.scope.metadata' | translate}}</option>
|
||||||
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
<option value="email">{{labelPrefix + 'search.scope.email' | translate}}</option>
|
||||||
<div>
|
</select>
|
||||||
<select name="scope" id="scope" formControlName="scope" class="form-control" aria-label="Search scope">
|
</div>
|
||||||
<option value="metadata">{{labelPrefix + 'search.scope.metadata' | translate}}</option>
|
<div class="flex-grow-1 mr-3 ml-3">
|
||||||
<option value="email">{{labelPrefix + 'search.scope.email' | translate}}</option>
|
<div class="form-group input-group">
|
||||||
</select>
|
<input type="text" name="query" id="query" formControlName="query"
|
||||||
</div>
|
class="form-control" [attr.aria-label]="labelPrefix + 'search.placeholder' | translate"
|
||||||
<div class="flex-grow-1 mr-3 ml-3">
|
[placeholder]="(labelPrefix + 'search.placeholder' | translate)">
|
||||||
<div class="form-group input-group">
|
<span class="input-group-append">
|
||||||
<input type="text" name="query" id="query" formControlName="query"
|
|
||||||
class="form-control" [attr.aria-label]="labelPrefix + 'search.placeholder' | translate"
|
|
||||||
[placeholder]="(labelPrefix + 'search.placeholder' | translate)">
|
|
||||||
<span class="input-group-append">
|
|
||||||
<button type="submit" class="search-button btn btn-primary">
|
<button type="submit" class="search-button btn btn-primary">
|
||||||
<i class="fas fa-search"></i> {{ labelPrefix + 'search.button' | translate }}
|
<i class="fas fa-search"></i> {{ labelPrefix + 'search.button' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<button (click)="clearFormAndResetResult();"
|
|
||||||
class="search-button btn btn-secondary">{{labelPrefix + 'button.see-all' | translate}}</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ds-themed-loading *ngIf="searching$ | async"></ds-themed-loading>
|
|
||||||
<ds-pagination
|
|
||||||
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(searching$ | async)"
|
|
||||||
[paginationOptions]="config"
|
|
||||||
[pageInfoState]="pageInfoState$"
|
|
||||||
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
|
||||||
[hideGear]="true"
|
|
||||||
[hidePagerWhenSinglePage]="true">
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table id="epeople" class="table table-striped table-hover table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">{{labelPrefix + 'table.id' | translate}}</th>
|
|
||||||
<th scope="col">{{labelPrefix + 'table.name' | translate}}</th>
|
|
||||||
<th scope="col">{{labelPrefix + 'table.email' | translate}}</th>
|
|
||||||
<th>{{labelPrefix + 'table.edit' | translate}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let epersonDto of (ePeopleDto$ | async)?.page"
|
|
||||||
[ngClass]="{'table-primary' : isActive(epersonDto.eperson) | async}">
|
|
||||||
<td>{{epersonDto.eperson.id}}</td>
|
|
||||||
<td>{{ dsoNameService.getName(epersonDto.eperson) }}</td>
|
|
||||||
<td>{{epersonDto.eperson.email}}</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-group edit-field">
|
|
||||||
<button (click)="toggleEditEPerson(epersonDto.eperson)"
|
|
||||||
class="btn btn-outline-primary btn-sm access-control-editEPersonButton"
|
|
||||||
title="{{labelPrefix + 'table.edit.buttons.edit' | translate: { name: dsoNameService.getName(epersonDto.eperson) } }}">
|
|
||||||
<i class="fas fa-edit fa-fw"></i>
|
|
||||||
</button>
|
|
||||||
<button [disabled]="!epersonDto.ableToDelete" (click)="deleteEPerson(epersonDto.eperson)"
|
|
||||||
class="delete-button btn btn-outline-danger btn-sm access-control-deleteEPersonButton"
|
|
||||||
title="{{labelPrefix + 'table.edit.buttons.remove' | translate: { name: dsoNameService.getName(epersonDto.eperson) } }}">
|
|
||||||
<i class="fas fa-trash-alt fa-fw"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</ds-pagination>
|
|
||||||
|
|
||||||
<div *ngIf="(pageInfoState$ | async)?.totalElements == 0" class="alert alert-info w-100 mb-2" role="alert">
|
|
||||||
{{labelPrefix + 'no-items' | translate}}
|
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<button (click)="clearFormAndResetResult();"
|
||||||
|
class="search-button btn btn-secondary">{{labelPrefix + 'button.see-all' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<ds-themed-loading *ngIf="searching$ | async"></ds-themed-loading>
|
||||||
|
<ds-pagination
|
||||||
|
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && !(searching$ | async)"
|
||||||
|
[paginationOptions]="config"
|
||||||
|
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
||||||
|
[hideGear]="true"
|
||||||
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="epeople" class="table table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">{{labelPrefix + 'table.id' | translate}}</th>
|
||||||
|
<th scope="col">{{labelPrefix + 'table.name' | translate}}</th>
|
||||||
|
<th scope="col">{{labelPrefix + 'table.email' | translate}}</th>
|
||||||
|
<th>{{labelPrefix + 'table.edit' | translate}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let epersonDto of (ePeopleDto$ | async)?.page"
|
||||||
|
[ngClass]="{'table-primary' : (activeEPerson$ | async) === epersonDto.eperson}">
|
||||||
|
<td>{{epersonDto.eperson.id}}</td>
|
||||||
|
<td>{{ dsoNameService.getName(epersonDto.eperson) }}</td>
|
||||||
|
<td>{{epersonDto.eperson.email}}</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group edit-field">
|
||||||
|
<button [routerLink]="getEditEPeoplePage(epersonDto.eperson.id)"
|
||||||
|
class="btn btn-outline-primary btn-sm access-control-editEPersonButton"
|
||||||
|
title="{{labelPrefix + 'table.edit.buttons.edit' | translate: { name: dsoNameService.getName(epersonDto.eperson) } }}">
|
||||||
|
<i class="fas fa-edit fa-fw"></i>
|
||||||
|
</button>
|
||||||
|
<button *ngIf="epersonDto.ableToDelete" (click)="deleteEPerson(epersonDto.eperson)"
|
||||||
|
class="delete-button btn btn-outline-danger btn-sm access-control-deleteEPersonButton"
|
||||||
|
title="{{labelPrefix + 'table.edit.buttons.remove' | translate: { name: dsoNameService.getName(epersonDto.eperson) } }}">
|
||||||
|
<i class="fas fa-trash-alt fa-fw"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</ds-pagination>
|
||||||
|
|
||||||
|
<div *ngIf="(pageInfoState$ | async)?.totalElements == 0" class="alert alert-info w-100 mb-2" role="alert">
|
||||||
|
{{labelPrefix + 'no-items' | translate}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -27,6 +27,7 @@ import { RequestService } from '../../core/data/request.service';
|
|||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../core/data/find-list-options.model';
|
||||||
|
import {BtnDisabledDirective} from '../../shared/btn-disabled.directive';
|
||||||
|
|
||||||
describe('EPeopleRegistryComponent', () => {
|
describe('EPeopleRegistryComponent', () => {
|
||||||
let component: EPeopleRegistryComponent;
|
let component: EPeopleRegistryComponent;
|
||||||
@@ -131,7 +132,7 @@ describe('EPeopleRegistryComponent', () => {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
declarations: [EPeopleRegistryComponent],
|
declarations: [EPeopleRegistryComponent, BtnDisabledDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
||||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||||
@@ -203,36 +204,6 @@ describe('EPeopleRegistryComponent', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('toggleEditEPerson', () => {
|
|
||||||
describe('when you click on first edit eperson button', () => {
|
|
||||||
beforeEach(fakeAsync(() => {
|
|
||||||
const editButtons = fixture.debugElement.queryAll(By.css('.access-control-editEPersonButton'));
|
|
||||||
editButtons[0].triggerEventHandler('click', {
|
|
||||||
preventDefault: () => {/**/
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tick();
|
|
||||||
fixture.detectChanges();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('editEPerson form is toggled', () => {
|
|
||||||
const ePeopleIds = fixture.debugElement.queryAll(By.css('#epeople tr td:first-child'));
|
|
||||||
ePersonDataServiceStub.getActiveEPerson().subscribe((activeEPerson: EPerson) => {
|
|
||||||
if (ePeopleIds[0] && activeEPerson === ePeopleIds[0].nativeElement.textContent) {
|
|
||||||
expect(component.isEPersonFormShown).toEqual(false);
|
|
||||||
} else {
|
|
||||||
expect(component.isEPersonFormShown).toEqual(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('EPerson search section is hidden', () => {
|
|
||||||
expect(fixture.debugElement.query(By.css('#search'))).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('deleteEPerson', () => {
|
describe('deleteEPerson', () => {
|
||||||
describe('when you click on first delete eperson button', () => {
|
describe('when you click on first delete eperson button', () => {
|
||||||
let ePeopleIdsFoundBeforeDelete;
|
let ePeopleIdsFoundBeforeDelete;
|
||||||
@@ -269,7 +240,8 @@ describe('EPeopleRegistryComponent', () => {
|
|||||||
it('should be disabled', () => {
|
it('should be disabled', () => {
|
||||||
ePeopleDeleteButton = fixture.debugElement.queryAll(By.css('#epeople tr td div button.delete-button'));
|
ePeopleDeleteButton = fixture.debugElement.queryAll(By.css('#epeople tr td div button.delete-button'));
|
||||||
ePeopleDeleteButton.forEach((deleteButton: DebugElement) => {
|
ePeopleDeleteButton.forEach((deleteButton: DebugElement) => {
|
||||||
expect(deleteButton.nativeElement.disabled).toBe(true);
|
expect(deleteButton.nativeElement.getAttribute('aria-disabled')).toBe('true');
|
||||||
|
expect(deleteButton.nativeElement.classList.contains('disabled')).toBeTrue();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -22,6 +22,7 @@ import { PageInfo } from '../../core/shared/page-info.model';
|
|||||||
import { NoContent } from '../../core/shared/NoContent.model';
|
import { NoContent } from '../../core/shared/NoContent.model';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { getEPersonEditRoute, getEPersonsRoute } from '../access-control-routing-paths';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-epeople-registry',
|
selector: 'ds-epeople-registry',
|
||||||
@@ -45,6 +46,8 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
ePeopleDto$: BehaviorSubject<PaginatedList<EpersonDtoModel>> = new BehaviorSubject<PaginatedList<EpersonDtoModel>>({} as any);
|
ePeopleDto$: BehaviorSubject<PaginatedList<EpersonDtoModel>> = new BehaviorSubject<PaginatedList<EpersonDtoModel>>({} as any);
|
||||||
|
|
||||||
|
activeEPerson$: Observable<EPerson>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An observable for the pageInfo, needed to pass to the pagination component
|
* An observable for the pageInfo, needed to pass to the pagination component
|
||||||
*/
|
*/
|
||||||
@@ -64,11 +67,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
currentPage: 1
|
currentPage: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether or not to show the EPerson form
|
|
||||||
*/
|
|
||||||
isEPersonFormShown: boolean;
|
|
||||||
|
|
||||||
// The search form
|
// The search form
|
||||||
searchForm;
|
searchForm;
|
||||||
|
|
||||||
@@ -114,17 +112,12 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
initialisePage() {
|
initialisePage() {
|
||||||
this.searching$.next(true);
|
this.searching$.next(true);
|
||||||
this.isEPersonFormShown = false;
|
|
||||||
this.search({scope: this.currentSearchScope, query: this.currentSearchQuery});
|
this.search({scope: this.currentSearchScope, query: this.currentSearchQuery});
|
||||||
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
|
this.activeEPerson$ = this.epersonService.getActiveEPerson();
|
||||||
if (eperson != null && eperson.id) {
|
|
||||||
this.isEPersonFormShown = true;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
this.subs.push(this.ePeople$.pipe(
|
this.subs.push(this.ePeople$.pipe(
|
||||||
switchMap((epeople: PaginatedList<EPerson>) => {
|
switchMap((epeople: PaginatedList<EPerson>) => {
|
||||||
if (epeople.pageInfo.totalElements > 0) {
|
if (epeople.pageInfo.totalElements > 0) {
|
||||||
return combineLatest([...epeople.page.map((eperson: EPerson) => {
|
return combineLatest(epeople.page.map((eperson: EPerson) => {
|
||||||
return this.authorizationService.isAuthorized(FeatureID.CanDelete, hasValue(eperson) ? eperson.self : undefined).pipe(
|
return this.authorizationService.isAuthorized(FeatureID.CanDelete, hasValue(eperson) ? eperson.self : undefined).pipe(
|
||||||
map((authorized) => {
|
map((authorized) => {
|
||||||
const epersonDtoModel: EpersonDtoModel = new EpersonDtoModel();
|
const epersonDtoModel: EpersonDtoModel = new EpersonDtoModel();
|
||||||
@@ -133,7 +126,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
return epersonDtoModel;
|
return epersonDtoModel;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})]).pipe(map((dtos: EpersonDtoModel[]) => {
|
})).pipe(map((dtos: EpersonDtoModel[]) => {
|
||||||
return buildPaginatedList(epeople.pageInfo, dtos);
|
return buildPaginatedList(epeople.pageInfo, dtos);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
@@ -160,14 +153,14 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
const query: string = data.query;
|
const query: string = data.query;
|
||||||
const scope: string = data.scope;
|
const scope: string = data.scope;
|
||||||
if (query != null && this.currentSearchQuery !== query) {
|
if (query != null && this.currentSearchQuery !== query) {
|
||||||
this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
|
void this.router.navigate([getEPersonsRoute()], {
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge'
|
||||||
});
|
});
|
||||||
this.currentSearchQuery = query;
|
this.currentSearchQuery = query;
|
||||||
this.paginationService.resetPage(this.config.id);
|
this.paginationService.resetPage(this.config.id);
|
||||||
}
|
}
|
||||||
if (scope != null && this.currentSearchScope !== scope) {
|
if (scope != null && this.currentSearchScope !== scope) {
|
||||||
this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
|
void this.router.navigate([getEPersonsRoute()], {
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge'
|
||||||
});
|
});
|
||||||
this.currentSearchScope = scope;
|
this.currentSearchScope = scope;
|
||||||
@@ -188,40 +181,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given EPerson is active (being edited)
|
|
||||||
* @param eperson
|
|
||||||
*/
|
|
||||||
isActive(eperson: EPerson): Observable<boolean> {
|
|
||||||
return this.getActiveEPerson().pipe(
|
|
||||||
map((activeEPerson) => eperson === activeEPerson)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the active eperson (being edited)
|
|
||||||
*/
|
|
||||||
getActiveEPerson(): Observable<EPerson> {
|
|
||||||
return this.epersonService.getActiveEPerson();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start editing the selected EPerson
|
|
||||||
* @param ePerson
|
|
||||||
*/
|
|
||||||
toggleEditEPerson(ePerson: EPerson) {
|
|
||||||
this.getActiveEPerson().pipe(take(1)).subscribe((activeEPerson: EPerson) => {
|
|
||||||
if (ePerson === activeEPerson) {
|
|
||||||
this.epersonService.cancelEditEPerson();
|
|
||||||
this.isEPersonFormShown = false;
|
|
||||||
} else {
|
|
||||||
this.epersonService.editEPerson(ePerson);
|
|
||||||
this.isEPersonFormShown = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.scrollToTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes EPerson, show notification on success/failure & updates EPeople list
|
* Deletes EPerson, show notification on success/failure & updates EPeople list
|
||||||
*/
|
*/
|
||||||
@@ -242,7 +201,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
if (restResponse.hasSucceeded) {
|
if (restResponse.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: this.dsoNameService.getName(ePerson)}));
|
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', {name: this.dsoNameService.getName(ePerson)}));
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + ePerson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
|
this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { id: ePerson.id, statusCode: restResponse.statusCode, errorMessage: restResponse.errorMessage }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -264,16 +223,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
|
||||||
(function smoothscroll() {
|
|
||||||
const currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
|
|
||||||
if (currentScroll > 0) {
|
|
||||||
window.requestAnimationFrame(smoothscroll);
|
|
||||||
window.scrollTo(0, currentScroll - (currentScroll / 8));
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset all input-fields to be empty and search all search
|
* Reset all input-fields to be empty and search all search
|
||||||
*/
|
*/
|
||||||
@@ -284,20 +233,7 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
this.search({query: ''});
|
this.search({query: ''});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
getEditEPeoplePage(id: string): string {
|
||||||
* This method will set everything to stale, which will cause the lists on this page to update.
|
return getEPersonEditRoute(id);
|
||||||
*/
|
|
||||||
reset(): void {
|
|
||||||
this.epersonService.getBrowseEndpoint().pipe(
|
|
||||||
take(1),
|
|
||||||
switchMap((href: string) => {
|
|
||||||
return this.requestService.setStaleByHrefSubstring(href).pipe(
|
|
||||||
take(1),
|
|
||||||
);
|
|
||||||
})
|
|
||||||
).subscribe(()=>{
|
|
||||||
this.epersonService.cancelEditEPerson();
|
|
||||||
this.isEPersonFormShown = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,89 +1,98 @@
|
|||||||
<div *ngIf="epersonService.getActiveEPerson() | async; then editheader; else createHeader"></div>
|
<div class="container">
|
||||||
|
<div class="group-form row">
|
||||||
|
<div class="col-12">
|
||||||
|
|
||||||
<ng-template #createHeader>
|
<div *ngIf="activeEPerson$ | async; then editHeader; else createHeader"></div>
|
||||||
<h4>{{messagePrefix + '.create' | translate}}</h4>
|
|
||||||
</ng-template>
|
|
||||||
|
|
||||||
<ng-template #editheader>
|
<ng-template #createHeader>
|
||||||
<h4>{{messagePrefix + '.edit' | translate}}</h4>
|
<h1 class="border-bottom pb-2">{{messagePrefix + '.create' | translate}}</h1>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ds-form [formId]="formId"
|
<ng-template #editHeader>
|
||||||
[formModel]="formModel"
|
<h1 class="border-bottom pb-2">{{messagePrefix + '.edit' | translate}}</h1>
|
||||||
[formGroup]="formGroup"
|
</ng-template>
|
||||||
[formLayout]="formLayout"
|
|
||||||
[displayCancel]="false"
|
|
||||||
[submitLabel]="submitLabel"
|
|
||||||
(submitForm)="onSubmit()">
|
|
||||||
<div before class="btn-group">
|
|
||||||
<button (click)="onCancel()"
|
|
||||||
class="btn btn-outline-secondary"><i class="fas fa-arrow-left"></i> {{messagePrefix + '.return' | translate}}</button>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="displayResetPassword" between class="btn-group">
|
|
||||||
<button class="btn btn-primary" [disabled]="!(canReset$ | async)" (click)="resetPassword()">
|
|
||||||
<i class="fa fa-key"></i> {{'admin.access-control.epeople.actions.reset' | translate}}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div between class="btn-group ml-1">
|
|
||||||
<button *ngIf="!isImpersonated" class="btn btn-primary" [ngClass]="{'d-none' : !(canImpersonate$ | async)}" (click)="impersonate()">
|
|
||||||
<i class="fa fa-user-secret"></i> {{'admin.access-control.epeople.actions.impersonate' | translate}}
|
|
||||||
</button>
|
|
||||||
<button *ngIf="isImpersonated" class="btn btn-primary" (click)="stopImpersonating()">
|
|
||||||
<i class="fa fa-user-secret"></i> {{'admin.access-control.epeople.actions.stop-impersonating' | translate}}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<button after class="btn btn-danger delete-button" [disabled]="!(canDelete$ | async)" (click)="delete()">
|
|
||||||
<i class="fas fa-trash"></i> {{'admin.access-control.epeople.actions.delete' | translate}}
|
|
||||||
</button>
|
|
||||||
</ds-form>
|
|
||||||
|
|
||||||
<ds-themed-loading [showMessage]="false" *ngIf="!formGroup"></ds-themed-loading>
|
<ds-form [formId]="formId"
|
||||||
|
[formModel]="formModel"
|
||||||
|
[formGroup]="formGroup"
|
||||||
|
[formLayout]="formLayout"
|
||||||
|
[displayCancel]="false"
|
||||||
|
[submitLabel]="submitLabel"
|
||||||
|
(submitForm)="onSubmit()">
|
||||||
|
<div before class="btn-group">
|
||||||
|
<button (click)="onCancel()" type="button" class="btn btn-outline-secondary">
|
||||||
|
<i class="fas fa-arrow-left"></i> {{messagePrefix + '.return' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="displayResetPassword" between class="btn-group">
|
||||||
|
<button class="btn btn-primary" [dsBtnDisabled]="!(canReset$ | async)" type="button" (click)="resetPassword()">
|
||||||
|
<i class="fa fa-key"></i> {{'admin.access-control.epeople.actions.reset' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="canImpersonate$ | async" between class="btn-group">
|
||||||
|
<button *ngIf="!isImpersonated" class="btn btn-primary" type="button" (click)="impersonate()">
|
||||||
|
<i class="fa fa-user-secret"></i> {{'admin.access-control.epeople.actions.impersonate' | translate}}
|
||||||
|
</button>
|
||||||
|
<button *ngIf="isImpersonated" class="btn btn-primary" type="button" (click)="stopImpersonating()">
|
||||||
|
<i class="fa fa-user-secret"></i> {{'admin.access-control.epeople.actions.stop-impersonating' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button *ngIf="canDelete$ | async" after class="btn btn-danger delete-button" type="button" (click)="delete()">
|
||||||
|
<i class="fas fa-trash"></i> {{'admin.access-control.epeople.actions.delete' | translate}}
|
||||||
|
</button>
|
||||||
|
</ds-form>
|
||||||
|
|
||||||
<div *ngIf="epersonService.getActiveEPerson() | async">
|
<ds-themed-loading [showMessage]="false" *ngIf="!formGroup"></ds-themed-loading>
|
||||||
<h5>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h5>
|
|
||||||
|
|
||||||
<ds-themed-loading [showMessage]="false" *ngIf="!(groups | async)"></ds-themed-loading>
|
<div *ngIf="activeEPerson$ | async">
|
||||||
|
<h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
|
||||||
|
|
||||||
<ds-pagination
|
<ds-themed-loading [showMessage]="false" *ngIf="!(groups | async)"></ds-themed-loading>
|
||||||
*ngIf="(groups | async)?.payload?.totalElements > 0"
|
|
||||||
[paginationOptions]="config"
|
|
||||||
[pageInfoState]="(groups | async)?.payload"
|
|
||||||
[collectionSize]="(groups | async)?.payload?.totalElements"
|
|
||||||
[hideGear]="true"
|
|
||||||
[hidePagerWhenSinglePage]="true"
|
|
||||||
(pageChange)="onPageChange($event)">
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<ds-pagination
|
||||||
<table id="groups" class="table table-striped table-hover table-bordered">
|
*ngIf="(groups | async)?.payload?.totalElements > 0"
|
||||||
<thead>
|
[paginationOptions]="config"
|
||||||
<tr>
|
[collectionSize]="(groups | async)?.payload?.totalElements"
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
[hideGear]="true"
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
[hidePagerWhenSinglePage]="true"
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.collectionOrCommunity' | translate}}</th>
|
(pageChange)="onPageChange($event)">
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let group of (groups | async)?.payload?.page">
|
|
||||||
<td class="align-middle">{{group.id}}</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
<a (click)="groupsDataService.startEditingNewGroup(group)"
|
|
||||||
[routerLink]="[groupsDataService.getGroupEditPageRouterLink(group)]">
|
|
||||||
{{ dsoNameService.getName(group) }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="align-middle">{{ dsoNameService.getName(undefined) }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</ds-pagination>
|
<div class="table-responsive">
|
||||||
|
<table id="groups" class="table table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.collectionOrCommunity' | translate}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let group of (groups | async)?.payload?.page">
|
||||||
|
<td class="align-middle">{{group.id}}</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<a (click)="groupsDataService.startEditingNewGroup(group)"
|
||||||
|
[routerLink]="[groupsDataService.getGroupEditPageRouterLink(group)]">
|
||||||
|
{{ dsoNameService.getName(group) }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
{{ dsoNameService.getName((group.object | async)?.payload) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div *ngIf="(groups | async)?.payload?.totalElements == 0" class="alert alert-info w-100 mb-2" role="alert">
|
</ds-pagination>
|
||||||
<div>{{messagePrefix + '.memberOfNoGroups' | translate}}</div>
|
|
||||||
<div>
|
<div *ngIf="(groups | async)?.payload?.totalElements == 0" class="alert alert-info w-100 mb-2" role="alert">
|
||||||
<button [routerLink]="[groupsDataService.getGroupRegistryRouterLink()]"
|
<div>{{messagePrefix + '.memberOfNoGroups' | translate}}</div>
|
||||||
class="btn btn-primary">{{messagePrefix + '.goToGroups' | translate}}</button>
|
<div>
|
||||||
|
<button [routerLink]="[groupsDataService.getGroupRegistryRouterLink()]"
|
||||||
|
class="btn btn-primary">{{messagePrefix + '.goToGroups' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { BrowserModule, By } from '@angular/platform-browser';
|
import { BrowserModule, By } from '@angular/platform-browser';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated-list.model';
|
import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
||||||
@@ -19,7 +19,6 @@ import { EPersonMock, EPersonMock2 } from '../../../shared/testing/eperson.mock'
|
|||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock';
|
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock';
|
||||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock';
|
|
||||||
import { AuthService } from '../../../core/auth/auth.service';
|
import { AuthService } from '../../../core/auth/auth.service';
|
||||||
import { AuthServiceStub } from '../../../shared/testing/auth-service.stub';
|
import { AuthServiceStub } from '../../../shared/testing/auth-service.stub';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
@@ -31,6 +30,12 @@ import { PaginationServiceStub } from '../../../shared/testing/pagination-servic
|
|||||||
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
import { FindListOptions } from '../../../core/data/find-list-options.model';
|
||||||
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
|
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
|
||||||
import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
|
import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
|
||||||
|
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { RouterStub } from '../../../shared/testing/router.stub';
|
||||||
|
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import {BtnDisabledDirective} from '../../../shared/btn-disabled.directive';
|
||||||
|
|
||||||
describe('EPersonFormComponent', () => {
|
describe('EPersonFormComponent', () => {
|
||||||
let component: EPersonFormComponent;
|
let component: EPersonFormComponent;
|
||||||
@@ -43,6 +48,8 @@ describe('EPersonFormComponent', () => {
|
|||||||
let authorizationService: AuthorizationDataService;
|
let authorizationService: AuthorizationDataService;
|
||||||
let groupsDataService: GroupDataService;
|
let groupsDataService: GroupDataService;
|
||||||
let epersonRegistrationService: EpersonRegistrationService;
|
let epersonRegistrationService: EpersonRegistrationService;
|
||||||
|
let route: ActivatedRouteStub;
|
||||||
|
let router: RouterStub;
|
||||||
|
|
||||||
let paginationService;
|
let paginationService;
|
||||||
|
|
||||||
@@ -53,9 +60,6 @@ describe('EPersonFormComponent', () => {
|
|||||||
ePersonDataServiceStub = {
|
ePersonDataServiceStub = {
|
||||||
activeEPerson: null,
|
activeEPerson: null,
|
||||||
allEpeople: mockEPeople,
|
allEpeople: mockEPeople,
|
||||||
getEPeople(): Observable<RemoteData<PaginatedList<EPerson>>> {
|
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList(null, this.allEpeople));
|
|
||||||
},
|
|
||||||
getActiveEPerson(): Observable<EPerson> {
|
getActiveEPerson(): Observable<EPerson> {
|
||||||
return observableOf(this.activeEPerson);
|
return observableOf(this.activeEPerson);
|
||||||
},
|
},
|
||||||
@@ -106,6 +110,9 @@ describe('EPersonFormComponent', () => {
|
|||||||
},
|
},
|
||||||
getEPersonByEmail(email): Observable<RemoteData<EPerson>> {
|
getEPersonByEmail(email): Observable<RemoteData<EPerson>> {
|
||||||
return createSuccessfulRemoteDataObject$(null);
|
return createSuccessfulRemoteDataObject$(null);
|
||||||
|
},
|
||||||
|
findById(_id: string, _useCachedVersionIfAvailable = true, _reRequestOnStale = true, ..._linksToFollow: FollowLinkConfig<EPerson>[]): Observable<RemoteData<EPerson>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
builderService = Object.assign(getMockFormBuilderService(),{
|
builderService = Object.assign(getMockFormBuilderService(),{
|
||||||
@@ -182,16 +189,14 @@ describe('EPersonFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
paginationService = new PaginationServiceStub();
|
paginationService = new PaginationServiceStub();
|
||||||
|
route = new ActivatedRouteStub();
|
||||||
|
router = new RouterStub();
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||||
TranslateModule.forRoot({
|
RouterTestingModule,
|
||||||
loader: {
|
TranslateModule.forRoot(),
|
||||||
provide: TranslateLoader,
|
|
||||||
useClass: TranslateLoaderMock
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
declarations: [EPersonFormComponent],
|
declarations: [EPersonFormComponent, BtnDisabledDirective],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
|
||||||
{ provide: GroupDataService, useValue: groupsDataService },
|
{ provide: GroupDataService, useValue: groupsDataService },
|
||||||
@@ -202,9 +207,11 @@ describe('EPersonFormComponent', () => {
|
|||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring'])},
|
{ provide: RequestService, useValue: jasmine.createSpyObj('requestService', ['removeByHrefSubstring'])},
|
||||||
{ provide: EpersonRegistrationService, useValue: epersonRegistrationService },
|
{ provide: EpersonRegistrationService, useValue: epersonRegistrationService },
|
||||||
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
|
{ provide: Router, useValue: router },
|
||||||
EPeopleRegistryComponent
|
EPeopleRegistryComponent
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -223,37 +230,13 @@ describe('EPersonFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('check form validation', () => {
|
describe('check form validation', () => {
|
||||||
let firstName;
|
let canLogIn: boolean;
|
||||||
let lastName;
|
let requireCertificate: boolean;
|
||||||
let email;
|
|
||||||
let canLogIn;
|
|
||||||
let requireCertificate;
|
|
||||||
|
|
||||||
let expected;
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
firstName = 'testName';
|
|
||||||
lastName = 'testLastName';
|
|
||||||
email = 'testEmail@test.com';
|
|
||||||
canLogIn = false;
|
canLogIn = false;
|
||||||
requireCertificate = false;
|
requireCertificate = false;
|
||||||
|
|
||||||
expected = Object.assign(new EPerson(), {
|
|
||||||
metadata: {
|
|
||||||
'eperson.firstname': [
|
|
||||||
{
|
|
||||||
value: firstName
|
|
||||||
}
|
|
||||||
],
|
|
||||||
'eperson.lastname': [
|
|
||||||
{
|
|
||||||
value: lastName
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
email: email,
|
|
||||||
canLogIn: canLogIn,
|
|
||||||
requireCertificate: requireCertificate,
|
|
||||||
});
|
|
||||||
spyOn(component.submitForm, 'emit');
|
spyOn(component.submitForm, 'emit');
|
||||||
component.canLogIn.value = canLogIn;
|
component.canLogIn.value = canLogIn;
|
||||||
component.requireCertificate.value = requireCertificate;
|
component.requireCertificate.value = requireCertificate;
|
||||||
@@ -263,24 +246,18 @@ describe('EPersonFormComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
describe('firstName, lastName and email should be required', () => {
|
describe('firstName, lastName and email should be required', () => {
|
||||||
it('form should be invalid because the firstName is required', waitForAsync(() => {
|
it('form should be invalid because the firstName is required', () => {
|
||||||
fixture.whenStable().then(() => {
|
expect(component.formGroup.controls.firstName.valid).toBeFalse();
|
||||||
expect(component.formGroup.controls.firstName.valid).toBeFalse();
|
expect(component.formGroup.controls.firstName.errors.required).toBeTrue();
|
||||||
expect(component.formGroup.controls.firstName.errors.required).toBeTrue();
|
});
|
||||||
});
|
it('form should be invalid because the lastName is required', () => {
|
||||||
}));
|
expect(component.formGroup.controls.lastName.valid).toBeFalse();
|
||||||
it('form should be invalid because the lastName is required', waitForAsync(() => {
|
expect(component.formGroup.controls.lastName.errors.required).toBeTrue();
|
||||||
fixture.whenStable().then(() => {
|
});
|
||||||
expect(component.formGroup.controls.lastName.valid).toBeFalse();
|
it('form should be invalid because the email is required', () => {
|
||||||
expect(component.formGroup.controls.lastName.errors.required).toBeTrue();
|
expect(component.formGroup.controls.email.valid).toBeFalse();
|
||||||
});
|
expect(component.formGroup.controls.email.errors.required).toBeTrue();
|
||||||
}));
|
});
|
||||||
it('form should be invalid because the email is required', waitForAsync(() => {
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.email.valid).toBeFalse();
|
|
||||||
expect(component.formGroup.controls.email.errors.required).toBeTrue();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('after inserting information firstName,lastName and email not required', () => {
|
describe('after inserting information firstName,lastName and email not required', () => {
|
||||||
@@ -290,24 +267,18 @@ describe('EPersonFormComponent', () => {
|
|||||||
component.formGroup.controls.email.setValue('test@test.com');
|
component.formGroup.controls.email.setValue('test@test.com');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
it('firstName should be valid because the firstName is set', waitForAsync(() => {
|
it('firstName should be valid because the firstName is set', () => {
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.firstName.valid).toBeTrue();
|
expect(component.formGroup.controls.firstName.valid).toBeTrue();
|
||||||
expect(component.formGroup.controls.firstName.errors).toBeNull();
|
expect(component.formGroup.controls.firstName.errors).toBeNull();
|
||||||
});
|
});
|
||||||
}));
|
it('lastName should be valid because the lastName is set', () => {
|
||||||
it('lastName should be valid because the lastName is set', waitForAsync(() => {
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.lastName.valid).toBeTrue();
|
expect(component.formGroup.controls.lastName.valid).toBeTrue();
|
||||||
expect(component.formGroup.controls.lastName.errors).toBeNull();
|
expect(component.formGroup.controls.lastName.errors).toBeNull();
|
||||||
});
|
});
|
||||||
}));
|
it('email should be valid because the email is set', () => {
|
||||||
it('email should be valid because the email is set', waitForAsync(() => {
|
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.email.valid).toBeTrue();
|
expect(component.formGroup.controls.email.valid).toBeTrue();
|
||||||
expect(component.formGroup.controls.email.errors).toBeNull();
|
expect(component.formGroup.controls.email.errors).toBeNull();
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -316,12 +287,10 @@ describe('EPersonFormComponent', () => {
|
|||||||
component.formGroup.controls.email.setValue('test@test');
|
component.formGroup.controls.email.setValue('test@test');
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
it('email should not be valid because the email pattern', waitForAsync(() => {
|
it('email should not be valid because the email pattern', () => {
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.email.valid).toBeFalse();
|
expect(component.formGroup.controls.email.valid).toBeFalse();
|
||||||
expect(component.formGroup.controls.email.errors.pattern).toBeTruthy();
|
expect(component.formGroup.controls.email.errors.pattern).toBeTruthy();
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('after already utilized email', () => {
|
describe('after already utilized email', () => {
|
||||||
@@ -336,22 +305,18 @@ describe('EPersonFormComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('email should not be valid because email is already taken', waitForAsync(() => {
|
it('email should not be valid because email is already taken', () => {
|
||||||
fixture.whenStable().then(() => {
|
|
||||||
expect(component.formGroup.controls.email.valid).toBeFalse();
|
expect(component.formGroup.controls.email.valid).toBeFalse();
|
||||||
expect(component.formGroup.controls.email.errors.emailTaken).toBeTruthy();
|
expect(component.formGroup.controls.email.errors.emailTaken).toBeTruthy();
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when submitting the form', () => {
|
describe('when submitting the form', () => {
|
||||||
let firstName;
|
let firstName;
|
||||||
let lastName;
|
let lastName;
|
||||||
let email;
|
let email;
|
||||||
let canLogIn;
|
let canLogIn: boolean;
|
||||||
let requireCertificate;
|
let requireCertificate;
|
||||||
|
|
||||||
let expected;
|
let expected;
|
||||||
@@ -380,6 +345,7 @@ describe('EPersonFormComponent', () => {
|
|||||||
requireCertificate: requireCertificate,
|
requireCertificate: requireCertificate,
|
||||||
});
|
});
|
||||||
spyOn(component.submitForm, 'emit');
|
spyOn(component.submitForm, 'emit');
|
||||||
|
component.ngOnInit();
|
||||||
component.firstName.value = firstName;
|
component.firstName.value = firstName;
|
||||||
component.lastName.value = lastName;
|
component.lastName.value = lastName;
|
||||||
component.email.value = email;
|
component.email.value = email;
|
||||||
@@ -393,11 +359,9 @@ describe('EPersonFormComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit a new eperson using the correct values', waitForAsync(() => {
|
it('should emit a new eperson using the correct values', () => {
|
||||||
fixture.whenStable().then(() => {
|
expect(component.submitForm.emit).toHaveBeenCalledWith(expected);
|
||||||
expect(component.submitForm.emit).toHaveBeenCalledWith(expected);
|
});
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with an active eperson', () => {
|
describe('with an active eperson', () => {
|
||||||
@@ -421,18 +385,24 @@ describe('EPersonFormComponent', () => {
|
|||||||
email: email,
|
email: email,
|
||||||
canLogIn: canLogIn,
|
canLogIn: canLogIn,
|
||||||
requireCertificate: requireCertificate,
|
requireCertificate: requireCertificate,
|
||||||
_links: undefined
|
_links: {
|
||||||
|
groups: {
|
||||||
|
href: '',
|
||||||
|
},
|
||||||
|
self: {
|
||||||
|
href: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
spyOn(ePersonDataServiceStub, 'getActiveEPerson').and.returnValue(observableOf(expectedWithId));
|
spyOn(ePersonDataServiceStub, 'getActiveEPerson').and.returnValue(observableOf(expectedWithId));
|
||||||
|
component.ngOnInit();
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit the existing eperson using the correct values', waitForAsync(() => {
|
it('should emit the existing eperson using the correct values', () => {
|
||||||
fixture.whenStable().then(() => {
|
expect(component.submitForm.emit).toHaveBeenCalledWith(expectedWithId);
|
||||||
expect(component.submitForm.emit).toHaveBeenCalledWith(expectedWithId);
|
});
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -473,34 +443,31 @@ describe('EPersonFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('delete', () => {
|
describe('delete', () => {
|
||||||
|
|
||||||
let ePersonId;
|
|
||||||
let eperson: EPerson;
|
let eperson: EPerson;
|
||||||
let modalService;
|
let modalService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(authService, 'impersonate').and.callThrough();
|
spyOn(authService, 'impersonate').and.callThrough();
|
||||||
ePersonId = 'testEPersonId';
|
|
||||||
eperson = EPersonMock;
|
eperson = EPersonMock;
|
||||||
component.epersonInitial = eperson;
|
component.epersonInitial = eperson;
|
||||||
component.canDelete$ = observableOf(true);
|
component.canDelete$ = observableOf(true);
|
||||||
spyOn(component.epersonService, 'getActiveEPerson').and.returnValue(observableOf(eperson));
|
spyOn(component.epersonService, 'getActiveEPerson').and.returnValue(observableOf(eperson));
|
||||||
modalService = (component as any).modalService;
|
modalService = (component as any).modalService;
|
||||||
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) }));
|
spyOn(modalService, 'open').and.returnValue(Object.assign({ componentInstance: Object.assign({ response: observableOf(true) }) }));
|
||||||
|
component.ngOnInit();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('the delete button should be active if the eperson can be deleted', () => {
|
it('the delete button should be visible if the ePerson can be deleted', () => {
|
||||||
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
||||||
expect(deleteButton.nativeElement.disabled).toBe(false);
|
expect(deleteButton).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('the delete button should be disabled if the eperson cannot be deleted', () => {
|
it('the delete button should be hidden if the ePerson cannot be deleted', () => {
|
||||||
component.canDelete$ = observableOf(false);
|
component.canDelete$ = observableOf(false);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
||||||
expect(deleteButton.nativeElement.disabled).toBe(true);
|
expect(deleteButton).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the epersonFormComponent delete when clicked on the button', () => {
|
it('should call the epersonFormComponent delete when clicked on the button', () => {
|
||||||
@@ -515,7 +482,8 @@ describe('EPersonFormComponent', () => {
|
|||||||
// ePersonDataServiceStub.activeEPerson = eperson;
|
// ePersonDataServiceStub.activeEPerson = eperson;
|
||||||
spyOn(component.epersonService, 'deleteEPerson').and.returnValue(createSuccessfulRemoteDataObject$('No Content', 204));
|
spyOn(component.epersonService, 'deleteEPerson').and.returnValue(createSuccessfulRemoteDataObject$('No Content', 204));
|
||||||
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
|
||||||
expect(deleteButton.nativeElement.disabled).toBe(false);
|
expect(deleteButton.nativeElement.getAttribute('aria-disabled')).toBeNull();
|
||||||
|
expect(deleteButton.nativeElement.classList.contains('disabled')).toBeFalse();
|
||||||
deleteButton.triggerEventHandler('click', null);
|
deleteButton.triggerEventHandler('click', null);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.epersonService.deleteEPerson).toHaveBeenCalledWith(eperson);
|
expect(component.epersonService.deleteEPerson).toHaveBeenCalledWith(eperson);
|
||||||
|
@@ -38,6 +38,8 @@ import { Registration } from '../../../core/shared/registration.model';
|
|||||||
import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
|
import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
|
||||||
import { TYPE_REQUEST_FORGOT } from '../../../register-email-form/register-email-form.component';
|
import { TYPE_REQUEST_FORGOT } from '../../../register-email-form/register-email-form.component';
|
||||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
|
import { getEPersonsRoute } from '../../access-control-routing-paths';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-eperson-form',
|
selector: 'ds-eperson-form',
|
||||||
@@ -137,6 +139,11 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
canImpersonate$: Observable<boolean>;
|
canImpersonate$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current {@link EPerson}
|
||||||
|
*/
|
||||||
|
activeEPerson$: Observable<EPerson>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of subscriptions
|
* List of subscriptions
|
||||||
*/
|
*/
|
||||||
@@ -194,8 +201,14 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
public requestService: RequestService,
|
public requestService: RequestService,
|
||||||
private epersonRegistrationService: EpersonRegistrationService,
|
private epersonRegistrationService: EpersonRegistrationService,
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
|
protected route: ActivatedRoute,
|
||||||
|
protected router: Router,
|
||||||
) {
|
) {
|
||||||
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.activeEPerson$ = this.epersonService.getActiveEPerson();
|
||||||
|
this.subs.push(this.activeEPerson$.subscribe((eperson: EPerson) => {
|
||||||
this.epersonInitial = eperson;
|
this.epersonInitial = eperson;
|
||||||
if (hasValue(eperson)) {
|
if (hasValue(eperson)) {
|
||||||
this.isImpersonated = this.authService.isImpersonatingUser(eperson.id);
|
this.isImpersonated = this.authService.isImpersonatingUser(eperson.id);
|
||||||
@@ -203,9 +216,6 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
this.submitLabel = 'form.submit';
|
this.submitLabel = 'form.submit';
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.initialisePage();
|
this.initialisePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,124 +223,117 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
* This method will initialise the page
|
* This method will initialise the page
|
||||||
*/
|
*/
|
||||||
initialisePage() {
|
initialisePage() {
|
||||||
|
if (this.route.snapshot.params.id) {
|
||||||
observableCombineLatest([
|
this.subs.push(this.epersonService.findById(this.route.snapshot.params.id).subscribe((ePersonRD: RemoteData<EPerson>) => {
|
||||||
this.translateService.get(`${this.messagePrefix}.firstName`),
|
this.epersonService.editEPerson(ePersonRD.payload);
|
||||||
this.translateService.get(`${this.messagePrefix}.lastName`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.email`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.canLogIn`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.requireCertificate`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.emailHint`),
|
|
||||||
]).subscribe(([firstName, lastName, email, canLogIn, requireCertificate, emailHint]) => {
|
|
||||||
this.firstName = new DynamicInputModel({
|
|
||||||
id: 'firstName',
|
|
||||||
label: firstName,
|
|
||||||
name: 'firstName',
|
|
||||||
validators: {
|
|
||||||
required: null,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
this.lastName = new DynamicInputModel({
|
|
||||||
id: 'lastName',
|
|
||||||
label: lastName,
|
|
||||||
name: 'lastName',
|
|
||||||
validators: {
|
|
||||||
required: null,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
this.email = new DynamicInputModel({
|
|
||||||
id: 'email',
|
|
||||||
label: email,
|
|
||||||
name: 'email',
|
|
||||||
validators: {
|
|
||||||
required: null,
|
|
||||||
pattern: '^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$',
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
errorMessages: {
|
|
||||||
emailTaken: 'error.validation.emailTaken',
|
|
||||||
pattern: 'error.validation.NotValidEmail'
|
|
||||||
},
|
|
||||||
hint: emailHint
|
|
||||||
});
|
|
||||||
this.canLogIn = new DynamicCheckboxModel(
|
|
||||||
{
|
|
||||||
id: 'canLogIn',
|
|
||||||
label: canLogIn,
|
|
||||||
name: 'canLogIn',
|
|
||||||
value: (this.epersonInitial != null ? this.epersonInitial.canLogIn : true)
|
|
||||||
});
|
|
||||||
this.requireCertificate = new DynamicCheckboxModel(
|
|
||||||
{
|
|
||||||
id: 'requireCertificate',
|
|
||||||
label: requireCertificate,
|
|
||||||
name: 'requireCertificate',
|
|
||||||
value: (this.epersonInitial != null ? this.epersonInitial.requireCertificate : false)
|
|
||||||
});
|
|
||||||
this.formModel = [
|
|
||||||
this.firstName,
|
|
||||||
this.lastName,
|
|
||||||
this.email,
|
|
||||||
this.canLogIn,
|
|
||||||
this.requireCertificate,
|
|
||||||
];
|
|
||||||
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
|
||||||
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
|
|
||||||
if (eperson != null) {
|
|
||||||
this.groups = this.groupsDataService.findListByHref(eperson._links.groups.href, {
|
|
||||||
currentPage: 1,
|
|
||||||
elementsPerPage: this.config.pageSize
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.formGroup.patchValue({
|
|
||||||
firstName: eperson != null ? eperson.firstMetadataValue('eperson.firstname') : '',
|
|
||||||
lastName: eperson != null ? eperson.firstMetadataValue('eperson.lastname') : '',
|
|
||||||
email: eperson != null ? eperson.email : '',
|
|
||||||
canLogIn: eperson != null ? eperson.canLogIn : true,
|
|
||||||
requireCertificate: eperson != null ? eperson.requireCertificate : false
|
|
||||||
});
|
|
||||||
|
|
||||||
if (eperson === null && !!this.formGroup.controls.email) {
|
|
||||||
this.formGroup.controls.email.setAsyncValidators(ValidateEmailNotTaken.createValidator(this.epersonService));
|
|
||||||
this.emailValueChangeSubscribe = this.email.valueChanges.pipe(debounceTime(300)).subscribe(() => {
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
const activeEPerson$ = this.epersonService.getActiveEPerson();
|
this.firstName = new DynamicInputModel({
|
||||||
|
id: 'firstName',
|
||||||
this.groups = activeEPerson$.pipe(
|
label: this.translateService.instant(`${this.messagePrefix}.firstName`),
|
||||||
switchMap((eperson) => {
|
name: 'firstName',
|
||||||
return observableCombineLatest([observableOf(eperson), this.paginationService.getFindListOptions(this.config.id, {
|
validators: {
|
||||||
currentPage: 1,
|
required: null,
|
||||||
elementsPerPage: this.config.pageSize
|
},
|
||||||
})]);
|
required: true,
|
||||||
}),
|
|
||||||
switchMap(([eperson, findListOptions]) => {
|
|
||||||
if (eperson != null) {
|
|
||||||
return this.groupsDataService.findListByHref(eperson._links.groups.href, findListOptions, true, true, followLink('object'));
|
|
||||||
}
|
|
||||||
return observableOf(undefined);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
this.canImpersonate$ = activeEPerson$.pipe(
|
|
||||||
switchMap((eperson) => {
|
|
||||||
if (hasValue(eperson)) {
|
|
||||||
return this.authorizationService.isAuthorized(FeatureID.LoginOnBehalfOf, eperson.self);
|
|
||||||
} else {
|
|
||||||
return observableOf(false);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.canDelete$ = activeEPerson$.pipe(
|
|
||||||
switchMap((eperson) => this.authorizationService.isAuthorized(FeatureID.CanDelete, hasValue(eperson) ? eperson.self : undefined))
|
|
||||||
);
|
|
||||||
this.canReset$ = observableOf(true);
|
|
||||||
});
|
});
|
||||||
|
this.lastName = new DynamicInputModel({
|
||||||
|
id: 'lastName',
|
||||||
|
label: this.translateService.instant(`${this.messagePrefix}.lastName`),
|
||||||
|
name: 'lastName',
|
||||||
|
validators: {
|
||||||
|
required: null,
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
this.email = new DynamicInputModel({
|
||||||
|
id: 'email',
|
||||||
|
label: this.translateService.instant(`${this.messagePrefix}.email`),
|
||||||
|
name: 'email',
|
||||||
|
validators: {
|
||||||
|
required: null,
|
||||||
|
pattern: '^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$',
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
errorMessages: {
|
||||||
|
emailTaken: 'error.validation.emailTaken',
|
||||||
|
pattern: 'error.validation.NotValidEmail'
|
||||||
|
},
|
||||||
|
hint: this.translateService.instant(`${this.messagePrefix}.emailHint`),
|
||||||
|
});
|
||||||
|
this.canLogIn = new DynamicCheckboxModel(
|
||||||
|
{
|
||||||
|
id: 'canLogIn',
|
||||||
|
label: this.translateService.instant(`${this.messagePrefix}.canLogIn`),
|
||||||
|
name: 'canLogIn',
|
||||||
|
value: (this.epersonInitial != null ? this.epersonInitial.canLogIn : true)
|
||||||
|
});
|
||||||
|
this.requireCertificate = new DynamicCheckboxModel(
|
||||||
|
{
|
||||||
|
id: 'requireCertificate',
|
||||||
|
label: this.translateService.instant(`${this.messagePrefix}.requireCertificate`),
|
||||||
|
name: 'requireCertificate',
|
||||||
|
value: (this.epersonInitial != null ? this.epersonInitial.requireCertificate : false)
|
||||||
|
});
|
||||||
|
this.formModel = [
|
||||||
|
this.firstName,
|
||||||
|
this.lastName,
|
||||||
|
this.email,
|
||||||
|
this.canLogIn,
|
||||||
|
this.requireCertificate,
|
||||||
|
];
|
||||||
|
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
||||||
|
this.subs.push(this.activeEPerson$.subscribe((eperson: EPerson) => {
|
||||||
|
if (eperson != null) {
|
||||||
|
this.groups = this.groupsDataService.findListByHref(eperson._links.groups.href, {
|
||||||
|
currentPage: 1,
|
||||||
|
elementsPerPage: this.config.pageSize
|
||||||
|
}, undefined, undefined, followLink('object'));
|
||||||
|
}
|
||||||
|
this.formGroup.patchValue({
|
||||||
|
firstName: eperson != null ? eperson.firstMetadataValue('eperson.firstname') : '',
|
||||||
|
lastName: eperson != null ? eperson.firstMetadataValue('eperson.lastname') : '',
|
||||||
|
email: eperson != null ? eperson.email : '',
|
||||||
|
canLogIn: eperson != null ? eperson.canLogIn : true,
|
||||||
|
requireCertificate: eperson != null ? eperson.requireCertificate : false
|
||||||
|
});
|
||||||
|
|
||||||
|
if (eperson === null && !!this.formGroup.controls.email) {
|
||||||
|
this.formGroup.controls.email.setAsyncValidators(ValidateEmailNotTaken.createValidator(this.epersonService));
|
||||||
|
this.emailValueChangeSubscribe = this.email.valueChanges.pipe(debounceTime(300)).subscribe(() => {
|
||||||
|
this.changeDetectorRef.detectChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.groups = this.activeEPerson$.pipe(
|
||||||
|
switchMap((eperson) => {
|
||||||
|
return observableCombineLatest([observableOf(eperson), this.paginationService.getFindListOptions(this.config.id, {
|
||||||
|
currentPage: 1,
|
||||||
|
elementsPerPage: this.config.pageSize
|
||||||
|
})]);
|
||||||
|
}),
|
||||||
|
switchMap(([eperson, findListOptions]) => {
|
||||||
|
if (eperson != null) {
|
||||||
|
return this.groupsDataService.findListByHref(eperson._links.groups.href, findListOptions, true, true, followLink('object'));
|
||||||
|
}
|
||||||
|
return observableOf(undefined);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.canImpersonate$ = this.activeEPerson$.pipe(
|
||||||
|
switchMap((eperson) => {
|
||||||
|
if (hasValue(eperson)) {
|
||||||
|
return this.authorizationService.isAuthorized(FeatureID.LoginOnBehalfOf, eperson.self);
|
||||||
|
} else {
|
||||||
|
return observableOf(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
this.canDelete$ = this.activeEPerson$.pipe(
|
||||||
|
switchMap((eperson) => this.authorizationService.isAuthorized(FeatureID.CanDelete, hasValue(eperson) ? eperson.self : undefined))
|
||||||
|
);
|
||||||
|
this.canReset$ = observableOf(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -339,6 +342,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
onCancel() {
|
onCancel() {
|
||||||
this.epersonService.cancelEditEPerson();
|
this.epersonService.cancelEditEPerson();
|
||||||
this.cancelForm.emit();
|
this.cancelForm.emit();
|
||||||
|
void this.router.navigate([getEPersonsRoute()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,7 +352,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
* Emit the updated/created eperson using the EventEmitter submitForm
|
* Emit the updated/created eperson using the EventEmitter submitForm
|
||||||
*/
|
*/
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.epersonService.getActiveEPerson().pipe(take(1)).subscribe(
|
this.activeEPerson$.pipe(take(1)).subscribe(
|
||||||
(ePerson: EPerson) => {
|
(ePerson: EPerson) => {
|
||||||
const values = {
|
const values = {
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -390,6 +394,8 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.created.success', { name: this.dsoNameService.getName(ePersonToCreate) }));
|
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.created.success', { name: this.dsoNameService.getName(ePersonToCreate) }));
|
||||||
this.submitForm.emit(ePersonToCreate);
|
this.submitForm.emit(ePersonToCreate);
|
||||||
|
this.epersonService.clearEPersonRequests();
|
||||||
|
void this.router.navigateByUrl(getEPersonsRoute());
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.created.failure', { name: this.dsoNameService.getName(ePersonToCreate) }));
|
this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.created.failure', { name: this.dsoNameService.getName(ePersonToCreate) }));
|
||||||
this.cancelForm.emit();
|
this.cancelForm.emit();
|
||||||
@@ -429,6 +435,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
if (rd.hasSucceeded) {
|
if (rd.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.edited.success', { name: this.dsoNameService.getName(editedEperson) }));
|
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.edited.success', { name: this.dsoNameService.getName(editedEperson) }));
|
||||||
this.submitForm.emit(editedEperson);
|
this.submitForm.emit(editedEperson);
|
||||||
|
void this.router.navigateByUrl(getEPersonsRoute());
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.edited.failure', { name: this.dsoNameService.getName(editedEperson) }));
|
this.notificationsService.error(this.translateService.get(this.labelPrefix + 'notification.edited.failure', { name: this.dsoNameService.getName(editedEperson) }));
|
||||||
this.cancelForm.emit();
|
this.cancelForm.emit();
|
||||||
@@ -464,7 +471,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
* It'll either show a success or error message depending on whether the delete was successful or not.
|
* It'll either show a success or error message depending on whether the delete was successful or not.
|
||||||
*/
|
*/
|
||||||
delete(): void {
|
delete(): void {
|
||||||
this.epersonService.getActiveEPerson().pipe(
|
this.activeEPerson$.pipe(
|
||||||
take(1),
|
take(1),
|
||||||
switchMap((eperson: EPerson) => {
|
switchMap((eperson: EPerson) => {
|
||||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||||
@@ -495,6 +502,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
).subscribe(({ restResponse, eperson }: { restResponse: RemoteData<NoContent> | null, eperson: EPerson }) => {
|
).subscribe(({ restResponse, eperson }: { restResponse: RemoteData<NoContent> | null, eperson: EPerson }) => {
|
||||||
if (restResponse?.hasSucceeded) {
|
if (restResponse?.hasSucceeded) {
|
||||||
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(eperson) }));
|
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: this.dsoNameService.getName(eperson) }));
|
||||||
|
void this.router.navigate([getEPersonsRoute()]);
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(`Error occurred when trying to delete EPerson with id: ${eperson?.id} with code: ${restResponse?.statusCode} and message: ${restResponse?.errorMessage}`);
|
this.notificationsService.error(`Error occurred when trying to delete EPerson with id: ${eperson?.id} with code: ${restResponse?.statusCode} and message: ${restResponse?.errorMessage}`);
|
||||||
}
|
}
|
||||||
@@ -541,16 +549,6 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will ensure that the page gets reset and that the cache is cleared
|
|
||||||
*/
|
|
||||||
reset() {
|
|
||||||
this.epersonService.getActiveEPerson().pipe(take(1)).subscribe((eperson: EPerson) => {
|
|
||||||
this.requestService.removeByHrefSubstring(eperson.self);
|
|
||||||
});
|
|
||||||
this.initialisePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for the given ePerson if there is already an ePerson in the system with that email
|
* Checks for the given ePerson if there is already an ePerson in the system with that email
|
||||||
* and shows notification if this is the case
|
* and shows notification if this is the case
|
||||||
@@ -577,7 +575,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
|
|||||||
* Update the list of groups by fetching it from the rest api or cache
|
* Update the list of groups by fetching it from the rest api or cache
|
||||||
*/
|
*/
|
||||||
private updateGroups(options) {
|
private updateGroups(options) {
|
||||||
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
|
this.subs.push(this.activeEPerson$.subscribe((eperson: EPerson) => {
|
||||||
this.groups = this.groupsDataService.findListByHref(eperson._links.groups.href, options);
|
this.groups = this.groupsDataService.findListByHref(eperson._links.groups.href, options);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,53 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||||
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
|
import { ResolvedAction } from '../../core/resolving/resolver.actions';
|
||||||
|
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
|
||||||
|
export const EPERSON_EDIT_FOLLOW_LINKS: FollowLinkConfig<EPerson>[] = [
|
||||||
|
followLink('groups'),
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a resolver that requests a specific {@link EPerson} before the route is activated
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root',
|
||||||
|
})
|
||||||
|
export class EPersonResolver implements Resolve<RemoteData<EPerson>> {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
protected ePersonService: EPersonDataService,
|
||||||
|
protected store: Store<any>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for resolving a {@link EPerson} based on the parameters in the current route
|
||||||
|
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
|
||||||
|
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
|
||||||
|
* @returns `Observable<<RemoteData<EPerson>>` Emits the found {@link EPerson} based on the parameters in the current
|
||||||
|
* route, or an error if something went wrong
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<EPerson>> {
|
||||||
|
const ePersonRD$: Observable<RemoteData<EPerson>> = this.ePersonService.findById(route.params.id,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
...EPERSON_EDIT_FOLLOW_LINKS,
|
||||||
|
).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
);
|
||||||
|
|
||||||
|
ePersonRD$.subscribe((ePersonRD: RemoteData<EPerson>) => {
|
||||||
|
this.store.dispatch(new ResolvedAction(state.url, ePersonRD.payload));
|
||||||
|
});
|
||||||
|
|
||||||
|
return ePersonRD$;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -2,14 +2,14 @@
|
|||||||
<div class="group-form row">
|
<div class="group-form row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
||||||
<div *ngIf="groupDataService.getActiveGroup() | async; then editheader; else createHeader"></div>
|
<div *ngIf="activeGroup$ | async; then editHeader; else createHeader"></div>
|
||||||
|
|
||||||
<ng-template #createHeader>
|
<ng-template #createHeader>
|
||||||
<h2 class="border-bottom pb-2">{{messagePrefix + '.head.create' | translate}}</h2>
|
<h1 class="border-bottom pb-2">{{messagePrefix + '.head.create' | translate}}</h1>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #editheader>
|
<ng-template #editHeader>
|
||||||
<h2 class="border-bottom pb-2">
|
<h1 class="border-bottom pb-2">
|
||||||
<span
|
<span
|
||||||
*dsContextHelp="{
|
*dsContextHelp="{
|
||||||
content: 'admin.access-control.groups.form.tooltip.editGroupPage',
|
content: 'admin.access-control.groups.form.tooltip.editGroupPage',
|
||||||
@@ -20,14 +20,18 @@
|
|||||||
>
|
>
|
||||||
{{messagePrefix + '.head.edit' | translate}}
|
{{messagePrefix + '.head.edit' | translate}}
|
||||||
</span>
|
</span>
|
||||||
</h2>
|
</h1>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ds-alert *ngIf="groupBeingEdited?.permanent" [type]="AlertTypeEnum.Warning"
|
<ng-container *ngIf="(activeGroup$ | async) as groupBeingEdited">
|
||||||
[content]="messagePrefix + '.alert.permanent'"></ds-alert>
|
<ds-alert *ngIf="groupBeingEdited?.permanent" [type]="AlertType.Warning"
|
||||||
<ds-alert *ngIf="!(canEdit$ | async) && (groupDataService.getActiveGroup() | async)" [type]="AlertTypeEnum.Warning"
|
[content]="messagePrefix + '.alert.permanent'"></ds-alert>
|
||||||
[content]="(messagePrefix + '.alert.workflowGroup' | translate:{ name: dsoNameService.getName((getLinkedDSO(groupBeingEdited) | async)?.payload), comcol: (getLinkedDSO(groupBeingEdited) | async)?.payload?.type, comcolEditRolesRoute: (getLinkedEditRolesRoute(groupBeingEdited) | async) })">
|
<ng-container *ngIf="(activeGroupLinkedDSO$ | async) as activeGroupLinkedDSO">
|
||||||
</ds-alert>
|
<ds-alert *ngIf="!(canEdit$ | async)" [type]="AlertType.Warning"
|
||||||
|
[content]="(messagePrefix + '.alert.workflowGroup' | translate:{ name: dsoNameService.getName(activeGroupLinkedDSO), comcol: activeGroupLinkedDSO.type, comcolEditRolesRoute: (linkedEditRolesRoute$ | async) })">
|
||||||
|
</ds-alert>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ds-form [formId]="formId"
|
<ds-form [formId]="formId"
|
||||||
[formModel]="formModel"
|
[formModel]="formModel"
|
||||||
@@ -36,26 +40,24 @@
|
|||||||
[displayCancel]="false"
|
[displayCancel]="false"
|
||||||
(submitForm)="onSubmit()">
|
(submitForm)="onSubmit()">
|
||||||
<div before class="btn-group">
|
<div before class="btn-group">
|
||||||
<button (click)="onCancel()"
|
<button (click)="onCancel()" type="button"
|
||||||
class="btn btn-outline-secondary"><i class="fas fa-arrow-left"></i> {{messagePrefix + '.return' | translate}}</button>
|
class="btn btn-outline-secondary"><i class="fas fa-arrow-left"></i> {{messagePrefix + '.return' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
<div after *ngIf="groupBeingEdited != null" class="btn-group">
|
<div after *ngIf="(canEdit$ | async) && !(activeGroup$ | async)?.permanent" class="btn-group">
|
||||||
<button class="btn btn-danger delete-button" [disabled]="!(canEdit$ | async) || groupBeingEdited.permanent"
|
<button (click)="delete()" class="btn btn-danger delete-button" type="button">
|
||||||
(click)="delete()">
|
|
||||||
<i class="fa fa-trash"></i> {{ messagePrefix + '.actions.delete' | translate}}
|
<i class="fa fa-trash"></i> {{ messagePrefix + '.actions.delete' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ds-form>
|
</ds-form>
|
||||||
|
|
||||||
<div class="mb-5">
|
<ng-container *ngIf="(activeGroup$ | async) as groupBeingEdited">
|
||||||
<ds-members-list *ngIf="groupBeingEdited != null"
|
<div class="mb-5">
|
||||||
[messagePrefix]="messagePrefix + '.members-list'"></ds-members-list>
|
<ds-members-list *ngIf="groupBeingEdited != null"
|
||||||
</div>
|
[messagePrefix]="messagePrefix + '.members-list'"></ds-members-list>
|
||||||
<ds-subgroups-list *ngIf="groupBeingEdited != null"
|
</div>
|
||||||
[messagePrefix]="messagePrefix + '.subgroups-list'"></ds-subgroups-list>
|
<ds-subgroups-list *ngIf="groupBeingEdited != null"
|
||||||
|
[messagePrefix]="messagePrefix + '.subgroups-list'"></ds-subgroups-list>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||||
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { UntypedFormControl, UntypedFormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { BrowserModule, By } from '@angular/platform-browser';
|
import { BrowserModule, By } from '@angular/platform-browser';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
|
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
|
||||||
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
import { ObjectCacheService } from '../../../core/cache/object-cache.service';
|
||||||
@@ -23,14 +23,13 @@ import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
|||||||
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
|
import { HALEndpointService } from '../../../core/shared/hal-endpoint.service';
|
||||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||||
import { UUIDService } from '../../../core/shared/uuid.service';
|
import { UUIDService } from '../../../core/shared/uuid.service';
|
||||||
|
import { XSRFService } from '../../../core/xsrf/xsrf.service';
|
||||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||||
import { GroupMock, GroupMock2 } from '../../../shared/testing/group-mock';
|
import { GroupMock, GroupMock2 } from '../../../shared/testing/group-mock';
|
||||||
import { GroupFormComponent } from './group-form.component';
|
import { GroupFormComponent } from './group-form.component';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||||
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock';
|
import { getMockFormBuilderService } from '../../../shared/mocks/form-builder-service.mock';
|
||||||
import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
|
|
||||||
import { TranslateLoaderMock } from '../../../shared/testing/translate-loader.mock';
|
|
||||||
import { RouterMock } from '../../../shared/mocks/router.mock';
|
import { RouterMock } from '../../../shared/mocks/router.mock';
|
||||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
@@ -38,23 +37,24 @@ import { ValidateGroupExists } from './validators/group-exists.validator';
|
|||||||
import { NoContent } from '../../../core/shared/NoContent.model';
|
import { NoContent } from '../../../core/shared/NoContent.model';
|
||||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
import { DSONameServiceMock } from '../../../shared/mocks/dso-name.service.mock';
|
import { DSONameServiceMock } from '../../../shared/mocks/dso-name.service.mock';
|
||||||
|
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
|
||||||
|
|
||||||
describe('GroupFormComponent', () => {
|
describe('GroupFormComponent', () => {
|
||||||
let component: GroupFormComponent;
|
let component: GroupFormComponent;
|
||||||
let fixture: ComponentFixture<GroupFormComponent>;
|
let fixture: ComponentFixture<GroupFormComponent>;
|
||||||
let translateService: TranslateService;
|
|
||||||
let builderService: FormBuilderService;
|
let builderService: FormBuilderService;
|
||||||
let ePersonDataServiceStub: any;
|
let ePersonDataServiceStub: any;
|
||||||
let groupsDataServiceStub: any;
|
let groupsDataServiceStub: any;
|
||||||
let dsoDataServiceStub: any;
|
let dsoDataServiceStub: any;
|
||||||
let authorizationService: AuthorizationDataService;
|
let authorizationService: AuthorizationDataService;
|
||||||
let notificationService: NotificationsServiceStub;
|
let notificationService: NotificationsServiceStub;
|
||||||
let router;
|
let router: RouterMock;
|
||||||
|
let route: ActivatedRouteStub;
|
||||||
|
|
||||||
let groups;
|
let groups: Group[];
|
||||||
let groupName;
|
let groupName: string;
|
||||||
let groupDescription;
|
let groupDescription: string;
|
||||||
let expected;
|
let expected: Group;
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
groups = [GroupMock, GroupMock2];
|
groups = [GroupMock, GroupMock2];
|
||||||
@@ -69,6 +69,15 @@ describe('GroupFormComponent', () => {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
object: createSuccessfulRemoteDataObject$(undefined),
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'group-selflink',
|
||||||
|
},
|
||||||
|
object: {
|
||||||
|
href: 'group-objectlink',
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
ePersonDataServiceStub = {};
|
ePersonDataServiceStub = {};
|
||||||
groupsDataServiceStub = {
|
groupsDataServiceStub = {
|
||||||
@@ -105,7 +114,14 @@ describe('GroupFormComponent', () => {
|
|||||||
create(group: Group): Observable<RemoteData<Group>> {
|
create(group: Group): Observable<RemoteData<Group>> {
|
||||||
this.allGroups = [...this.allGroups, group];
|
this.allGroups = [...this.allGroups, group];
|
||||||
this.createdGroup = Object.assign({}, group, {
|
this.createdGroup = Object.assign({}, group, {
|
||||||
_links: { self: { href: 'group-selflink' } }
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'group-selflink',
|
||||||
|
},
|
||||||
|
object: {
|
||||||
|
href: 'group-objectlink',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return createSuccessfulRemoteDataObject$(this.createdGroup);
|
return createSuccessfulRemoteDataObject$(this.createdGroup);
|
||||||
},
|
},
|
||||||
@@ -187,17 +203,13 @@ describe('GroupFormComponent', () => {
|
|||||||
return typeof value === 'object' && value !== null;
|
return typeof value === 'object' && value !== null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
translateService = getMockTranslateService();
|
|
||||||
router = new RouterMock();
|
router = new RouterMock();
|
||||||
|
route = new ActivatedRouteStub();
|
||||||
notificationService = new NotificationsServiceStub();
|
notificationService = new NotificationsServiceStub();
|
||||||
|
|
||||||
return TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot(),
|
||||||
loader: {
|
|
||||||
provide: TranslateLoader,
|
|
||||||
useClass: TranslateLoaderMock
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
declarations: [GroupFormComponent],
|
declarations: [GroupFormComponent],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -211,17 +223,15 @@ describe('GroupFormComponent', () => {
|
|||||||
{ provide: HttpClient, useValue: {} },
|
{ provide: HttpClient, useValue: {} },
|
||||||
{ provide: ObjectCacheService, useValue: {} },
|
{ provide: ObjectCacheService, useValue: {} },
|
||||||
{ provide: UUIDService, useValue: {} },
|
{ provide: UUIDService, useValue: {} },
|
||||||
|
{ provide: XSRFService, useValue: {} },
|
||||||
{ provide: Store, useValue: {} },
|
{ provide: Store, useValue: {} },
|
||||||
{ provide: RemoteDataBuildService, useValue: {} },
|
{ provide: RemoteDataBuildService, useValue: {} },
|
||||||
{ provide: HALEndpointService, useValue: {} },
|
{ provide: HALEndpointService, useValue: {} },
|
||||||
{
|
{ provide: ActivatedRoute, useValue: route },
|
||||||
provide: ActivatedRoute,
|
|
||||||
useValue: { data: observableOf({ dso: { payload: {} } }), params: observableOf({}) }
|
|
||||||
},
|
|
||||||
{ provide: Router, useValue: router },
|
{ provide: Router, useValue: router },
|
||||||
{ provide: AuthorizationDataService, useValue: authorizationService },
|
{ provide: AuthorizationDataService, useValue: authorizationService },
|
||||||
],
|
],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -234,8 +244,8 @@ describe('GroupFormComponent', () => {
|
|||||||
describe('when submitting the form', () => {
|
describe('when submitting the form', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(component.submitForm, 'emit');
|
spyOn(component.submitForm, 'emit');
|
||||||
component.groupName.value = groupName;
|
component.groupName.setValue(groupName);
|
||||||
component.groupDescription.value = groupDescription;
|
component.groupDescription.setValue(groupDescription);
|
||||||
});
|
});
|
||||||
describe('without active Group', () => {
|
describe('without active Group', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -243,14 +253,22 @@ describe('GroupFormComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit a new group using the correct values', (async () => {
|
it('should emit a new group using the correct values', (() => {
|
||||||
await fixture.whenStable().then(() => {
|
expect(component.submitForm.emit).toHaveBeenCalledWith(jasmine.objectContaining({
|
||||||
expect(component.submitForm.emit).toHaveBeenCalledWith(expected);
|
name: groupName,
|
||||||
});
|
metadata: {
|
||||||
|
'dc.description': [
|
||||||
|
{
|
||||||
|
value: groupDescription,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}));
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with active Group', () => {
|
describe('with active Group', () => {
|
||||||
let expected2;
|
let expected2: Group;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
expected2 = Object.assign(new Group(), {
|
expected2 = Object.assign(new Group(), {
|
||||||
name: 'newGroupName',
|
name: 'newGroupName',
|
||||||
@@ -261,15 +279,24 @@ describe('GroupFormComponent', () => {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
object: createSuccessfulRemoteDataObject$(undefined),
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'group-selflink',
|
||||||
|
},
|
||||||
|
object: {
|
||||||
|
href: 'group-objectlink',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
spyOn(groupsDataServiceStub, 'getActiveGroup').and.returnValue(observableOf(expected));
|
spyOn(groupsDataServiceStub, 'getActiveGroup').and.returnValue(observableOf(expected));
|
||||||
spyOn(groupsDataServiceStub, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(expected2));
|
spyOn(groupsDataServiceStub, 'patch').and.returnValue(createSuccessfulRemoteDataObject$(expected2));
|
||||||
component.groupName.value = 'newGroupName';
|
component.ngOnInit();
|
||||||
component.onSubmit();
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should edit with name and description operations', () => {
|
it('should edit with name and description operations', () => {
|
||||||
|
component.groupName.setValue('newGroupName');
|
||||||
|
component.onSubmit();
|
||||||
const operations = [{
|
const operations = [{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
path: '/metadata/dc.description',
|
path: '/metadata/dc.description',
|
||||||
@@ -283,9 +310,8 @@ describe('GroupFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should edit with description operations', () => {
|
it('should edit with description operations', () => {
|
||||||
component.groupName.value = null;
|
component.groupName.setValue(null);
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
fixture.detectChanges();
|
|
||||||
const operations = [{
|
const operations = [{
|
||||||
op: 'add',
|
op: 'add',
|
||||||
path: '/metadata/dc.description',
|
path: '/metadata/dc.description',
|
||||||
@@ -295,9 +321,9 @@ describe('GroupFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should edit with name operations', () => {
|
it('should edit with name operations', () => {
|
||||||
component.groupDescription.value = null;
|
component.groupName.setValue('newGroupName');
|
||||||
|
component.groupDescription.setValue(null);
|
||||||
component.onSubmit();
|
component.onSubmit();
|
||||||
fixture.detectChanges();
|
|
||||||
const operations = [{
|
const operations = [{
|
||||||
op: 'replace',
|
op: 'replace',
|
||||||
path: '/name',
|
path: '/name',
|
||||||
@@ -306,12 +332,13 @@ describe('GroupFormComponent', () => {
|
|||||||
expect(groupsDataServiceStub.patch).toHaveBeenCalledWith(expected, operations);
|
expect(groupsDataServiceStub.patch).toHaveBeenCalledWith(expected, operations);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit the existing group using the correct new values', (async () => {
|
it('should emit the existing group using the correct new values', () => {
|
||||||
await fixture.whenStable().then(() => {
|
component.onSubmit();
|
||||||
expect(component.submitForm.emit).toHaveBeenCalledWith(expected2);
|
expect(component.submitForm.emit).toHaveBeenCalledWith(expected2);
|
||||||
});
|
});
|
||||||
}));
|
|
||||||
it('should emit success notification', () => {
|
it('should emit success notification', () => {
|
||||||
|
component.onSubmit();
|
||||||
expect(notificationService.success).toHaveBeenCalled();
|
expect(notificationService.success).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -326,11 +353,8 @@ describe('GroupFormComponent', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe('check form validation', () => {
|
describe('check form validation', () => {
|
||||||
let groupCommunity;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
groupName = 'testName';
|
groupName = 'testName';
|
||||||
groupCommunity = 'testgroupCommunity';
|
|
||||||
groupDescription = 'testgroupDescription';
|
groupDescription = 'testgroupDescription';
|
||||||
|
|
||||||
expected = Object.assign(new Group(), {
|
expected = Object.assign(new Group(), {
|
||||||
@@ -342,8 +366,17 @@ describe('GroupFormComponent', () => {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
_links: {
|
||||||
|
self: {
|
||||||
|
href: 'group-selflink',
|
||||||
|
},
|
||||||
|
object: {
|
||||||
|
href: 'group-objectlink',
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
spyOn(component.submitForm, 'emit');
|
spyOn(component.submitForm, 'emit');
|
||||||
|
spyOn(dsoDataServiceStub, 'findByHref').and.returnValue(observableOf(expected));
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.initialisePage();
|
component.initialisePage();
|
||||||
@@ -393,21 +426,20 @@ describe('GroupFormComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('delete', () => {
|
describe('delete', () => {
|
||||||
let deleteButton;
|
let deleteButton: HTMLButtonElement;
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
component.initialisePage();
|
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
||||||
|
component.activeGroup$ = observableOf({
|
||||||
|
id: 'active-group',
|
||||||
|
permanent: false,
|
||||||
|
} as Group);
|
||||||
component.canEdit$ = observableOf(true);
|
component.canEdit$ = observableOf(true);
|
||||||
component.groupBeingEdited = {
|
|
||||||
permanent: false
|
component.initialisePage();
|
||||||
} as Group;
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
deleteButton = fixture.debugElement.query(By.css('.delete-button')).nativeElement;
|
deleteButton = fixture.debugElement.query(By.css('.delete-button')).nativeElement;
|
||||||
|
|
||||||
spyOn(groupsDataServiceStub, 'delete').and.callThrough();
|
|
||||||
spyOn(groupsDataServiceStub, 'getActiveGroup').and.returnValue(observableOf({ id: 'active-group' }));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('if confirmed via modal', () => {
|
describe('if confirmed via modal', () => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Component, EventEmitter, HostListener, OnDestroy, OnInit, Output, ChangeDetectorRef } from '@angular/core';
|
import { Component, EventEmitter, HostListener, OnDestroy, OnInit, Output, ChangeDetectorRef } from '@angular/core';
|
||||||
import { UntypedFormGroup } from '@angular/forms';
|
import { UntypedFormGroup, AbstractControl } from '@angular/forms';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
@@ -10,13 +10,11 @@ import {
|
|||||||
} from '@ng-dynamic-forms/core';
|
} from '@ng-dynamic-forms/core';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
ObservedValueOf,
|
|
||||||
combineLatest as observableCombineLatest,
|
combineLatest as observableCombineLatest,
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
|
||||||
Subscription,
|
Subscription,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { catchError, map, switchMap, take, filter, debounceTime } from 'rxjs/operators';
|
import { map, switchMap, take, debounceTime } from 'rxjs/operators';
|
||||||
import { getCollectionEditRolesRoute } from '../../../collection-page/collection-page-routing-paths';
|
import { getCollectionEditRolesRoute } from '../../../collection-page/collection-page-routing-paths';
|
||||||
import { getCommunityEditRolesRoute } from '../../../community-page/community-page-routing-paths';
|
import { getCommunityEditRolesRoute } from '../../../community-page/community-page-routing-paths';
|
||||||
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../../core/data/dspace-object-data.service';
|
||||||
@@ -25,19 +23,18 @@ import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
|||||||
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
|
|
||||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||||
import { Group } from '../../../core/eperson/models/group.model';
|
import { Group } from '../../../core/eperson/models/group.model';
|
||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { Community } from '../../../core/shared/community.model';
|
import { Community } from '../../../core/shared/community.model';
|
||||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||||
import {
|
import {
|
||||||
|
getAllCompletedRemoteData,
|
||||||
getRemoteDataPayload,
|
getRemoteDataPayload,
|
||||||
getFirstSucceededRemoteData,
|
getFirstSucceededRemoteData,
|
||||||
getFirstCompletedRemoteData,
|
getFirstCompletedRemoteData,
|
||||||
getFirstSucceededRemoteDataPayload
|
|
||||||
} from '../../../core/shared/operators';
|
} from '../../../core/shared/operators';
|
||||||
import { AlertType } from '../../../shared/alert/aletr-type';
|
import { AlertType } from '../../../shared/alert/alert-type';
|
||||||
import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/confirmation-modal.component';
|
import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/confirmation-modal.component';
|
||||||
import { hasValue, isNotEmpty, hasValueOperator } from '../../../shared/empty.util';
|
import { hasValue, isNotEmpty, hasValueOperator } from '../../../shared/empty.util';
|
||||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||||
@@ -48,6 +45,7 @@ import { Operation } from 'fast-json-patch';
|
|||||||
import { ValidateGroupExists } from './validators/group-exists.validator';
|
import { ValidateGroupExists } from './validators/group-exists.validator';
|
||||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
|
import { getGroupEditRoute, getGroupsRoute } from '../../access-control-routing-paths';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-group-form',
|
selector: 'ds-group-form',
|
||||||
@@ -68,9 +66,9 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* Dynamic models for the inputs of form
|
* Dynamic models for the inputs of form
|
||||||
*/
|
*/
|
||||||
groupName: DynamicInputModel;
|
groupName: AbstractControl;
|
||||||
groupCommunity: DynamicInputModel;
|
groupCommunity: AbstractControl;
|
||||||
groupDescription: DynamicTextAreaModel;
|
groupDescription: AbstractControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of all dynamic input models
|
* A list of all dynamic input models
|
||||||
@@ -113,21 +111,30 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
subs: Subscription[] = [];
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Group currently being edited
|
|
||||||
*/
|
|
||||||
groupBeingEdited: Group;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observable whether or not the logged in user is allowed to delete the Group & doesn't have a linked object (community / collection linked to workspace group
|
* Observable whether or not the logged in user is allowed to delete the Group & doesn't have a linked object (community / collection linked to workspace group
|
||||||
*/
|
*/
|
||||||
canEdit$: Observable<boolean>;
|
canEdit$: Observable<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AlertType enumeration
|
* The current {@link Group}
|
||||||
* @type {AlertType}
|
|
||||||
*/
|
*/
|
||||||
public AlertTypeEnum = AlertType;
|
activeGroup$: Observable<Group>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current {@link Group}'s linked {@link Community}/{@link Collection}
|
||||||
|
*/
|
||||||
|
activeGroupLinkedDSO$: Observable<DSpaceObject>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link to the current {@link Group}'s {@link Community}/{@link Collection} edit role tab
|
||||||
|
*/
|
||||||
|
linkedEditRolesRoute$: Observable<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AlertType enumeration
|
||||||
|
*/
|
||||||
|
public readonly AlertType = AlertType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscription to email field value change
|
* Subscription to email field value change
|
||||||
@@ -137,124 +144,121 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public groupDataService: GroupDataService,
|
public groupDataService: GroupDataService,
|
||||||
private ePersonDataService: EPersonDataService,
|
protected dSpaceObjectDataService: DSpaceObjectDataService,
|
||||||
private dSpaceObjectDataService: DSpaceObjectDataService,
|
protected formBuilderService: FormBuilderService,
|
||||||
private formBuilderService: FormBuilderService,
|
protected translateService: TranslateService,
|
||||||
private translateService: TranslateService,
|
protected notificationsService: NotificationsService,
|
||||||
private notificationsService: NotificationsService,
|
protected route: ActivatedRoute,
|
||||||
private route: ActivatedRoute,
|
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
private authorizationService: AuthorizationDataService,
|
protected authorizationService: AuthorizationDataService,
|
||||||
private modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
public requestService: RequestService,
|
public requestService: RequestService,
|
||||||
protected changeDetectorRef: ChangeDetectorRef,
|
protected changeDetectorRef: ChangeDetectorRef,
|
||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit(): void {
|
||||||
|
if (this.route.snapshot.params.groupId !== 'newGroup') {
|
||||||
|
this.setActiveGroup(this.route.snapshot.params.groupId);
|
||||||
|
}
|
||||||
|
this.activeGroup$ = this.groupDataService.getActiveGroup();
|
||||||
|
this.activeGroupLinkedDSO$ = this.getActiveGroupLinkedDSO();
|
||||||
|
this.linkedEditRolesRoute$ = this.getLinkedEditRolesRoute();
|
||||||
|
this.canEdit$ = this.activeGroupLinkedDSO$.pipe(
|
||||||
|
switchMap((dso: DSpaceObject) => {
|
||||||
|
if (hasValue(dso)) {
|
||||||
|
return [false];
|
||||||
|
} else {
|
||||||
|
return this.activeGroup$.pipe(
|
||||||
|
hasValueOperator(),
|
||||||
|
switchMap((group: Group) => this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
this.initialisePage();
|
this.initialisePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialisePage() {
|
initialisePage() {
|
||||||
this.subs.push(this.route.params.subscribe((params) => {
|
const groupNameModel = new DynamicInputModel({
|
||||||
if (params.groupId !== 'newGroup') {
|
id: 'groupName',
|
||||||
this.setActiveGroup(params.groupId);
|
label: this.translateService.instant(`${this.messagePrefix}.groupName`),
|
||||||
}
|
name: 'groupName',
|
||||||
}));
|
validators: {
|
||||||
this.canEdit$ = this.groupDataService.getActiveGroup().pipe(
|
required: null,
|
||||||
hasValueOperator(),
|
},
|
||||||
switchMap((group: Group) => {
|
required: true,
|
||||||
return observableCombineLatest(
|
});
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanDelete, isNotEmpty(group) ? group.self : undefined),
|
const groupCommunityModel = new DynamicInputModel({
|
||||||
this.hasLinkedDSO(group),
|
id: 'groupCommunity',
|
||||||
(isAuthorized: ObservedValueOf<Observable<boolean>>, hasLinkedDSO: ObservedValueOf<Observable<boolean>>) => {
|
label: this.translateService.instant(`${this.messagePrefix}.groupCommunity`),
|
||||||
return isAuthorized && !hasLinkedDSO;
|
name: 'groupCommunity',
|
||||||
});
|
required: false,
|
||||||
|
readOnly: true,
|
||||||
|
});
|
||||||
|
const groupDescriptionModel = new DynamicTextAreaModel({
|
||||||
|
id: 'groupDescription',
|
||||||
|
label: this.translateService.instant(`${this.messagePrefix}.groupDescription`),
|
||||||
|
name: 'groupDescription',
|
||||||
|
required: false,
|
||||||
|
spellCheck: environment.form.spellCheck,
|
||||||
|
});
|
||||||
|
this.formModel = [
|
||||||
|
groupNameModel,
|
||||||
|
groupDescriptionModel,
|
||||||
|
];
|
||||||
|
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
||||||
|
this.groupName = this.formGroup.get('groupName');
|
||||||
|
this.groupDescription = this.formGroup.get('groupDescription');
|
||||||
|
|
||||||
|
if (hasValue(this.groupName)) {
|
||||||
|
this.groupName.setAsyncValidators(ValidateGroupExists.createValidator(this.groupDataService));
|
||||||
|
this.groupNameValueChangeSubscribe = this.groupName.valueChanges.pipe(debounceTime(300)).subscribe(() => {
|
||||||
|
this.changeDetectorRef.detectChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.subs.push(
|
||||||
|
observableCombineLatest([
|
||||||
|
this.activeGroup$,
|
||||||
|
this.canEdit$,
|
||||||
|
this.activeGroupLinkedDSO$,
|
||||||
|
]).subscribe(([activeGroup, canEdit, linkedObject]) => {
|
||||||
|
|
||||||
|
if (activeGroup != null) {
|
||||||
|
|
||||||
|
// Disable group name exists validator
|
||||||
|
this.formGroup.controls.groupName.clearAsyncValidators();
|
||||||
|
|
||||||
|
if (isNotEmpty(linkedObject?.name)) {
|
||||||
|
if (!this.formGroup.controls.groupCommunity) {
|
||||||
|
this.formBuilderService.insertFormGroupControl(1, this.formGroup, this.formModel, groupCommunityModel);
|
||||||
|
this.groupDescription = this.formGroup.get('groupCommunity');
|
||||||
|
}
|
||||||
|
this.formGroup.patchValue({
|
||||||
|
groupName: activeGroup.name,
|
||||||
|
groupCommunity: linkedObject?.name ?? '',
|
||||||
|
groupDescription: activeGroup.firstMetadataValue('dc.description'),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.formModel = [
|
||||||
|
groupNameModel,
|
||||||
|
groupDescriptionModel,
|
||||||
|
];
|
||||||
|
this.formGroup.patchValue({
|
||||||
|
groupName: activeGroup.name,
|
||||||
|
groupDescription: activeGroup.firstMetadataValue('dc.description'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!canEdit || activeGroup.permanent) {
|
||||||
|
this.formGroup.disable();
|
||||||
|
} else {
|
||||||
|
this.formGroup.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
observableCombineLatest(
|
|
||||||
this.translateService.get(`${this.messagePrefix}.groupName`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.groupCommunity`),
|
|
||||||
this.translateService.get(`${this.messagePrefix}.groupDescription`)
|
|
||||||
).subscribe(([groupName, groupCommunity, groupDescription]) => {
|
|
||||||
this.groupName = new DynamicInputModel({
|
|
||||||
id: 'groupName',
|
|
||||||
label: groupName,
|
|
||||||
name: 'groupName',
|
|
||||||
validators: {
|
|
||||||
required: null,
|
|
||||||
},
|
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
this.groupCommunity = new DynamicInputModel({
|
|
||||||
id: 'groupCommunity',
|
|
||||||
label: groupCommunity,
|
|
||||||
name: 'groupCommunity',
|
|
||||||
required: false,
|
|
||||||
readOnly: true,
|
|
||||||
});
|
|
||||||
this.groupDescription = new DynamicTextAreaModel({
|
|
||||||
id: 'groupDescription',
|
|
||||||
label: groupDescription,
|
|
||||||
name: 'groupDescription',
|
|
||||||
required: false,
|
|
||||||
spellCheck: environment.form.spellCheck,
|
|
||||||
});
|
|
||||||
this.formModel = [
|
|
||||||
this.groupName,
|
|
||||||
this.groupDescription,
|
|
||||||
];
|
|
||||||
this.formGroup = this.formBuilderService.createFormGroup(this.formModel);
|
|
||||||
|
|
||||||
if (!!this.formGroup.controls.groupName) {
|
|
||||||
this.formGroup.controls.groupName.setAsyncValidators(ValidateGroupExists.createValidator(this.groupDataService));
|
|
||||||
this.groupNameValueChangeSubscribe = this.groupName.valueChanges.pipe(debounceTime(300)).subscribe(() => {
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.subs.push(
|
|
||||||
observableCombineLatest(
|
|
||||||
this.groupDataService.getActiveGroup(),
|
|
||||||
this.canEdit$,
|
|
||||||
this.groupDataService.getActiveGroup()
|
|
||||||
.pipe(filter((activeGroup) => hasValue(activeGroup)),switchMap((activeGroup) => this.getLinkedDSO(activeGroup).pipe(getFirstSucceededRemoteDataPayload())))
|
|
||||||
).subscribe(([activeGroup, canEdit, linkedObject]) => {
|
|
||||||
|
|
||||||
if (activeGroup != null) {
|
|
||||||
|
|
||||||
// Disable group name exists validator
|
|
||||||
this.formGroup.controls.groupName.clearAsyncValidators();
|
|
||||||
|
|
||||||
this.groupBeingEdited = activeGroup;
|
|
||||||
|
|
||||||
if (linkedObject?.name) {
|
|
||||||
this.formBuilderService.insertFormGroupControl(1, this.formGroup, this.formModel, this.groupCommunity);
|
|
||||||
this.formGroup.patchValue({
|
|
||||||
groupName: activeGroup.name,
|
|
||||||
groupCommunity: linkedObject?.name ?? '',
|
|
||||||
groupDescription: activeGroup.firstMetadataValue('dc.description'),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.formModel = [
|
|
||||||
this.groupName,
|
|
||||||
this.groupDescription,
|
|
||||||
];
|
|
||||||
this.formGroup.patchValue({
|
|
||||||
groupName: activeGroup.name,
|
|
||||||
groupDescription: activeGroup.firstMetadataValue('dc.description'),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!canEdit || activeGroup.permanent) {
|
|
||||||
this.formGroup.disable();
|
|
||||||
}
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +267,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
onCancel() {
|
onCancel() {
|
||||||
this.groupDataService.cancelEditGroup();
|
this.groupDataService.cancelEditGroup();
|
||||||
this.cancelForm.emit();
|
this.cancelForm.emit();
|
||||||
this.router.navigate([this.groupDataService.getGroupRegistryRouterLink()]);
|
void this.router.navigate([getGroupsRoute()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,25 +277,22 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
* Emit the updated/created eperson using the EventEmitter submitForm
|
* Emit the updated/created eperson using the EventEmitter submitForm
|
||||||
*/
|
*/
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe(
|
this.activeGroup$.pipe(take(1)).subscribe((group: Group) => {
|
||||||
(group: Group) => {
|
if (group === null) {
|
||||||
const values = {
|
this.createNewGroup({
|
||||||
name: this.groupName.value,
|
name: this.groupName.value,
|
||||||
metadata: {
|
metadata: {
|
||||||
'dc.description': [
|
'dc.description': [
|
||||||
{
|
{
|
||||||
value: this.groupDescription.value
|
value: this.groupDescription.value,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
if (group === null) {
|
} else {
|
||||||
this.createNewGroup(values);
|
this.editGroup(group);
|
||||||
} else {
|
|
||||||
this.editGroup(group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -310,7 +311,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
const groupSelfLink = rd.payload._links.self.href;
|
const groupSelfLink = rd.payload._links.self.href;
|
||||||
this.setActiveGroupWithLink(groupSelfLink);
|
this.setActiveGroupWithLink(groupSelfLink);
|
||||||
this.groupDataService.clearGroupsRequests();
|
this.groupDataService.clearGroupsRequests();
|
||||||
this.router.navigateByUrl(this.groupDataService.getGroupEditPageRouterLinkWithID(rd.payload.uuid));
|
void this.router.navigateByUrl(getGroupEditRoute(rd.payload.uuid));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.created.failure', { name: groupToCreate.name }));
|
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.created.failure', { name: groupToCreate.name }));
|
||||||
@@ -397,7 +398,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
* @param groupSelfLink SelfLink of group to set as active
|
* @param groupSelfLink SelfLink of group to set as active
|
||||||
*/
|
*/
|
||||||
setActiveGroupWithLink(groupSelfLink: string) {
|
setActiveGroupWithLink(groupSelfLink: string) {
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
this.activeGroup$.pipe(take(1)).subscribe((activeGroup: Group) => {
|
||||||
if (activeGroup === null) {
|
if (activeGroup === null) {
|
||||||
this.groupDataService.cancelEditGroup();
|
this.groupDataService.cancelEditGroup();
|
||||||
this.groupDataService.findByHref(groupSelfLink, false, false, followLink('subgroups'), followLink('epersons'), followLink('object'))
|
this.groupDataService.findByHref(groupSelfLink, false, false, followLink('subgroups'), followLink('epersons'), followLink('object'))
|
||||||
@@ -416,7 +417,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
* It'll either show a success or error message depending on whether the delete was successful or not.
|
* It'll either show a success or error message depending on whether the delete was successful or not.
|
||||||
*/
|
*/
|
||||||
delete() {
|
delete() {
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((group: Group) => {
|
this.activeGroup$.pipe(take(1)).subscribe((group: Group) => {
|
||||||
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
const modalRef = this.modalService.open(ConfirmationModalComponent);
|
||||||
modalRef.componentInstance.dso = group;
|
modalRef.componentInstance.dso = group;
|
||||||
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-group.modal.header';
|
modalRef.componentInstance.headerLabel = this.messagePrefix + '.delete-group.modal.header';
|
||||||
@@ -460,52 +461,38 @@ export class GroupFormComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if group has a linked object (community or collection linked to a workflow group)
|
* Get the active {@link Group}'s linked object if it has one ({@link Community} or {@link Collection} linked to a
|
||||||
* @param group
|
* workflow group)
|
||||||
*/
|
*/
|
||||||
hasLinkedDSO(group: Group): Observable<boolean> {
|
getActiveGroupLinkedDSO(): Observable<DSpaceObject> {
|
||||||
if (hasValue(group) && hasValue(group._links.object.href)) {
|
return this.activeGroup$.pipe(
|
||||||
return this.getLinkedDSO(group).pipe(
|
hasValueOperator(),
|
||||||
map((rd: RemoteData<DSpaceObject>) => {
|
switchMap((group: Group) => {
|
||||||
return hasValue(rd) && hasValue(rd.payload);
|
if (group.object === undefined) {
|
||||||
}),
|
return this.dSpaceObjectDataService.findByHref(group._links.object.href);
|
||||||
catchError(() => observableOf(false)),
|
}
|
||||||
);
|
return group.object;
|
||||||
}
|
}),
|
||||||
|
getAllCompletedRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get group's linked object if it has one (community or collection linked to a workflow group)
|
* Get the route to the edit roles tab of the active {@link Group}'s linked object (community or collection linked
|
||||||
* @param group
|
* to a workflow group) if it has one
|
||||||
*/
|
*/
|
||||||
getLinkedDSO(group: Group): Observable<RemoteData<DSpaceObject>> {
|
getLinkedEditRolesRoute(): Observable<string> {
|
||||||
if (hasValue(group) && hasValue(group._links.object.href)) {
|
return this.activeGroupLinkedDSO$.pipe(
|
||||||
if (group.object === undefined) {
|
hasValueOperator(),
|
||||||
return this.dSpaceObjectDataService.findByHref(group._links.object.href);
|
map((dso: DSpaceObject) => {
|
||||||
}
|
switch ((dso as any).type) {
|
||||||
return group.object;
|
case Community.type.value:
|
||||||
}
|
return getCommunityEditRolesRoute(dso.id);
|
||||||
}
|
case Collection.type.value:
|
||||||
|
return getCollectionEditRolesRoute(dso.id);
|
||||||
/**
|
}
|
||||||
* Get the route to the edit roles tab of the group's linked object (community or collection linked to a workflow group) if it has one
|
}),
|
||||||
* @param group
|
);
|
||||||
*/
|
|
||||||
getLinkedEditRolesRoute(group: Group): Observable<string> {
|
|
||||||
if (hasValue(group) && hasValue(group._links.object.href)) {
|
|
||||||
return this.getLinkedDSO(group).pipe(
|
|
||||||
map((rd: RemoteData<DSpaceObject>) => {
|
|
||||||
if (hasValue(rd) && hasValue(rd.payload)) {
|
|
||||||
const dso = rd.payload;
|
|
||||||
switch ((dso as any).type) {
|
|
||||||
case Community.type.value:
|
|
||||||
return getCommunityEditRolesRoute(rd.payload.id);
|
|
||||||
case Collection.type.value:
|
|
||||||
return getCollectionEditRolesRoute(rd.payload.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,110 +1,11 @@
|
|||||||
<ng-container>
|
<ng-container>
|
||||||
<h3 class="border-bottom pb-2">{{messagePrefix + '.head' | translate}}</h3>
|
<h2 class="border-bottom pb-2">{{messagePrefix + '.head' | translate}}</h2>
|
||||||
|
|
||||||
<h4 id="search" class="border-bottom pb-2">
|
<h3>{{messagePrefix + '.headMembers' | translate}}</h3>
|
||||||
<span
|
|
||||||
*dsContextHelp="{
|
|
||||||
content: 'admin.access-control.groups.form.tooltip.editGroup.addEpeople',
|
|
||||||
id: 'edit-group-add-epeople',
|
|
||||||
iconPlacement: 'right',
|
|
||||||
tooltipPlacement: ['top', 'right', 'bottom']
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
{{messagePrefix + '.search.head' | translate}}
|
|
||||||
</span>
|
|
||||||
</h4>
|
|
||||||
|
|
||||||
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
<ds-pagination *ngIf="(ePeopleMembersOfGroup | async)?.totalElements > 0"
|
||||||
<div>
|
|
||||||
<select name="scope" id="scope" formControlName="scope" class="form-control" aria-label="Search scope">
|
|
||||||
<option value="metadata">{{messagePrefix + '.search.scope.metadata' | translate}}</option>
|
|
||||||
<option value="email">{{messagePrefix + '.search.scope.email' | translate}}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="flex-grow-1 mr-3 ml-3">
|
|
||||||
<div class="form-group input-group">
|
|
||||||
<input type="text" name="query" id="query" formControlName="query"
|
|
||||||
class="form-control" aria-label="Search input">
|
|
||||||
<span class="input-group-append">
|
|
||||||
<button type="submit" class="search-button btn btn-primary">
|
|
||||||
<i class="fas fa-search"></i> {{ messagePrefix + '.search.button' | translate }}</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button (click)="clearFormAndResetResult();"
|
|
||||||
class="btn btn-secondary">{{messagePrefix + '.button.see-all' | translate}}</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ds-pagination *ngIf="(ePeopleSearchDtos | async)?.totalElements > 0"
|
|
||||||
[paginationOptions]="configSearch"
|
|
||||||
[pageInfoState]="(ePeopleSearchDtos | async)"
|
|
||||||
[collectionSize]="(ePeopleSearchDtos | async)?.totalElements"
|
|
||||||
[hideGear]="true"
|
|
||||||
[hidePagerWhenSinglePage]="true">
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table id="epersonsSearch" class="table table-striped table-hover table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.identity' | translate}}</th>
|
|
||||||
<th class="align-middle">{{messagePrefix + '.table.edit' | translate}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let ePerson of (ePeopleSearchDtos | async)?.page">
|
|
||||||
<td class="align-middle">{{ePerson.eperson.id}}</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
<a (click)="ePersonDataService.startEditingNewEPerson(ePerson.eperson)"
|
|
||||||
[routerLink]="[ePersonDataService.getEPeoplePageRouterLink()]">
|
|
||||||
{{ dsoNameService.getName(ePerson.eperson) }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
{{messagePrefix + '.table.email' | translate}}: {{ ePerson.eperson.email ? ePerson.eperson.email : '-' }}<br/>
|
|
||||||
{{messagePrefix + '.table.netid' | translate}}: {{ ePerson.eperson.netid ? ePerson.eperson.netid : '-' }}
|
|
||||||
</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
<div class="btn-group edit-field">
|
|
||||||
<button *ngIf="ePerson.memberOfGroup"
|
|
||||||
(click)="deleteMemberFromGroup(ePerson)"
|
|
||||||
[disabled]="actionConfig.remove.disabled"
|
|
||||||
[ngClass]="['btn btn-sm', actionConfig.remove.css]"
|
|
||||||
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: { name: dsoNameService.getName(ePerson.eperson) } }}">
|
|
||||||
<i [ngClass]="actionConfig.remove.icon"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button *ngIf="!ePerson.memberOfGroup"
|
|
||||||
(click)="addMemberToGroup(ePerson)"
|
|
||||||
[disabled]="actionConfig.add.disabled"
|
|
||||||
[ngClass]="['btn btn-sm', actionConfig.add.css]"
|
|
||||||
title="{{messagePrefix + '.table.edit.buttons.add' | translate: { name: dsoNameService.getName(ePerson.eperson) } }}">
|
|
||||||
<i [ngClass]="actionConfig.add.icon"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</ds-pagination>
|
|
||||||
|
|
||||||
<div *ngIf="(ePeopleSearchDtos | async)?.totalElements == 0 && searchDone"
|
|
||||||
class="alert alert-info w-100 mb-2"
|
|
||||||
role="alert">
|
|
||||||
{{messagePrefix + '.no-items' | translate}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4>{{messagePrefix + '.headMembers' | translate}}</h4>
|
|
||||||
|
|
||||||
<ds-pagination *ngIf="(ePeopleMembersOfGroupDtos | async)?.totalElements > 0"
|
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="(ePeopleMembersOfGroupDtos | async)"
|
[collectionSize]="(ePeopleMembersOfGroup | async)?.totalElements"
|
||||||
[collectionSize]="(ePeopleMembersOfGroupDtos | async)?.totalElements"
|
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
|
||||||
@@ -119,32 +20,103 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let ePerson of (ePeopleMembersOfGroupDtos | async)?.page">
|
<tr *ngFor="let eperson of (ePeopleMembersOfGroup | async)?.page">
|
||||||
<td class="align-middle">{{ePerson.eperson.id}}</td>
|
<td class="align-middle">{{eperson.id}}</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<a (click)="ePersonDataService.startEditingNewEPerson(ePerson.eperson)"
|
<a [routerLink]="getEPersonEditRoute(eperson.id)">
|
||||||
[routerLink]="[ePersonDataService.getEPeoplePageRouterLink()]">
|
{{ dsoNameService.getName(eperson) }}
|
||||||
{{ dsoNameService.getName(ePerson.eperson) }}
|
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
{{messagePrefix + '.table.email' | translate}}: {{ ePerson.eperson.email ? ePerson.eperson.email : '-' }}<br/>
|
{{messagePrefix + '.table.email' | translate}}: {{ eperson.email ? eperson.email : '-' }}<br/>
|
||||||
{{messagePrefix + '.table.netid' | translate}}: {{ ePerson.eperson.netid ? ePerson.eperson.netid : '-' }}
|
{{messagePrefix + '.table.netid' | translate}}: {{ eperson.netid ? eperson.netid : '-' }}
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle">
|
||||||
<div class="btn-group edit-field">
|
<div class="btn-group edit-field">
|
||||||
<button *ngIf="ePerson.memberOfGroup"
|
<button (click)="deleteMemberFromGroup(eperson)"
|
||||||
(click)="deleteMemberFromGroup(ePerson)"
|
[dsBtnDisabled]="actionConfig.remove.disabled"
|
||||||
[disabled]="actionConfig.remove.disabled"
|
|
||||||
[ngClass]="['btn btn-sm', actionConfig.remove.css]"
|
[ngClass]="['btn btn-sm', actionConfig.remove.css]"
|
||||||
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: { name: dsoNameService.getName(ePerson.eperson) } }}">
|
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: { name: dsoNameService.getName(eperson) } }}">
|
||||||
<i [ngClass]="actionConfig.remove.icon"></i>
|
<i [ngClass]="actionConfig.remove.icon"></i>
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="!ePerson.memberOfGroup"
|
</div>
|
||||||
(click)="addMemberToGroup(ePerson)"
|
</td>
|
||||||
[disabled]="actionConfig.add.disabled"
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</ds-pagination>
|
||||||
|
|
||||||
|
<div *ngIf="(ePeopleMembersOfGroup | async) == undefined || (ePeopleMembersOfGroup | async)?.totalElements == 0" class="alert alert-info w-100 mb-2"
|
||||||
|
role="alert">
|
||||||
|
{{messagePrefix + '.no-members-yet' | translate}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 id="search" class="border-bottom pb-2">
|
||||||
|
<span
|
||||||
|
*dsContextHelp="{
|
||||||
|
content: 'admin.access-control.groups.form.tooltip.editGroup.addEpeople',
|
||||||
|
id: 'edit-group-add-epeople',
|
||||||
|
iconPlacement: 'right',
|
||||||
|
tooltipPlacement: ['top', 'right', 'bottom']
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{messagePrefix + '.search.head' | translate}}
|
||||||
|
</span>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
||||||
|
<div class="flex-grow-1 mr-3">
|
||||||
|
<div class="form-group input-group mr-3">
|
||||||
|
<input type="text" name="query" id="query" formControlName="query"
|
||||||
|
class="form-control" aria-label="Search input">
|
||||||
|
<span class="input-group-append">
|
||||||
|
<button type="submit" class="search-button btn btn-primary">
|
||||||
|
<i class="fas fa-search"></i> {{ messagePrefix + '.search.button' | translate }}</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button (click)="clearFormAndResetResult();"
|
||||||
|
class="btn btn-secondary">{{messagePrefix + '.button.see-all' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<ds-pagination *ngIf="(ePeopleSearch | async)?.totalElements > 0"
|
||||||
|
[paginationOptions]="configSearch"
|
||||||
|
[collectionSize]="(ePeopleSearch | async)?.totalElements"
|
||||||
|
[hideGear]="true"
|
||||||
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="epersonsSearch" class="table table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.identity' | translate}}</th>
|
||||||
|
<th class="align-middle">{{messagePrefix + '.table.edit' | translate}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let eperson of (ePeopleSearch | async)?.page">
|
||||||
|
<td class="align-middle">{{eperson.id}}</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<a [routerLink]="getEPersonEditRoute(eperson.id)">
|
||||||
|
{{ dsoNameService.getName(eperson) }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
{{messagePrefix + '.table.email' | translate}}: {{ eperson.email ? eperson.email : '-' }}<br/>
|
||||||
|
{{messagePrefix + '.table.netid' | translate}}: {{ eperson.netid ? eperson.netid : '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<div class="btn-group edit-field">
|
||||||
|
<button (click)="addMemberToGroup(eperson)"
|
||||||
|
[dsBtnDisabled]="actionConfig.add.disabled"
|
||||||
[ngClass]="['btn btn-sm', actionConfig.add.css]"
|
[ngClass]="['btn btn-sm', actionConfig.add.css]"
|
||||||
title="{{messagePrefix + '.table.edit.buttons.add' | translate: { name: dsoNameService.getName(ePerson.eperson) } }}">
|
title="{{messagePrefix + '.table.edit.buttons.add' | translate: { name: dsoNameService.getName(eperson) } }}">
|
||||||
<i [ngClass]="actionConfig.add.icon"></i>
|
<i [ngClass]="actionConfig.add.icon"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -156,9 +128,10 @@
|
|||||||
|
|
||||||
</ds-pagination>
|
</ds-pagination>
|
||||||
|
|
||||||
<div *ngIf="(ePeopleMembersOfGroupDtos | async) == undefined || (ePeopleMembersOfGroupDtos | async)?.totalElements == 0" class="alert alert-info w-100 mb-2"
|
<div *ngIf="(ePeopleSearch | async)?.totalElements == 0 && searchDone"
|
||||||
|
class="alert alert-info w-100 mb-2"
|
||||||
role="alert">
|
role="alert">
|
||||||
{{messagePrefix + '.no-members-yet' | translate}}
|
{{messagePrefix + '.no-items' | translate}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -17,7 +17,7 @@ import { Group } from '../../../../core/eperson/models/group.model';
|
|||||||
import { PageInfo } from '../../../../core/shared/page-info.model';
|
import { PageInfo } from '../../../../core/shared/page-info.model';
|
||||||
import { FormBuilderService } from '../../../../shared/form/builder/form-builder.service';
|
import { FormBuilderService } from '../../../../shared/form/builder/form-builder.service';
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { GroupMock, GroupMock2 } from '../../../../shared/testing/group-mock';
|
import { GroupMock } from '../../../../shared/testing/group-mock';
|
||||||
import { MembersListComponent } from './members-list.component';
|
import { MembersListComponent } from './members-list.component';
|
||||||
import { EPersonMock, EPersonMock2 } from '../../../../shared/testing/eperson.mock';
|
import { EPersonMock, EPersonMock2 } from '../../../../shared/testing/eperson.mock';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-data.utils';
|
||||||
@@ -39,28 +39,26 @@ describe('MembersListComponent', () => {
|
|||||||
let ePersonDataServiceStub: any;
|
let ePersonDataServiceStub: any;
|
||||||
let groupsDataServiceStub: any;
|
let groupsDataServiceStub: any;
|
||||||
let activeGroup;
|
let activeGroup;
|
||||||
let allEPersons: EPerson[];
|
|
||||||
let allGroups: Group[];
|
|
||||||
let epersonMembers: EPerson[];
|
let epersonMembers: EPerson[];
|
||||||
let subgroupMembers: Group[];
|
let epersonNonMembers: EPerson[];
|
||||||
let paginationService;
|
let paginationService;
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
activeGroup = GroupMock;
|
activeGroup = GroupMock;
|
||||||
epersonMembers = [EPersonMock2];
|
epersonMembers = [EPersonMock2];
|
||||||
subgroupMembers = [GroupMock2];
|
epersonNonMembers = [EPersonMock];
|
||||||
allEPersons = [EPersonMock, EPersonMock2];
|
|
||||||
allGroups = [GroupMock, GroupMock2];
|
|
||||||
ePersonDataServiceStub = {
|
ePersonDataServiceStub = {
|
||||||
activeGroup: activeGroup,
|
activeGroup: activeGroup,
|
||||||
epersonMembers: epersonMembers,
|
epersonMembers: epersonMembers,
|
||||||
subgroupMembers: subgroupMembers,
|
epersonNonMembers: epersonNonMembers,
|
||||||
|
// This method is used to get all the current members
|
||||||
findListByHref(_href: string): Observable<RemoteData<PaginatedList<EPerson>>> {
|
findListByHref(_href: string): Observable<RemoteData<PaginatedList<EPerson>>> {
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList<EPerson>(new PageInfo(), groupsDataServiceStub.getEPersonMembers()));
|
return createSuccessfulRemoteDataObject$(buildPaginatedList<EPerson>(new PageInfo(), groupsDataServiceStub.getEPersonMembers()));
|
||||||
},
|
},
|
||||||
searchByScope(scope: string, query: string): Observable<RemoteData<PaginatedList<EPerson>>> {
|
// This method is used to search across *non-members*
|
||||||
|
searchNonMembers(query: string, group: string): Observable<RemoteData<PaginatedList<EPerson>>> {
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), allEPersons));
|
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), epersonNonMembers));
|
||||||
}
|
}
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []));
|
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []));
|
||||||
},
|
},
|
||||||
@@ -70,29 +68,26 @@ describe('MembersListComponent', () => {
|
|||||||
clearLinkRequests() {
|
clearLinkRequests() {
|
||||||
// empty
|
// empty
|
||||||
},
|
},
|
||||||
getEPeoplePageRouterLink(): string {
|
|
||||||
return '/access-control/epeople';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
groupsDataServiceStub = {
|
groupsDataServiceStub = {
|
||||||
activeGroup: activeGroup,
|
activeGroup: activeGroup,
|
||||||
epersonMembers: epersonMembers,
|
epersonMembers: epersonMembers,
|
||||||
subgroupMembers: subgroupMembers,
|
epersonNonMembers: epersonNonMembers,
|
||||||
allGroups: allGroups,
|
|
||||||
getActiveGroup(): Observable<Group> {
|
getActiveGroup(): Observable<Group> {
|
||||||
return observableOf(activeGroup);
|
return observableOf(activeGroup);
|
||||||
},
|
},
|
||||||
getEPersonMembers() {
|
getEPersonMembers() {
|
||||||
return this.epersonMembers;
|
return this.epersonMembers;
|
||||||
},
|
},
|
||||||
searchGroups(query: string): Observable<RemoteData<PaginatedList<Group>>> {
|
addMemberToGroup(parentGroup, epersonToAdd: EPerson): Observable<RestResponse> {
|
||||||
if (query === '') {
|
// Add eperson to list of members
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), this.allGroups));
|
this.epersonMembers = [...this.epersonMembers, epersonToAdd];
|
||||||
}
|
// Remove eperson from list of non-members
|
||||||
return createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []));
|
this.epersonNonMembers.forEach( (eperson: EPerson, index: number) => {
|
||||||
},
|
if (eperson.id === epersonToAdd.id) {
|
||||||
addMemberToGroup(parentGroup, eperson: EPerson): Observable<RestResponse> {
|
this.epersonNonMembers.splice(index, 1);
|
||||||
this.epersonMembers = [...this.epersonMembers, eperson];
|
}
|
||||||
|
});
|
||||||
return observableOf(new RestResponse(true, 200, 'Success'));
|
return observableOf(new RestResponse(true, 200, 'Success'));
|
||||||
},
|
},
|
||||||
clearGroupsRequests() {
|
clearGroupsRequests() {
|
||||||
@@ -105,14 +100,14 @@ describe('MembersListComponent', () => {
|
|||||||
return '/access-control/groups/' + group.id;
|
return '/access-control/groups/' + group.id;
|
||||||
},
|
},
|
||||||
deleteMemberFromGroup(parentGroup, epersonToDelete: EPerson): Observable<RestResponse> {
|
deleteMemberFromGroup(parentGroup, epersonToDelete: EPerson): Observable<RestResponse> {
|
||||||
this.epersonMembers = this.epersonMembers.find((eperson: EPerson) => {
|
// Remove eperson from list of members
|
||||||
if (eperson.id !== epersonToDelete.id) {
|
this.epersonMembers.forEach( (eperson: EPerson, index: number) => {
|
||||||
return eperson;
|
if (eperson.id === epersonToDelete.id) {
|
||||||
|
this.epersonMembers.splice(index, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (this.epersonMembers === undefined) {
|
// Add eperson to list of non-members
|
||||||
this.epersonMembers = [];
|
this.epersonNonMembers = [...this.epersonNonMembers, epersonToDelete];
|
||||||
}
|
|
||||||
return observableOf(new RestResponse(true, 200, 'Success'));
|
return observableOf(new RestResponse(true, 200, 'Success'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -160,13 +155,37 @@ describe('MembersListComponent', () => {
|
|||||||
expect(comp).toBeDefined();
|
expect(comp).toBeDefined();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should show list of eperson members of current active group', () => {
|
describe('current members list', () => {
|
||||||
const epersonIdsFound = fixture.debugElement.queryAll(By.css('#ePeopleMembersOfGroup tr td:first-child'));
|
it('should show list of eperson members of current active group', () => {
|
||||||
expect(epersonIdsFound.length).toEqual(1);
|
const epersonIdsFound = fixture.debugElement.queryAll(By.css('#ePeopleMembersOfGroup tr td:first-child'));
|
||||||
epersonMembers.map((eperson: EPerson) => {
|
expect(epersonIdsFound.length).toEqual(1);
|
||||||
expect(epersonIdsFound.find((foundEl) => {
|
epersonMembers.map((eperson: EPerson) => {
|
||||||
return (foundEl.nativeElement.textContent.trim() === eperson.uuid);
|
expect(epersonIdsFound.find((foundEl) => {
|
||||||
})).toBeTruthy();
|
return (foundEl.nativeElement.textContent.trim() === eperson.uuid);
|
||||||
|
})).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show a delete button next to each member', () => {
|
||||||
|
const epersonsFound = fixture.debugElement.queryAll(By.css('#ePeopleMembersOfGroup tbody tr'));
|
||||||
|
epersonsFound.map((foundEPersonRowElement: DebugElement) => {
|
||||||
|
const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus'));
|
||||||
|
const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt'));
|
||||||
|
expect(addButton).toBeNull();
|
||||||
|
expect(deleteButton).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('if first delete button is pressed', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const deleteButton: DebugElement = fixture.debugElement.query(By.css('#ePeopleMembersOfGroup tbody .fa-trash-alt'));
|
||||||
|
deleteButton.nativeElement.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
it('then no ePerson remains as a member of the active group.', () => {
|
||||||
|
const epersonsFound = fixture.debugElement.queryAll(By.css('#ePeopleMembersOfGroup tbody tr'));
|
||||||
|
expect(epersonsFound.length).toEqual(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -174,76 +193,40 @@ describe('MembersListComponent', () => {
|
|||||||
describe('when searching without query', () => {
|
describe('when searching without query', () => {
|
||||||
let epersonsFound: DebugElement[];
|
let epersonsFound: DebugElement[];
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(fakeAsync(() => {
|
||||||
spyOn(component, 'isMemberOfGroup').and.callFake((ePerson: EPerson) => {
|
|
||||||
return observableOf(activeGroup.epersons.includes(ePerson));
|
|
||||||
});
|
|
||||||
component.search({ scope: 'metadata', query: '' });
|
component.search({ scope: 'metadata', query: '' });
|
||||||
tick();
|
tick();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr'));
|
epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr'));
|
||||||
// Stop using the fake spy function (because otherwise the clicking on the buttons will not change anything
|
|
||||||
// because they don't change the value of activeGroup.epersons)
|
|
||||||
jasmine.getEnv().allowRespy(true);
|
|
||||||
spyOn(component, 'isMemberOfGroup').and.callThrough();
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should display all epersons', () => {
|
it('should display only non-members of the group', () => {
|
||||||
expect(epersonsFound.length).toEqual(2);
|
const epersonIdsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr td:first-child'));
|
||||||
|
expect(epersonIdsFound.length).toEqual(1);
|
||||||
|
epersonNonMembers.map((eperson: EPerson) => {
|
||||||
|
expect(epersonIdsFound.find((foundEl) => {
|
||||||
|
return (foundEl.nativeElement.textContent.trim() === eperson.uuid);
|
||||||
|
})).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('if eperson is already a eperson', () => {
|
it('should display an add button next to non-members, not a delete button', () => {
|
||||||
it('should have delete button, else it should have add button', () => {
|
epersonsFound.map((foundEPersonRowElement: DebugElement) => {
|
||||||
const memberIds: string[] = activeGroup.epersons.map((ePerson: EPerson) => ePerson.id);
|
const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus'));
|
||||||
epersonsFound.map((foundEPersonRowElement: DebugElement) => {
|
const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt'));
|
||||||
const epersonId: DebugElement = foundEPersonRowElement.query(By.css('td:first-child'));
|
expect(addButton).not.toBeNull();
|
||||||
const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus'));
|
expect(deleteButton).toBeNull();
|
||||||
const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt'));
|
|
||||||
if (memberIds.includes(epersonId.nativeElement.textContent)) {
|
|
||||||
expect(addButton).toBeNull();
|
|
||||||
expect(deleteButton).not.toBeNull();
|
|
||||||
} else {
|
|
||||||
expect(deleteButton).toBeNull();
|
|
||||||
expect(addButton).not.toBeNull();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('if first add button is pressed', () => {
|
describe('if first add button is pressed', () => {
|
||||||
beforeEach(fakeAsync(() => {
|
beforeEach(() => {
|
||||||
const addButton: DebugElement = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-plus'));
|
const addButton: DebugElement = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-plus'));
|
||||||
addButton.nativeElement.click();
|
addButton.nativeElement.click();
|
||||||
tick();
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
|
||||||
it('then all the ePersons are member of the active group', () => {
|
|
||||||
epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr'));
|
|
||||||
expect(epersonsFound.length).toEqual(2);
|
|
||||||
epersonsFound.map((foundEPersonRowElement: DebugElement) => {
|
|
||||||
const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus'));
|
|
||||||
const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt'));
|
|
||||||
expect(addButton).toBeNull();
|
|
||||||
expect(deleteButton).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
it('then all (two) ePersons are member of the active group. No non-members left', () => {
|
||||||
|
|
||||||
describe('if first delete button is pressed', () => {
|
|
||||||
beforeEach(fakeAsync(() => {
|
|
||||||
const deleteButton: DebugElement = fixture.debugElement.query(By.css('#epersonsSearch tbody .fa-trash-alt'));
|
|
||||||
deleteButton.nativeElement.click();
|
|
||||||
tick();
|
|
||||||
fixture.detectChanges();
|
|
||||||
}));
|
|
||||||
it('then no ePerson is member of the active group', () => {
|
|
||||||
epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr'));
|
epersonsFound = fixture.debugElement.queryAll(By.css('#epersonsSearch tbody tr'));
|
||||||
expect(epersonsFound.length).toEqual(2);
|
expect(epersonsFound.length).toEqual(0);
|
||||||
epersonsFound.map((foundEPersonRowElement: DebugElement) => {
|
|
||||||
const addButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-plus'));
|
|
||||||
const deleteButton: DebugElement = foundEPersonRowElement.query(By.css('td:last-child .fa-trash-alt'));
|
|
||||||
expect(deleteButton).toBeNull();
|
|
||||||
expect(addButton).not.toBeNull();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,38 +4,34 @@ import { Router } from '@angular/router';
|
|||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
|
||||||
Subscription,
|
Subscription,
|
||||||
BehaviorSubject,
|
BehaviorSubject
|
||||||
combineLatest as observableCombineLatest,
|
|
||||||
ObservedValueOf,
|
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { defaultIfEmpty, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { map, switchMap, take } from 'rxjs/operators';
|
||||||
import { buildPaginatedList, PaginatedList } from '../../../../core/data/paginated-list.model';
|
import { PaginatedList } from '../../../../core/data/paginated-list.model';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { EPersonDataService } from '../../../../core/eperson/eperson-data.service';
|
import { EPersonDataService } from '../../../../core/eperson/eperson-data.service';
|
||||||
import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../../../core/eperson/group-data.service';
|
||||||
import { EPerson } from '../../../../core/eperson/models/eperson.model';
|
import { EPerson } from '../../../../core/eperson/models/eperson.model';
|
||||||
import { Group } from '../../../../core/eperson/models/group.model';
|
import { Group } from '../../../../core/eperson/models/group.model';
|
||||||
import {
|
import {
|
||||||
getFirstSucceededRemoteData,
|
|
||||||
getFirstCompletedRemoteData,
|
getFirstCompletedRemoteData,
|
||||||
getAllCompletedRemoteData,
|
getAllCompletedRemoteData,
|
||||||
getRemoteDataPayload
|
getRemoteDataPayload
|
||||||
} from '../../../../core/shared/operators';
|
} from '../../../../core/shared/operators';
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
import { EpersonDtoModel } from '../../../../core/eperson/models/eperson-dto.model';
|
|
||||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { getEPersonEditRoute } from '../../../access-control-routing-paths';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys to keep track of specific subscriptions
|
* Keys to keep track of specific subscriptions
|
||||||
*/
|
*/
|
||||||
enum SubKey {
|
enum SubKey {
|
||||||
ActiveGroup,
|
ActiveGroup,
|
||||||
MembersDTO,
|
Members,
|
||||||
SearchResultsDTO,
|
SearchResults,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,11 +92,11 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
/**
|
/**
|
||||||
* EPeople being displayed in search result, initially all members, after search result of search
|
* EPeople being displayed in search result, initially all members, after search result of search
|
||||||
*/
|
*/
|
||||||
ePeopleSearchDtos: BehaviorSubject<PaginatedList<EpersonDtoModel>> = new BehaviorSubject<PaginatedList<EpersonDtoModel>>(undefined);
|
ePeopleSearch: BehaviorSubject<PaginatedList<EPerson>> = new BehaviorSubject<PaginatedList<EPerson>>(undefined);
|
||||||
/**
|
/**
|
||||||
* List of EPeople members of currently active group being edited
|
* List of EPeople members of currently active group being edited
|
||||||
*/
|
*/
|
||||||
ePeopleMembersOfGroupDtos: BehaviorSubject<PaginatedList<EpersonDtoModel>> = new BehaviorSubject<PaginatedList<EpersonDtoModel>>(undefined);
|
ePeopleMembersOfGroup: BehaviorSubject<PaginatedList<EPerson>> = new BehaviorSubject<PaginatedList<EPerson>>(undefined);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pagination config used to display the list of EPeople that are result of EPeople search
|
* Pagination config used to display the list of EPeople that are result of EPeople search
|
||||||
@@ -129,7 +125,6 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// Current search in edit group - epeople search form
|
// Current search in edit group - epeople search form
|
||||||
currentSearchQuery: string;
|
currentSearchQuery: string;
|
||||||
currentSearchScope: string;
|
|
||||||
|
|
||||||
// Whether or not user has done a EPeople search yet
|
// Whether or not user has done a EPeople search yet
|
||||||
searchDone: boolean;
|
searchDone: boolean;
|
||||||
@@ -137,6 +132,8 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
// current active group being edited
|
// current active group being edited
|
||||||
groupBeingEdited: Group;
|
groupBeingEdited: Group;
|
||||||
|
|
||||||
|
readonly getEPersonEditRoute = getEPersonEditRoute;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected groupDataService: GroupDataService,
|
protected groupDataService: GroupDataService,
|
||||||
public ePersonDataService: EPersonDataService,
|
public ePersonDataService: EPersonDataService,
|
||||||
@@ -148,18 +145,17 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
public dsoNameService: DSONameService,
|
public dsoNameService: DSONameService,
|
||||||
) {
|
) {
|
||||||
this.currentSearchQuery = '';
|
this.currentSearchQuery = '';
|
||||||
this.currentSearchScope = 'metadata';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.searchForm = this.formBuilder.group(({
|
this.searchForm = this.formBuilder.group(({
|
||||||
scope: 'metadata',
|
|
||||||
query: '',
|
query: '',
|
||||||
}));
|
}));
|
||||||
this.subs.set(SubKey.ActiveGroup, this.groupDataService.getActiveGroup().subscribe((activeGroup: Group) => {
|
this.subs.set(SubKey.ActiveGroup, this.groupDataService.getActiveGroup().subscribe((activeGroup: Group) => {
|
||||||
if (activeGroup != null) {
|
if (activeGroup != null) {
|
||||||
this.groupBeingEdited = activeGroup;
|
this.groupBeingEdited = activeGroup;
|
||||||
this.retrieveMembers(this.config.currentPage);
|
this.retrieveMembers(this.config.currentPage);
|
||||||
|
this.search({query: ''});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -171,8 +167,8 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
retrieveMembers(page: number): void {
|
retrieveMembers(page: number): void {
|
||||||
this.unsubFrom(SubKey.MembersDTO);
|
this.unsubFrom(SubKey.Members);
|
||||||
this.subs.set(SubKey.MembersDTO,
|
this.subs.set(SubKey.Members,
|
||||||
this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
|
this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
|
||||||
switchMap((currentPagination) => {
|
switchMap((currentPagination) => {
|
||||||
return this.ePersonDataService.findListByHref(this.groupBeingEdited._links.epersons.href, {
|
return this.ePersonDataService.findListByHref(this.groupBeingEdited._links.epersons.href, {
|
||||||
@@ -189,49 +185,12 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
switchMap((epersonListRD: RemoteData<PaginatedList<EPerson>>) => {
|
getRemoteDataPayload())
|
||||||
const dtos$ = observableCombineLatest([...epersonListRD.payload.page.map((member: EPerson) => {
|
.subscribe((paginatedListOfEPersons: PaginatedList<EPerson>) => {
|
||||||
const dto$: Observable<EpersonDtoModel> = observableCombineLatest(
|
this.ePeopleMembersOfGroup.next(paginatedListOfEPersons);
|
||||||
this.isMemberOfGroup(member), (isMember: ObservedValueOf<Observable<boolean>>) => {
|
|
||||||
const epersonDtoModel: EpersonDtoModel = new EpersonDtoModel();
|
|
||||||
epersonDtoModel.eperson = member;
|
|
||||||
epersonDtoModel.memberOfGroup = isMember;
|
|
||||||
return epersonDtoModel;
|
|
||||||
});
|
|
||||||
return dto$;
|
|
||||||
})]);
|
|
||||||
return dtos$.pipe(defaultIfEmpty([]), map((dtos: EpersonDtoModel[]) => {
|
|
||||||
return buildPaginatedList(epersonListRD.payload.pageInfo, dtos);
|
|
||||||
}));
|
|
||||||
}))
|
|
||||||
.subscribe((paginatedListOfDTOs: PaginatedList<EpersonDtoModel>) => {
|
|
||||||
this.ePeopleMembersOfGroupDtos.next(paginatedListOfDTOs);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the given ePerson is a member of the group currently being edited
|
|
||||||
* @param possibleMember EPerson that is a possible member (being tested) of the group currently being edited
|
|
||||||
*/
|
|
||||||
isMemberOfGroup(possibleMember: EPerson): Observable<boolean> {
|
|
||||||
return this.groupDataService.getActiveGroup().pipe(take(1),
|
|
||||||
mergeMap((group: Group) => {
|
|
||||||
if (group != null) {
|
|
||||||
return this.ePersonDataService.findListByHref(group._links.epersons.href, {
|
|
||||||
currentPage: 1,
|
|
||||||
elementsPerPage: 9999
|
|
||||||
})
|
|
||||||
.pipe(
|
|
||||||
getFirstSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
map((listEPeopleInGroup: PaginatedList<EPerson>) => listEPeopleInGroup.page.filter((ePersonInList: EPerson) => ePersonInList.id === possibleMember.id)),
|
|
||||||
map((epeople: EPerson[]) => epeople.length > 0));
|
|
||||||
} else {
|
|
||||||
return observableOf(false);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribe from a subscription if it's still subscribed, and remove it from the map of
|
* Unsubscribe from a subscription if it's still subscribed, and remove it from the map of
|
||||||
* active subscriptions
|
* active subscriptions
|
||||||
@@ -248,14 +207,18 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a given EPerson from the members list of the group currently being edited
|
* Deletes a given EPerson from the members list of the group currently being edited
|
||||||
* @param ePerson EPerson we want to delete as member from group that is currently being edited
|
* @param eperson EPerson we want to delete as member from group that is currently being edited
|
||||||
*/
|
*/
|
||||||
deleteMemberFromGroup(ePerson: EpersonDtoModel) {
|
deleteMemberFromGroup(eperson: EPerson) {
|
||||||
ePerson.memberOfGroup = false;
|
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
||||||
if (activeGroup != null) {
|
if (activeGroup != null) {
|
||||||
const response = this.groupDataService.deleteMemberFromGroup(activeGroup, ePerson.eperson);
|
const response = this.groupDataService.deleteMemberFromGroup(activeGroup, eperson);
|
||||||
this.showNotifications('deleteMember', response, this.dsoNameService.getName(ePerson.eperson), activeGroup);
|
this.showNotifications('deleteMember', response, this.dsoNameService.getName(eperson), activeGroup);
|
||||||
|
// Reload search results (if there is an active query).
|
||||||
|
// This will potentially add this deleted subgroup into the list of search results.
|
||||||
|
if (this.currentSearchQuery != null) {
|
||||||
|
this.search({query: this.currentSearchQuery});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
||||||
}
|
}
|
||||||
@@ -264,14 +227,18 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a given EPerson to the members list of the group currently being edited
|
* Adds a given EPerson to the members list of the group currently being edited
|
||||||
* @param ePerson EPerson we want to add as member to group that is currently being edited
|
* @param eperson EPerson we want to add as member to group that is currently being edited
|
||||||
*/
|
*/
|
||||||
addMemberToGroup(ePerson: EpersonDtoModel) {
|
addMemberToGroup(eperson: EPerson) {
|
||||||
ePerson.memberOfGroup = true;
|
|
||||||
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
this.groupDataService.getActiveGroup().pipe(take(1)).subscribe((activeGroup: Group) => {
|
||||||
if (activeGroup != null) {
|
if (activeGroup != null) {
|
||||||
const response = this.groupDataService.addMemberToGroup(activeGroup, ePerson.eperson);
|
const response = this.groupDataService.addMemberToGroup(activeGroup, eperson);
|
||||||
this.showNotifications('addMember', response, this.dsoNameService.getName(ePerson.eperson), activeGroup);
|
this.showNotifications('addMember', response, this.dsoNameService.getName(eperson), activeGroup);
|
||||||
|
// Reload search results (if there is an active query).
|
||||||
|
// This will potentially add this deleted subgroup into the list of search results.
|
||||||
|
if (this.currentSearchQuery != null) {
|
||||||
|
this.search({query: this.currentSearchQuery});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
this.notificationsService.error(this.translateService.get(this.messagePrefix + '.notification.failure.noActiveGroup'));
|
||||||
}
|
}
|
||||||
@@ -279,37 +246,25 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search in the EPeople by name, email or metadata
|
* Search all EPeople who are NOT a member of the current group by name, email or metadata
|
||||||
* @param data Contains scope and query param
|
* @param data Contains query param
|
||||||
*/
|
*/
|
||||||
search(data: any) {
|
search(data: any) {
|
||||||
this.unsubFrom(SubKey.SearchResultsDTO);
|
this.unsubFrom(SubKey.SearchResults);
|
||||||
this.subs.set(SubKey.SearchResultsDTO,
|
this.subs.set(SubKey.SearchResults,
|
||||||
this.paginationService.getCurrentPagination(this.configSearch.id, this.configSearch).pipe(
|
this.paginationService.getCurrentPagination(this.configSearch.id, this.configSearch).pipe(
|
||||||
switchMap((paginationOptions) => {
|
switchMap((paginationOptions) => {
|
||||||
|
|
||||||
const query: string = data.query;
|
const query: string = data.query;
|
||||||
const scope: string = data.scope;
|
|
||||||
if (query != null && this.currentSearchQuery !== query && this.groupBeingEdited) {
|
if (query != null && this.currentSearchQuery !== query && this.groupBeingEdited) {
|
||||||
this.router.navigate([], {
|
|
||||||
queryParamsHandling: 'merge'
|
|
||||||
});
|
|
||||||
this.currentSearchQuery = query;
|
this.currentSearchQuery = query;
|
||||||
this.paginationService.resetPage(this.configSearch.id);
|
this.paginationService.resetPage(this.configSearch.id);
|
||||||
}
|
}
|
||||||
if (scope != null && this.currentSearchScope !== scope && this.groupBeingEdited) {
|
|
||||||
this.router.navigate([], {
|
|
||||||
queryParamsHandling: 'merge'
|
|
||||||
});
|
|
||||||
this.currentSearchScope = scope;
|
|
||||||
this.paginationService.resetPage(this.configSearch.id);
|
|
||||||
}
|
|
||||||
this.searchDone = true;
|
this.searchDone = true;
|
||||||
|
|
||||||
return this.ePersonDataService.searchByScope(this.currentSearchScope, this.currentSearchQuery, {
|
return this.ePersonDataService.searchNonMembers(this.currentSearchQuery, this.groupBeingEdited.id, {
|
||||||
currentPage: paginationOptions.currentPage,
|
currentPage: paginationOptions.currentPage,
|
||||||
elementsPerPage: paginationOptions.pageSize
|
elementsPerPage: paginationOptions.pageSize
|
||||||
});
|
}, false, true);
|
||||||
}),
|
}),
|
||||||
getAllCompletedRemoteData(),
|
getAllCompletedRemoteData(),
|
||||||
map((rd: RemoteData<any>) => {
|
map((rd: RemoteData<any>) => {
|
||||||
@@ -319,23 +274,9 @@ export class MembersListComponent implements OnInit, OnDestroy {
|
|||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
switchMap((epersonListRD: RemoteData<PaginatedList<EPerson>>) => {
|
getRemoteDataPayload())
|
||||||
const dtos$ = observableCombineLatest([...epersonListRD.payload.page.map((member: EPerson) => {
|
.subscribe((paginatedListOfEPersons: PaginatedList<EPerson>) => {
|
||||||
const dto$: Observable<EpersonDtoModel> = observableCombineLatest(
|
this.ePeopleSearch.next(paginatedListOfEPersons);
|
||||||
this.isMemberOfGroup(member), (isMember: ObservedValueOf<Observable<boolean>>) => {
|
|
||||||
const epersonDtoModel: EpersonDtoModel = new EpersonDtoModel();
|
|
||||||
epersonDtoModel.eperson = member;
|
|
||||||
epersonDtoModel.memberOfGroup = isMember;
|
|
||||||
return epersonDtoModel;
|
|
||||||
});
|
|
||||||
return dto$;
|
|
||||||
})]);
|
|
||||||
return dtos$.pipe(defaultIfEmpty([]), map((dtos: EpersonDtoModel[]) => {
|
|
||||||
return buildPaginatedList(epersonListRD.payload.pageInfo, dtos);
|
|
||||||
}));
|
|
||||||
}))
|
|
||||||
.subscribe((paginatedListOfDTOs: PaginatedList<EpersonDtoModel>) => {
|
|
||||||
this.ePeopleSearchDtos.next(paginatedListOfDTOs);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,100 +1,10 @@
|
|||||||
<ng-container>
|
<ng-container>
|
||||||
<h3 class="border-bottom pb-2">{{messagePrefix + '.head' | translate}}</h3>
|
<h3 class="border-bottom pb-2">{{messagePrefix + '.head' | translate}}</h3>
|
||||||
|
|
||||||
<h4 id="search" class="border-bottom pb-2">
|
|
||||||
<span *dsContextHelp="{
|
|
||||||
content: 'admin.access-control.groups.form.tooltip.editGroup.addSubgroups',
|
|
||||||
id: 'edit-group-add-subgroups',
|
|
||||||
iconPlacement: 'right',
|
|
||||||
tooltipPlacement: ['top', 'right', 'bottom']
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
{{messagePrefix + '.search.head' | translate}}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</h4>
|
|
||||||
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
|
||||||
<div class="flex-grow-1 mr-3">
|
|
||||||
<div class="form-group input-group mr-3">
|
|
||||||
<input type="text" name="query" id="query" formControlName="query"
|
|
||||||
class="form-control" aria-label="Search input">
|
|
||||||
<span class="input-group-append">
|
|
||||||
<button type="submit" class="search-button btn btn-primary">
|
|
||||||
<i class="fas fa-search"></i> {{ messagePrefix + '.search.button' | translate }}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button (click)="clearFormAndResetResult();" class="btn btn-secondary float-right">
|
|
||||||
{{messagePrefix + '.button.see-all' | translate}}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
|
|
||||||
[paginationOptions]="configSearch"
|
|
||||||
[pageInfoState]="(searchResults$ | async)?.payload"
|
|
||||||
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
|
|
||||||
[hideGear]="true"
|
|
||||||
[hidePagerWhenSinglePage]="true">
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table id="groupsSearch" class="table table-striped table-hover table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
|
||||||
<th scope="col" class="align-middle">{{messagePrefix + '.table.collectionOrCommunity' | translate}}</th>
|
|
||||||
<th class="align-middle">{{messagePrefix + '.table.edit' | translate}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr *ngFor="let group of (searchResults$ | async)?.payload?.page">
|
|
||||||
<td class="align-middle">{{group.id}}</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
<a (click)="groupDataService.startEditingNewGroup(group)"
|
|
||||||
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">
|
|
||||||
{{ dsoNameService.getName(group) }}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="align-middle">{{ dsoNameService.getName((group.object | async)?.payload) }}</td>
|
|
||||||
<td class="align-middle">
|
|
||||||
<div class="btn-group edit-field">
|
|
||||||
<button *ngIf="(isSubgroupOfGroup(group) | async) && !(isActiveGroup(group) | async)"
|
|
||||||
(click)="deleteSubgroupFromGroup(group)"
|
|
||||||
class="btn btn-outline-danger btn-sm deleteButton"
|
|
||||||
title="{{messagePrefix + '.table.edit.buttons.remove' | translate: { name: dsoNameService.getName(group) } }}">
|
|
||||||
<i class="fas fa-trash-alt fa-fw"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<span *ngIf="(isActiveGroup(group) | async)">{{ messagePrefix + '.table.edit.currentGroup' | translate }}</span>
|
|
||||||
|
|
||||||
<button *ngIf="!(isSubgroupOfGroup(group) | async) && !(isActiveGroup(group) | async)"
|
|
||||||
(click)="addSubgroupToGroup(group)"
|
|
||||||
class="btn btn-outline-primary btn-sm addButton"
|
|
||||||
title="{{messagePrefix + '.table.edit.buttons.add' | translate: { name: dsoNameService.getName(group) } }}">
|
|
||||||
<i class="fas fa-plus fa-fw"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</ds-pagination>
|
|
||||||
|
|
||||||
<div *ngIf="(searchResults$ | async)?.payload?.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2"
|
|
||||||
role="alert">
|
|
||||||
{{messagePrefix + '.no-items' | translate}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4>{{messagePrefix + '.headSubgroups' | translate}}</h4>
|
<h4>{{messagePrefix + '.headSubgroups' | translate}}</h4>
|
||||||
|
|
||||||
<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
|
<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="(subGroups$ | async)?.payload"
|
|
||||||
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
|
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
@@ -139,4 +49,82 @@
|
|||||||
{{messagePrefix + '.no-subgroups-yet' | translate}}
|
{{messagePrefix + '.no-subgroups-yet' | translate}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h4 id="search" class="border-bottom pb-2">
|
||||||
|
<span *dsContextHelp="{
|
||||||
|
content: 'admin.access-control.groups.form.tooltip.editGroup.addSubgroups',
|
||||||
|
id: 'edit-group-add-subgroups',
|
||||||
|
iconPlacement: 'right',
|
||||||
|
tooltipPlacement: ['top', 'right', 'bottom']
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{messagePrefix + '.search.head' | translate}}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</h4>
|
||||||
|
<form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)" class="d-flex justify-content-between">
|
||||||
|
<div class="flex-grow-1 mr-3">
|
||||||
|
<div class="form-group input-group mr-3">
|
||||||
|
<input type="text" name="query" id="query" formControlName="query"
|
||||||
|
class="form-control" aria-label="Search input">
|
||||||
|
<span class="input-group-append">
|
||||||
|
<button type="submit" class="search-button btn btn-primary">
|
||||||
|
<i class="fas fa-search"></i> {{ messagePrefix + '.search.button' | translate }}
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button (click)="clearFormAndResetResult();" class="btn btn-secondary float-right">
|
||||||
|
{{messagePrefix + '.button.see-all' | translate}}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
|
||||||
|
[paginationOptions]="configSearch"
|
||||||
|
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
|
||||||
|
[hideGear]="true"
|
||||||
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="groupsSearch" class="table table-striped table-hover table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.id' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.name' | translate}}</th>
|
||||||
|
<th scope="col" class="align-middle">{{messagePrefix + '.table.collectionOrCommunity' | translate}}</th>
|
||||||
|
<th class="align-middle">{{messagePrefix + '.table.edit' | translate}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let group of (searchResults$ | async)?.payload?.page">
|
||||||
|
<td class="align-middle">{{group.id}}</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<a (click)="groupDataService.startEditingNewGroup(group)"
|
||||||
|
[routerLink]="[groupDataService.getGroupEditPageRouterLink(group)]">
|
||||||
|
{{ dsoNameService.getName(group) }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td class="align-middle">{{ dsoNameService.getName((group.object | async)?.payload) }}</td>
|
||||||
|
<td class="align-middle">
|
||||||
|
<div class="btn-group edit-field">
|
||||||
|
<button (click)="addSubgroupToGroup(group)"
|
||||||
|
class="btn btn-outline-primary btn-sm addButton"
|
||||||
|
title="{{messagePrefix + '.table.edit.buttons.add' | translate: { name: dsoNameService.getName(group) } }}">
|
||||||
|
<i class="fas fa-plus fa-fw"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</ds-pagination>
|
||||||
|
|
||||||
|
<div *ngIf="(searchResults$ | async)?.payload?.totalElements == 0 && searchDone" class="alert alert-info w-100 mb-2"
|
||||||
|
role="alert">
|
||||||
|
{{messagePrefix + '.no-items' | translate}}
|
||||||
|
</div>
|
||||||
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user