Skip to content

Commit cdcb8db

Browse files
committed
Merged dspace-cris-2024_02_x into task/dspace-cris-2024_02_x/DSC-2537
2 parents 57b1a3d + 7709400 commit cdcb8db

File tree

46 files changed

+466
-81
lines changed

Some content is hidden

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

46 files changed

+466
-81
lines changed

bitbucket-pipelines.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ definitions:
105105
- node-2024-02-x
106106
- cypress-2024-02-x
107107
script:
108+
- apt-get update && apt-get install -y curl
108109
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
109110
- echo "Running tests for commit $HASH_COMMIT"
110111
- export DSPACE_REST_HOST=${E2E_RUNNER_HOST}
@@ -120,6 +121,27 @@ definitions:
120121
- export CYPRESS_CACHE_FOLDER=~/.cache/Cypress
121122
- export CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu"
122123
- export NODE_OPTIONS="--max-old-space-size=4096"
124+
- |
125+
MAX_RETRIES=10
126+
RETRY_COUNT=0
127+
SUCCESS=false
128+
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
129+
echo "Pinging REST endpoint... (Attempt $((RETRY_COUNT+1)))"
130+
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://$DSPACE_REST_HOST$DSPACE_REST_NAMESPACE")
131+
if [ "$STATUS_CODE" -lt 400 ]; then
132+
echo "REST endpoint is up! Status code: $STATUS_CODE"
133+
SUCCESS=true
134+
break
135+
else
136+
echo "REST endpoint not ready (Status code: $STATUS_CODE). Retrying in 60 seconds..."
137+
RETRY_COUNT=$((RETRY_COUNT+1))
138+
sleep 60
139+
fi
140+
done
141+
if [ "$SUCCESS" = "false" ]; then
142+
echo "REST endpoint did not become available after $MAX_RETRIES attempts. Failing the build."
143+
exit 1
144+
fi
123145
- npx cypress install
124146
- yarn serve:ssr &
125147
- echo "Waiting for server to start..."
@@ -253,7 +275,7 @@ definitions:
253275
- export AWS_DEFAULT_REGION=$AWS_REGION
254276
- export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
255277
- export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='dev--${CLOUDFRONT_NAME}'].Id" --output text)
256-
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
278+
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
257279

258280
- step: &find-and-invalidate-cloudfront-staging
259281
name: Invalidate CloudFront Staging Cache
@@ -264,7 +286,7 @@ definitions:
264286
- export AWS_DEFAULT_REGION=$AWS_REGION
265287
- export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
266288
- export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='staging--${CLOUDFRONT_NAME}'].Id" --output text)
267-
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
289+
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
268290

269291
- step: &find-and-invalidate-cloudfront-test
270292
name: Invalidate CloudFront Test Cache
@@ -275,7 +297,7 @@ definitions:
275297
- export AWS_DEFAULT_REGION=$AWS_REGION
276298
- export CLOUDFRONT_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
277299
- export CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Comment=='test--${CLOUDFRONT_NAME}'].Id" --output text)
278-
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
300+
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" || echo "CloudFront distribution $CLOUDFRONT_DISTRIBUTION_ID not found — skipping invalidation."
279301

280302
pipelines:
281303
custom:

