Skip to content

Commit f56d875

Browse files
committed
Removed submit-config and move submit-button to dso-edit-menu.
1 parent f9e3737 commit f56d875

13 files changed

Lines changed: 40 additions & 50 deletions

File tree

config/config.example.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,6 @@ collection:
478478
showSidebar: true
479479
edit:
480480
undoTimeout: 10000 # 10 seconds
481-
# Whether to show a submit button on item pages instead of having an entry in the dso-edit menu.
482-
showSubmitButton: false
483481

484482
# Theme Config
485483
themes:

cypress/e2e/collection-page.cy.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,26 @@ describe('Collection Page -> Collection-edit menu', () => {
3333
// <dso-edit-menu> tag must be loaded
3434
cy.get('ds-dso-edit-menu').should('be.visible');
3535
});
36+
});
37+
38+
describe('Collection Page -> Submit-item button', () => {
39+
beforeEach(() => {
40+
cy.visit(COLLECTION_PAGE);
41+
// Open login menu in header & verify <ds-log-in> tag is visible
42+
cy.get('[data-test="login-menu"]').click();
43+
cy.get('.form-login').should('be.visible');
44+
45+
// Login, and the <ds-log-in> tag should no longer exist
46+
cy.env(['DSPACE_TEST_SUBMIT_USER', 'DSPACE_TEST_SUBMIT_USER_PASSWORD']).then(({ DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD }) => {
47+
cy.loginViaForm(DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD);
48+
});
49+
cy.get('ds-log-in').should('not.exist');
50+
});
3651

37-
it('Options menu should include submit item on collection pages.', () => {
52+
it('Submit item button should exist for submitters on collection pages.', () => {
3853
// Open the Options menu and verify the Submit item entry is available
39-
cy.get('ds-dso-edit-menu button[aria-label="Options"]').click();
40-
cy.get('[data-test="link-menu-item.collection.submit.item"]')
54+
//cy.get('ds-dso-edit-menu a[aria-label="Options"]').click();
55+
cy.get('ds-dso-edit-menu a[href="/submit"]')
4156
.should('be.visible')
4257
.and('contain', 'Submit item');
4358
});

src/app/app.menus.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export const MENUS = buildMenuStructure({
8484
EditUserAgreementMenuProvider,
8585
],
8686
[MenuID.DSO_EDIT]: [
87+
SubmitNewItemMenuProvider.onRoute(
88+
MenuRoute.COLLECTION_PAGE,
89+
),
8790
DsoOptionMenuProvider.withSubs([
8891
EditItemMenuProvider.onRoute(
8992
MenuRoute.ITEM_PAGE,
@@ -100,9 +103,6 @@ export const MENUS = buildMenuStructure({
100103
AddSubComColMenuProvider.onRoute(
101104
MenuRoute.COMMUNITY_PAGE,
102105
),
103-
SubmitNewItemMenuProvider.onRoute(
104-
MenuRoute.COLLECTION_PAGE,
105-
),
106106
WithdrawnReinstateItemMenuProvider.onRoute(
107107
MenuRoute.ITEM_PAGE,
108108
),

src/app/collection-page/collection-page.component.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
[hasInnerHtml]="true"
3535
[title]="'collection.page.news'">
3636
</ds-comcol-page-content>
37-
@if (showSubmitButton$ | async) {
38-
<!-- TODO: Adapt button label to collection entity type? --->
39-
<a routerLink="/submit" [queryParams]="{ 'collection': collection.uuid }" class="btn btn-secondary" [innerText]="'collection.page.submit-button' | translate"></a>
40-
}
4137
</header>
4238
<ds-dso-edit-menu></ds-dso-edit-menu>
4339
</div>

src/app/collection-page/collection-page.component.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ import { AsyncPipe } from '@angular/common';
22
import {
33
ChangeDetectionStrategy,
44
Component,
5-
Inject,
65
OnInit,
76
} from '@angular/core';
87
import {
98
ActivatedRoute,
109
Router,
11-
RouterLink,
1210
RouterOutlet,
1311
} from '@angular/router';
14-
import {
15-
APP_CONFIG,
16-
AppConfig,
17-
} from '@dspace/config/app-config.interface';
1812
import { AuthService } from '@dspace/core/auth/auth.service';
1913
import { DSONameService } from '@dspace/core/breadcrumbs/dso-name.service';
2014
import { SortOptions } from '@dspace/core/cache/models/sort-options.model';
@@ -69,7 +63,6 @@ import { VarDirective } from '../shared/utils/var.directive';
6963
ComcolPageLogoComponent,
7064
DsoEditMenuComponent,
7165
ErrorComponent,
72-
RouterLink,
7366
RouterOutlet,
7467
ThemedComcolPageBrowseByComponent,
7568
ThemedComcolPageContentComponent,
@@ -95,18 +88,12 @@ export class CollectionPageComponent implements OnInit {
9588
*/
9689
collectionPageRoute$: Observable<string>;
9790

98-
/**
99-
* Whether to show a submit button for users on the collection page.
100-
*/
101-
showSubmitButton$: Observable<boolean>;
102-
10391
constructor(
10492
protected route: ActivatedRoute,
10593
protected router: Router,
10694
protected authService: AuthService,
10795
protected authorizationDataService: AuthorizationDataService,
10896
public dsoNameService: DSONameService,
109-
@Inject(APP_CONFIG) protected appConfig: AppConfig,
11097
) {
11198
}
11299

@@ -127,10 +114,6 @@ export class CollectionPageComponent implements OnInit {
127114
getAllSucceededRemoteDataPayload(),
128115
map((collection) => getCollectionPageRoute(collection.id)),
129116
);
130-
131-
this.showSubmitButton$ = this.authorizationDataService.isAuthorized(FeatureID.CanSubmit).pipe(
132-
map(authorized => authorized && this.appConfig.collection.showSubmitButton),
133-
);
134117
}
135118

136119
isNotEmpty(object: any) {

src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<a class="btn btn-dark btn-sm"
66
[routerLink]="itemModel.link">
77
<i class="fas fa-{{section.icon}} fa-fw" aria-hidden="true"></i>
8-
<span class="sr-only">{{itemModel.text | translate}}</span>
8+
<span [class.sr-only]="isMobile$ | async" >{{itemModel.text | translate}}</span>
99
</a>
1010
}
1111
@if (section.model.disabled) {
1212
<button class="btn btn-dark btn-sm" [dsBtnDisabled]="true">
1313
<i class="fas fa-{{section.icon}} fa-fw" aria-hidden="true"></i>
14-
<span class="sr-only">{{itemModel.text | translate}}</span>
14+
<span [class.sr-only]="isMobile$ | async">{{itemModel.text | translate}}</span>
1515
</button>
1616
}
1717
</div>
@@ -23,7 +23,7 @@
2323
<button class="btn btn-dark btn-sm" [dsBtnDisabled]="section.model.disabled"
2424
(click)="activate($event)">
2525
<i class="fas fa-{{section.icon}} fa-fw" aria-hidden="true"></i>
26-
<span class="sr-only">{{itemModel.text | translate}}</span>
26+
<span [class.sr-only]="isMobile$ | async">{{itemModel.text | translate}}</span>
2727
</button>
2828
</div>
2929
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.btn-dark {
22
background-color: var(--ds-admin-sidebar-bg);
33
}
4+
.dso-button-menu {
5+
width: max-content;
6+
}

src/app/shared/dso-page/dso-edit-menu/dso-edit-menu-section/dso-edit-menu-section.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11

2+
import { AsyncPipe } from '@angular/common';
23
import {
34
Component,
45
Inject,
56
Injector,
67
OnInit,
78
} from '@angular/core';
89
import { RouterLink } from '@angular/router';
10+
import { WidthCategory } from '@dspace/core/shared/host-window-type';
911
import { isNotEmpty } from '@dspace/shared/utils/empty.util';
1012
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
1113
import { TranslateModule } from '@ngx-translate/core';
14+
import { Observable } from 'rxjs';
1215
import { AbstractMenuSectionComponent } from 'src/app/shared/menu/menu-section/abstract-menu-section.component';
1316

1417
import { BtnDisabledDirective } from '../../../btn-disabled.directive';
18+
import { HostWindowService } from '../../../host-window.service';
1519
import { MenuService } from '../../../menu/menu.service';
1620
import { MenuID } from '../../../menu/menu-id.model';
1721
import { MenuSection } from '../../../menu/menu-section.model';
@@ -24,6 +28,7 @@ import { MenuSection } from '../../../menu/menu-section.model';
2428
templateUrl: './dso-edit-menu-section.component.html',
2529
styleUrls: ['./dso-edit-menu-section.component.scss'],
2630
imports: [
31+
AsyncPipe,
2732
BtnDisabledDirective,
2833
NgbTooltip,
2934
RouterLink,
@@ -36,14 +41,19 @@ export class DsoEditMenuSectionComponent extends AbstractMenuSectionComponent im
3641
itemModel;
3742
hasLink: boolean;
3843
canActivate: boolean;
44+
public isMobile$: Observable<boolean>;
45+
46+
maxMobileWidth = WidthCategory.SM;
3947

4048
constructor(
4149
@Inject('sectionDataProvider') protected section: MenuSection,
4250
protected menuService: MenuService,
4351
protected injector: Injector,
52+
protected windowService: HostWindowService,
4453
) {
4554
super(menuService, injector);
4655
this.itemModel = section.model;
56+
this.isMobile$ = this.windowService.isUpTo(this.maxMobileWidth);
4757
}
4858

4959
ngOnInit(): void {

src/app/shared/menu/providers/submit-new-item.menu.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
*
66
* http://www.dspace.org/license/
77
*/
8-
import {
9-
Inject,
10-
Injectable,
11-
} from '@angular/core';
12-
import {
13-
APP_CONFIG,
14-
AppConfig,
15-
} from '@dspace/config/app-config.interface';
8+
import { Injectable } from '@angular/core';
169
import { AuthorizationDataService } from '@dspace/core/data/feature-authorization/authorization-data.service';
1710
import { FeatureID } from '@dspace/core/data/feature-authorization/feature-id';
1811
import { DSpaceObject } from '@dspace/core/shared/dspace-object.model';
@@ -34,7 +27,6 @@ import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
3427
export class SubmitNewItemMenuProvider extends DSpaceObjectPageMenuProvider {
3528
constructor(
3629
protected authorizationDataService: AuthorizationDataService,
37-
@Inject(APP_CONFIG) protected appConfig: AppConfig,
3830
) {
3931
super();
4032
}
@@ -46,7 +38,7 @@ export class SubmitNewItemMenuProvider extends DSpaceObjectPageMenuProvider {
4638
map(([canSubmitItem]) => {
4739
return [
4840
{
49-
visible: canSubmitItem && !this.appConfig.collection.showSubmitButton,
41+
visible: canSubmitItem,
5042
model: {
5143
type: MenuItemType.LINK,
5244
text: 'collection.submit.item',

src/config/collection-page-config.interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface CollectionPageConfig extends Config {
99
edit: {
1010
undoTimeout: number;
1111
};
12-
showSubmitButton: boolean;
1312
}
1413

1514
/**

0 commit comments

Comments
 (0)