cypress/e2e/header.cy.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,33 @@ describe('Header', () => {
1414
it('should allow for changing language to German (for example)', () => {
1515
cy.visit('/');
1616

17-
// Click the language switcher (globe) in header
18-
cy.get('button[data-test="lang-switch"]').click();
19-
// Click on the "Deusch" language in dropdown
20-
cy.get('#language-menu-list div[role="option"]').contains('Deutsch').click();
17+
// This test should only run if the language switcher is visible.
18+
// We query for the body first, so the test doesn't fail if the button doesn't exist.
19+
cy.get('body').then($body => {
20+
if ($body.find('button[data-test="lang-switch"]').is(':visible')) {
2121

22-
// HTML "lang" attribute should switch to "de"
23-
cy.get('html').invoke('attr', 'lang').should('eq', 'de');
22+
// Click the language switcher (globe) in header
23+
cy.get('button[data-test="lang-switch"]').click();
24+
// Click on the "Deutsch" language in dropdown
25+
cy.get('#language-menu-list div[role="option"]').contains('Deutsch').click();
2426

25-
// Login menu should now be in German
26-
cy.get('[data-test="login-menu"]').contains('Anmelden');
27+
// HTML "lang" attribute should switch to "de"
28+
cy.get('html').invoke('attr', 'lang').should('eq', 'de');
2729

28-
// Change back to English from language switcher
29-
cy.get('button[data-test="lang-switch"]').click();
30-
cy.get('#language-menu-list div[role="option"]').contains('English').click();
30+
// Login menu should now be in German
31+
cy.get('[data-test="login-menu"]').contains('Anmelden');
3132

32-
// HTML "lang" attribute should switch to "en"
33-
cy.get('html').invoke('attr', 'lang').should('eq', 'en');
33+
// Change back to English from language switcher
34+
cy.get('button[data-test="lang-switch"]').click();
35+
cy.get('#language-menu-list div[role="option"]').contains('English').click();
3436

35-
// Login menu should now be in English
36-
cy.get('[data-test="login-menu"]').contains('Log In');
37+
// HTML "lang" attribute should switch to "en"
38+
cy.get('html').invoke('attr', 'lang').should('eq', 'en');
39+
40+
// Login menu should now be in English
41+
cy.get('[data-test="login-menu"]').contains('Log In');
42+
}
43+
});
3744
});
45+
3846
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"markdown-it": "^13.0.1",
139139
"mirador": "^3.4.3",
140140
"mirador-dl-plugin": "^0.13.0",
141+
"mirador-imagecropper": "^0.1.9",
141142
"mirador-share-plugin": "^0.16.0",
142143
"morgan": "^1.10.0",
143144
"ng2-file-upload": "5.0.0",

src/app/app-routes.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { ThemedPageErrorComponent } from './page-error/themed-page-error.compone
4444
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
4545
import { ThemedPageNotFoundComponent } from './pagenotfound/themed-pagenotfound.component';
4646
import { PROCESS_MODULE_PATH } from './process-page/process-page-routing.paths';
47+
import { RedirectService } from './redirect/redirect.service';
4748
import { viewTrackerResolver } from './statistics/angulartics/dspace/view-tracker.resolver';
4849
import { provideSubmissionState } from './submission/provide-submission-state';
4950
import { SUGGESTION_MODULE_PATH } from './suggestions-page/suggestions-page-routing-paths';
@@ -181,12 +182,12 @@ export const APP_ROUTES: Route[] = [
181182
canActivate: [authenticatedGuard, endUserAgreementCurrentUserGuard],
182183
},
183184
{
184-
path: 'standard-login',
185+
path: 'admin-only-login',
185186
loadChildren: () => import('./login-page/login-page-routes').then((m) => m.ROUTES),
186187
data: {
187188
isBackDoor: true,
188189
},
189-
canMatch: [() => !environment.auth.disableStandardLogin],
190+
canMatch: [() => environment.auth.isPasswordLoginEnabledForAdminsOnly],
190191
},
191192
{
192193
path: 'login',
@@ -333,7 +334,7 @@ export const APP_ROUTES: Route[] = [
333334
.then((m) => m.ROUTES),
334335
canActivate: [authenticatedGuard],
335336
},
336-
{ path: '**', pathMatch: 'full', component: ThemedPageNotFoundComponent, data: { title: PAGE_NOT_FOUND_PATH } },
337+
{ path: '**', pathMatch: 'full', component: ThemedPageNotFoundComponent, data: { title: PAGE_NOT_FOUND_PATH }, canActivate: [RedirectService] },
337338
],
338339
},
339340
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ds-item-page-cc-license-field
2+
[item]="item"
3+
[variant]="'full'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="true">
8+
</ds-item-page-cc-license-field>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-large/cc-license-large.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
ComponentFixture,
3+
TestBed,
4+
} from '@angular/core/testing';
5+
import { TranslateModule } from '@ngx-translate/core';
6+
7+
import { CcLicenseLargeComponent } from './cc-license-large.component';
8+
9+
describe('CcLicenseLargeComponent', () => {
10+
let component: CcLicenseLargeComponent;
11+
let fixture: ComponentFixture<CcLicenseLargeComponent>;
12+
13+
const mockItem = {
14+
firstMetadataValue: jasmine.createSpy('firstMetadataValue').and.returnValue(''),
15+
metadata: {},
16+
findMetadataSortedByPlace: jasmine.createSpy('findMetadataSortedByPlace').and.returnValue([]),
17+
};
18+
19+
const mockField = {
20+
metadataGroup: { elements: [] },
21+
styleValue: '',
22+
};
23+
24+
beforeEach(async () => {
25+
await TestBed.configureTestingModule({
26+
imports: [
27+
CcLicenseLargeComponent,
28+
TranslateModule.forRoot(),
29+
],
30+
providers: [
31+
{ provide: 'fieldProvider', useValue: mockField },
32+
{ provide: 'itemProvider', useValue: mockItem },
33+
{ provide: 'metadataValueProvider', useValue: {} },
34+
{ provide: 'renderingSubTypeProvider', useValue: '' },
35+
{ provide: 'tabNameProvider', useValue: '' },
36+
],
37+
}).compileComponents();
38+
39+
fixture = TestBed.createComponent(CcLicenseLargeComponent);
40+
component = fixture.componentInstance;
41+
42+
component.componentsToBeRenderedMap.set(0, [
43+
{ field: { metadata: 'dc.rights' } as any, value: {} as any },
44+
{ field: { metadata: 'dc.rights.uri' } as any, value: {} as any },
45+
] as any);
46+
47+
fixture.detectChanges();
48+
});
49+
50+
it('should create', () => {
51+
expect(component).toBeTruthy();
52+
});
53+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
Component,
3+
Inject,
4+
OnInit,
5+
} from '@angular/core';
6+
import { TranslateService } from '@ngx-translate/core';
7+
8+
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
9+
import { Item } from '../../../../../../../core/shared/item.model';
10+
import { ItemPageCcLicenseFieldComponent } from '../../../../../../../item-page/simple/field-components/specific-field/cc-license/item-page-cc-license-field.component';
11+
import { MetadataGroupComponent } from '../metadataGroup/metadata-group.component';
12+
13+
@Component({
14+
selector: 'ds-cc-license-large',
15+
standalone: true,
16+
imports: [ItemPageCcLicenseFieldComponent],
17+
templateUrl: './cc-license-large.component.html',
18+
styleUrl: './cc-license-large.component.scss',
19+
})
20+
export class CcLicenseLargeComponent extends MetadataGroupComponent implements OnInit {
21+
22+
dcRights: any;
23+
dcRightsUri: any;
24+
25+
constructor(
26+
@Inject('fieldProvider') public fieldProvider: LayoutField,
27+
@Inject('itemProvider') public itemProvider: Item,
28+
@Inject('renderingSubTypeProvider') public renderingSubTypeProvider: string,
29+
@Inject('tabNameProvider') public tabNameProvider: string,
30+
protected translateService: TranslateService,
31+
) {
32+
super(fieldProvider, itemProvider, renderingSubTypeProvider, tabNameProvider, translateService);
33+
}
34+
ngOnInit(): void {
35+
super.ngOnInit();
36+
const ccLicenseEntryMetadata = this.componentsToBeRenderedMap.get(0);
37+
[this.dcRights, this.dcRightsUri] = ccLicenseEntryMetadata.map((entryMeta) => entryMeta.field.metadata);
38+
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ds-item-page-cc-license-field
2+
[item]="item"
3+
[variant]="'small'"
4+
[ccLicenseUriField]="dcRightsUri"
5+
[ccLicenseNameField]="dcRights"
6+
[showLabel]="false"
7+
[showUrl]="false">
8+
</ds-item-page-cc-license-field>

src/app/cris-layout/cris-layout-matrix/cris-layout-box-container/boxes/metadata/rendering-types/cc-license-small/cc-license-small.component.scss

Whitespace-only changes.

0 commit comments

Comments
 (0)