Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Invite user modal fixes (#9107)

Benjamin Bädorf79832c27ea06
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index c3bdf2148d4..910c3bd9f1f 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -1094,7 +1094,7 @@ en:
<a
href="%{href}"
target="_blank">
- learn more about roles and permissions.
+ Learn more about roles and permissions.
</a>'
required: 'Please select a role'
next_button: 'Next'
@@ -1102,10 +1102,10 @@ en:
message:
label: 'Invitation message'
description: 'We will send an email to %{principal}, to which you can add a personal message here. An explanation for the invitation could be useful, or perhaps a bit of information regarding the project to help them get started.'
- next_button: 'Review Invitation'
+ next_button: 'Review invitation'
summary:
- next_button: 'Send Invitation'
+ next_button: 'Send invitation'
success:
title: '%{principal} was invited!'
diff --git a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
index 90bea786a3f..df9f10a90be 100644
--- a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
+++ b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.html
@@ -27,6 +27,6 @@
</ng-template>
<ng-template ng-footer-tmp *ngIf="showAddNewButton">
- <op-invite-user-button (invited)="onUserInvited($event)"></op-invite-user-button>
+ <op-invite-user-button></op-invite-user-button>
</ng-template>
</ng-select>
\ No newline at end of file
diff --git a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
index 4b79697026f..30d163f584f 100644
--- a/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
+++ b/frontend/src/app/modules/autocompleter/create-autocompleter/create-autocompleter.component.ts
@@ -33,14 +33,19 @@ import {
EventEmitter,
Input,
Output,
- ViewChild
+ ViewChild,
+ Injector,
} from '@angular/core';
import { NgSelectComponent } from "@ng-select/ng-select";
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
+import { InviteUserModalComponent } from "core-app/modules/invite-user-modal/invite-user.component";
+import { OpInviteUserModalService } from "core-app/modules/invite-user-modal/invite-user-modal.service";
import { CurrentProjectService } from "core-components/projects/current-project.service";
import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
import { HalResource } from "core-app/modules/hal/resources/hal-resource";
import { AddTagFn } from "@ng-select/ng-select/lib/ng-select.component";
+import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
+import { InjectField } from "core-app/helpers/angular/inject-field.decorator";
import { Subject } from 'rxjs';
export interface CreateAutocompleterValueOption {
@@ -53,7 +58,7 @@ export interface CreateAutocompleterValueOption {
selector: 'create-autocompleter',
styleUrls: ['./create-autocompleter.component.sass']
})
-export class CreateAutocompleterComponent implements AfterViewInit {
+export class CreateAutocompleterComponent extends UntilDestroyedMixin implements AfterViewInit {
@Input() public availableValues:CreateAutocompleterValueOption[];
@Input() public appendTo:string;
@Input() public model:any;
@@ -76,22 +81,31 @@ export class CreateAutocompleterComponent implements AfterViewInit {
@ViewChild(NgSelectComponent) public ngSelectComponent:NgSelectComponent;
- public text:{ [key:string]:string } = {
- add_new_action: this.I18n.t('js.label_create'),
- };
+ @InjectField() readonly opInviteUserModalService:OpInviteUserModalService;
+ @InjectField() readonly I18n:I18nService;
+ @InjectField() readonly cdRef:ChangeDetectorRef;
+ @InjectField() readonly currentProject:CurrentProjectService;
+ @InjectField() readonly pathHelper:PathHelperService;
+ public text:{ [key:string]:string } = {};
public createAllowed:boolean|AddTagFn = false;
-
private _openDirectly = false;
- constructor(readonly I18n:I18nService,
- readonly cdRef:ChangeDetectorRef,
- readonly currentProject:CurrentProjectService,
- readonly pathHelper:PathHelperService,
- ) { }
+ constructor(readonly injector:Injector) {
+ super();
+
+ this.text.add_new_action = this.I18n.t('js.label_create');
+ }
ngAfterViewInit() {
this.onAfterViewInit.emit(this);
+ if (this.opInviteUserModalService) {
+ this.opInviteUserModalService.close
+ .pipe(this.untilDestroyed())
+ .subscribe((user: HalResource) => {
+ this.onChange.emit(user);
+ });
+ }
}
public openSelect() {
@@ -150,8 +164,4 @@ export class CreateAutocompleterComponent implements AfterViewInit {
public focusInputField() {
this.ngSelectComponent && this.ngSelectComponent.focus();
}
-
- public onUserInvited(user:HalResource) {
- this.onChange.emit(user);
- }
}
diff --git a/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.ts b/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.ts
index 14bf5432312..ba4bcf72aac 100644
--- a/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.ts
+++ b/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.ts
@@ -33,6 +33,7 @@ import {
Output,
EventEmitter,
ChangeDetectorRef,
+ Injector,
} from '@angular/core';
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
import { CurrentProjectService } from "core-components/projects/current-project.service";
@@ -50,11 +51,10 @@ export type TimeEntryWorkPackageAutocompleterMode = 'all'|'recent';
export class TimeEntryWorkPackageAutocompleterComponent extends WorkPackageAutocompleterComponent implements AfterViewInit {
@Output() modeSwitch = new EventEmitter<TimeEntryWorkPackageAutocompleterMode>();
- constructor(readonly I18n:I18nService,
- readonly cdRef:ChangeDetectorRef,
- readonly currentProject:CurrentProjectService,
- readonly pathHelper:PathHelperService) {
- super(I18n, cdRef, currentProject, pathHelper);
+ constructor(
+ readonly injector:Injector,
+ ) {
+ super(injector);
this.text['all'] = this.I18n.t('js.label_all');
this.text['recent'] = this.I18n.t('js.label_recent');
diff --git a/frontend/src/app/modules/autocompleter/version-autocompleter/version-autocompleter.component.ts b/frontend/src/app/modules/autocompleter/version-autocompleter/version-autocompleter.component.ts
index de5f82bf8b2..aff953c4aff 100644
--- a/frontend/src/app/modules/autocompleter/version-autocompleter/version-autocompleter.component.ts
+++ b/frontend/src/app/modules/autocompleter/version-autocompleter/version-autocompleter.component.ts
@@ -26,7 +26,7 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
-import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
+import { AfterViewInit, ChangeDetectorRef, Component, EventEmitter, Input, Output, Injector } from '@angular/core';
import { CurrentProjectService } from "core-components/projects/current-project.service";
import { PathHelperService } from "core-app/modules/common/path-helper/path-helper.service";
import { VersionResource } from "core-app/modules/hal/resources/version-resource";
@@ -42,13 +42,16 @@ import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
export class VersionAutocompleterComponent extends CreateAutocompleterComponent implements AfterViewInit {
@Output() public onCreate = new EventEmitter<VersionResource>();
- constructor(readonly I18n:I18nService,
- readonly currentProject:CurrentProjectService,
- readonly cdRef:ChangeDetectorRef,
- readonly pathHelper:PathHelperService,
- readonly apiV3Service:APIV3Service,
- readonly halNotification:HalResourceNotificationService) {
- super(I18n, cdRef, currentProject, pathHelper);
+ constructor(
+ readonly injector: Injector,
+ readonly I18n:I18nService,
+ readonly currentProject:CurrentProjectService,
+ readonly cdRef:ChangeDetectorRef,
+ readonly pathHelper:PathHelperService,
+ readonly apiV3Service:APIV3Service,
+ readonly halNotification:HalResourceNotificationService,
+ ) {
+ super(injector);
}
ngAfterViewInit() {
diff --git a/frontend/src/app/modules/common/form-field/form-field.children.sass b/frontend/src/app/modules/common/form-field/form-field.children.sass
index 8dc96aa01d8..43aeec0d95a 100644
--- a/frontend/src/app/modules/common/form-field/form-field.children.sass
+++ b/frontend/src/app/modules/common/form-field/form-field.children.sass
@@ -1,4 +1,5 @@
.op-form-field_invalid
.ng-select-container,
- .op-input
+ .op-input,
+ .op-option-list--item
border-color: var(--content-form-error-color)
diff --git a/frontend/src/app/modules/common/form-field/form-field.component.html b/frontend/src/app/modules/common/form-field/form-field.component.html
index cef9a992c96..2f6e7948d4b 100644
--- a/frontend/src/app/modules/common/form-field/form-field.component.html
+++ b/frontend/src/app/modules/common/form-field/form-field.component.html
@@ -1,5 +1,8 @@
<label class="op-form-field--label-wrap">
- <div class="op-form-field--label">
+ <div
+ class="op-form-field--label"
+ *ngIf="label"
+ >
{{ label }}
<span *ngIf="required" class="op-form-field--label-indicator">*</span>
</div>
diff --git a/frontend/src/app/modules/common/form-field/form-field.sass b/frontend/src/app/modules/common/form-field/form-field.sass
index 23fa79310f6..19930b0c595 100644
--- a/frontend/src/app/modules/common/form-field/form-field.sass
+++ b/frontend/src/app/modules/common/form-field/form-field.sass
@@ -37,3 +37,10 @@
&--error
color: var(--content-form-error-color)
margin-bottom: 1rem
+ font-size: 0.8rem
+
+ &--description,
+ &--help-text,
+ &--errors
+ &:empty
+ display: none
diff --git a/frontend/src/app/modules/common/link/link.sass b/frontend/src/app/modules/common/link/link.sass
index 71b624799aa..811eedcb148 100644
--- a/frontend/src/app/modules/common/link/link.sass
+++ b/frontend/src/app/modules/common/link/link.sass
@@ -1,6 +1,9 @@
.op-link
+ display: inline
color: var(--content-link-color)
text-decoration: none
+ padding: 0
+ margin: 0
background: 0
border: 0
font: inherit
diff --git a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.html b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.html
index 1489d26f300..1c6607f4001 100644
--- a/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.html
+++ b/frontend/src/app/modules/fields/edit/field-types/multi-select-edit-field.component.html
@@ -19,8 +19,7 @@
[dropdownPosition]="'top'"
[hideSelected]="true">
<ng-template ng-footer-tmp>
- <op-invite-user-button (invited)="selectedOption = $event">
- </op-invite-user-button>
+ <op-invite-user-button (invited)="selectedOption = $event"></op-invite-user-button>
</ng-template>
</ng-select>
diff --git a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts b/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
index 6530047f7f8..9e14245a1f5 100644
--- a/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
+++ b/frontend/src/app/modules/fields/edit/field-types/select-edit-field.component.ts
@@ -73,7 +73,15 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
const href = this.value ? this.value.$href : null;
return _.find(this.valueOptions, o => o.$href === href)!;
}
- public set selectedOption(val:ValueOption) {
+ public set selectedOption(val:ValueOption|HalResource) {
+ // The InviteUserModal gives us a resource that is not in availableOptions yet,
+ // but we also don't want to wait for a refresh of the options every time we want to
+ // select an option, so if we get a HalResource we trust it exists
+ if (val instanceof HalResource) {
+ this.value = val;
+ return;
+ }
+
const option = _.find(this.availableOptions, o => o.$href === val.$href);
// Special case 'null' value, which angular
@@ -232,9 +240,9 @@ export class SelectEditFieldComponent extends EditFieldComponent implements OnIn
// Nothing to do
}
- public onChange(value:HalResource|undefined) {
- if (value !== undefined) {
- this.selectedOption = { name: value.name, $href: value.$href };
+ public onChange(value:HalResource|undefined|null) {
+ if (value) {
+ this.selectedOption = value;
this.handler.handleUserSubmit();
return;
}
diff --git a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.html b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.html
index cec477aae95..f4dfd824b79 100644
--- a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.html
+++ b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.html
@@ -1,12 +1,11 @@
<button
- class="button -tiny -alt-highlight"
+ class="invite-user-button"
type="button"
(click)="onAddNewClick($event)"
- *ngIf="showButton">
- <op-icon icon-classes="button--icon icon-add" class="op-icon--wrapper">
- </op-icon>
-
- <span class="button--text">
+ *ngIf="showButton"
+>
+ <span class="icon-context">
+ <op-icon icon-classes="icon-add icon-context"></op-icon>
{{text.button}}
</span>
</button>
diff --git a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.sass b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.sass
index ae1c4fb6dbc..fde8a94ab13 100644
--- a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.sass
+++ b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.sass
@@ -1,6 +1,22 @@
\:host
- .button.-tiny
- margin: 5px 7px
-
+ display: block
+ margin: 0
+ padding: 0
+.invite-user-button
+ cursor: pointer
+ display: block
+ background: transparent
+ border: 0
+ padding: 8px 10px
+ font-size: 14px
+ line-height: 22px
+ background-color: #fff
+ color: rgba(0,0,0,0.87)
+ font-weight: bold
+ width: 100%
+ text-align: left
+ &:hover
+ background-color: #f5faff
+ color: #333
diff --git a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
index 7fc381c14ad..f70af385d10 100644
--- a/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/button/invite-user-button.component.ts
@@ -1,15 +1,12 @@
-import { Component, EventEmitter, Inject, OnInit, Optional, Output } from '@angular/core';
+import { Component, EventEmitter, Inject, Input, OnInit, Optional } from '@angular/core';
+import { NgSelectComponent } from "@ng-select/ng-select";
import { OpEditingPortalSchemaToken } from "core-app/modules/fields/edit/edit-field.component";
import { IFieldSchema } from "core-app/modules/fields/field.base";
-import { CurrentProjectService } from "core-components/projects/current-project.service";
-import { NgSelectComponent } from "@ng-select/ng-select";
import { SelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/select-edit-field.component";
import { MultiSelectEditFieldComponent } from "core-app/modules/fields/edit/field-types/multi-select-edit-field.component";
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
import { PermissionsService } from "core-app/core/services/permissions/permissions.service";
-import { HalResource } from "core-app/modules/hal/resources/hal-resource";
-import { OpModalService } from "core-app/modules/modal/modal.service";
-import { InviteUserModalComponent } from "core-app/modules/invite-user-modal/invite-user.component";
+import { OpInviteUserModalService } from "core-app/modules/invite-user-modal/invite-user-modal.service";
@Component({
selector: 'op-invite-user-button',
@@ -17,7 +14,11 @@ import { InviteUserModalComponent } from "core-app/modules/invite-user-modal/inv
styleUrls: ['./invite-user-button.component.sass']
})
export class InviteUserButtonComponent implements OnInit {
- @Output() invited = new EventEmitter<HalResource | HalResource[]>();
+ /* This component does not provide an output, because both primary usecases were in places where the button was
+ * destroyed before the modal closed, causing the data from the modal to never arrive at the parent.
+ * If you want to do something with the output from the modal that is opened, use the OpInviteUserModalService
+ * and subscribe to the `close` event there.
+ */
get showButton() {
const showButton = this.schema?.type === 'User' &&
@@ -37,10 +38,9 @@ export class InviteUserButtonComponent implements OnInit {
constructor(
readonly I18n:I18nService,
- readonly opModalService:OpModalService,
- readonly currentProjectService:CurrentProjectService,
- readonly ngSelectComponent:NgSelectComponent,
+ readonly opInviteUserModalService:OpInviteUserModalService,
readonly permissionsService:PermissionsService,
+ readonly ngSelectComponent:NgSelectComponent,
@Optional() readonly selectEditFieldComponent:SelectEditFieldComponent,
@Optional() readonly multiSelectEditFieldComponent:MultiSelectEditFieldComponent,
@Inject(OpEditingPortalSchemaToken) public schema:IFieldSchema,
@@ -53,37 +53,8 @@ export class InviteUserButtonComponent implements OnInit {
}
onAddNewClick($event:Event) {
- this.ngSelectComponent.close();
$event.stopPropagation();
- this.openInviteUserModal();
- }
-
- openInviteUserModal() {
- const inviteModal = this.opModalService.show(InviteUserModalComponent, 'global', {
- projectId: this.currentProjectService.id,
- });
-
- inviteModal
- .closingEvent
- .subscribe((modal:any) => {
- let dataToEmit = null;
-
- if (modal.data) {
- // TODO: Remove this data formatting
- // The principal should be a UserResource instance to match
- // the interface used by the SelectEditFieldComponent's
- // availableOptions.
- dataToEmit = {
- ...modal.data,
- $href: modal.data.$source?._links?.self?.href,
- };
-
- if (this.parentIsMultiSelectEditFieldComponent) {
- dataToEmit = [dataToEmit];
- }
- }
-
- this.invited.emit(dataToEmit);
- });
+ this.opInviteUserModalService.open();
+ this.ngSelectComponent.close();
}
}
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user-modal-augment.service.ts b/frontend/src/app/modules/invite-user-modal/invite-user-modal-augment.service.ts
index 349a186d322..e9bad2a0187 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user-modal-augment.service.ts
+++ b/frontend/src/app/modules/invite-user-modal/invite-user-modal-augment.service.ts
@@ -31,8 +31,8 @@ import {Inject, Injectable, Injector} from "@angular/core";
import {DOCUMENT} from "@angular/common";
import {DynamicContentModal} from "core-components/modals/modal-wrapper/dynamic-content.modal";
import {OpModalService} from "core-app/modules/modal/modal.service";
-import {InviteUserModalComponent} from "core-app/modules/invite-user-modal/invite-user.component";
import {CurrentProjectService} from "core-components/projects/current-project.service";
+import {InviteUserModalComponent} from "./invite-user.component";
import ClickEvent = JQuery.ClickEvent;
const attributeSelector = '[invite-user-modal-augment]';
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts b/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
index d07fc87aa48..cd7a96177a0 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
+++ b/frontend/src/app/modules/invite-user-modal/invite-user-modal.module.ts
@@ -1,5 +1,6 @@
import { APP_INITIALIZER, Injector, NgModule } from "@angular/core";
import { ReactiveFormsModule } from "@angular/forms";
+import { TextFieldModule } from '@angular/cdk/text-field';
import { OpenprojectModalModule } from "core-app/modules/modal/modal.module";
import { InviteUserModalComponent } from "./invite-user.component";
import { ProjectSelectionComponent } from "./project-selection/project-selection.component";
@@ -15,6 +16,7 @@ import { NgSelectModule } from "@ng-select/ng-select";
import { OpenprojectCommonModule } from "core-app/modules/common/openproject-common.module";
import { InviteUserButtonComponent } from "core-app/modules/invite-user-modal/button/invite-user-button.component";
import { OpInviteUserModalAugmentService } from "core-app/modules/invite-user-modal/invite-user-modal-augment.service";
+import { OpInviteUserModalService } from "core-app/modules/invite-user-modal/invite-user-modal.service";
export function initializeServices(injector:Injector) {
return function () {
@@ -29,6 +31,7 @@ export function initializeServices(injector:Injector) {
OpenprojectModalModule,
NgSelectModule,
ReactiveFormsModule,
+ TextFieldModule,
],
exports: [
InviteUserButtonComponent,
@@ -47,6 +50,7 @@ export function initializeServices(injector:Injector) {
SummaryComponent,
],
providers: [
+ OpInviteUserModalService,
{ provide: APP_INITIALIZER, useFactory: initializeServices, deps: [Injector], multi: true },
],
})
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user-modal.service.ts b/frontend/src/app/modules/invite-user-modal/invite-user-modal.service.ts
new file mode 100644
index 00000000000..f4810c1de45
--- /dev/null
+++ b/frontend/src/app/modules/invite-user-modal/invite-user-modal.service.ts
@@ -0,0 +1,62 @@
+//-- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See docs/COPYRIGHT.rdoc for more details.
+//++
+
+
+import { Inject, Injectable, Injector, EventEmitter } from "@angular/core";
+import { HalResource } from "core-app/modules/hal/resources/hal-resource";
+import { OpModalService } from "core-app/modules/modal/modal.service";
+import { CurrentProjectService } from "core-components/projects/current-project.service";
+import { InviteUserModalComponent } from "./invite-user.component";
+
+/**
+ * This service triggers user-invite modals to clicks on elements
+ * with the attribute [invite-user-modal-augment] set.
+ */
+@Injectable()
+export class OpInviteUserModalService {
+ public close = new EventEmitter<HalResource | HalResource[]>();
+
+ constructor(
+ protected opModalService:OpModalService,
+ protected currentProjectService:CurrentProjectService,
+ ) { }
+
+ public open(projectId: string|null = this.currentProjectService.id) {
+ const modal = this.opModalService.show(
+ InviteUserModalComponent,
+ 'global',
+ { projectId }
+ );
+
+ modal
+ .closingEvent
+ .subscribe((modal: InviteUserModalComponent) => {
+ this.close.emit(modal.data);
+ });
+ }
+}
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user.component.html b/frontend/src/app/modules/invite-user-modal/invite-user.component.html
index b8baa0823ab..c9b5f17e9b3 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user.component.html
+++ b/frontend/src/app/modules/invite-user-modal/invite-user.component.html
@@ -1,6 +1,10 @@
+<div
+ class="op-modal"
+ *ngIf="loading"
+></div>
<op-ium-project-selection
- *ngIf="step === Steps.ProjectSelection"
- class="op-modal op-modal"
+ *ngIf="!loading && step === Steps.ProjectSelection"
+ class="op-modal"
[project]="project"
[type]="type"
(save)="onProjectSelectionSave($event)"
@@ -8,8 +12,8 @@
></op-ium-project-selection>
<op-ium-principal
- *ngIf="step === Steps.Principal"
- class="op-modal op-modal"
+ *ngIf="!loading && step === Steps.Principal"
+ class="op-modal"
[project]="project"
[principal]="principal"
[type]="type"
@@ -19,8 +23,8 @@
></op-ium-principal>
<op-ium-role
- *ngIf="step === Steps.Role"
- class="op-modal op-modal"
+ *ngIf="!loading && step === Steps.Role"
+ class="op-modal"
[role]="role"
[principal]="principal"
[project]="project"
@@ -31,8 +35,8 @@
></op-ium-role>
<op-ium-message
- *ngIf="step === Steps.Message"
- class="op-modal op-modal"
+ *ngIf="!loading && step === Steps.Message"
+ class="op-modal"
[message]="message"
[principal]="principal"
[project]="project"
@@ -42,8 +46,8 @@
></op-ium-message>
<op-ium-summary
- *ngIf="step === Steps.Summary"
- class="op-modal op-modal"
+ *ngIf="!loading && step === Steps.Summary"
+ class="op-modal"
[project]="project"
[principal]="principal"
[type]="type"
@@ -58,7 +62,8 @@
[principal]="principal"
[project]="project"
[type]="type"
- *ngIf="step === Steps.Success"
- class="op-modal op-modal"
+ [createdNewPrincipal]="createdNewPrincipal"
+ *ngIf="!loading && step === Steps.Success"
+ class="op-modal"
(close)="closeWithPrincipal()"
></op-ium-success>
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user.component.sass b/frontend/src/app/modules/invite-user-modal/invite-user.component.sass
index 31fd3637a05..6125eaadcd3 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user.component.sass
+++ b/frontend/src/app/modules/invite-user-modal/invite-user.component.sass
@@ -1,11 +1,9 @@
.op-modal
- // different steps have different height. Force a similar height this way
- min-height: 500px
-
// Unfortunately, the op-modal contents has been wrapped once here
form
display: flex
flex-direction: column
+ height: 100%
flex-grow: 1
.op-form-field + .op-form-field
diff --git a/frontend/src/app/modules/invite-user-modal/invite-user.component.ts b/frontend/src/app/modules/invite-user-modal/invite-user.component.ts
index fa7f05cad10..b4a802920e8 100644
--- a/frontend/src/app/modules/invite-user-modal/invite-user.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/invite-user.component.ts
@@ -40,9 +40,6 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
public Steps = Steps;
public step = Steps.ProjectSelection;
- /* Close on escape? */
- public closeOnEscape = true;
-
/* Close on outside click */
public closeOnOutsideClick = true;
@@ -54,6 +51,11 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
public principal:HalResource|null = null;
public role:RoleResource|null = null;
public message = '';
+ public createdNewPrincipal = false;
+
+ public get loading() {
+ return this.locals.projectId && !this.project;
+ }
constructor(
@Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
@@ -68,10 +70,17 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
super.ngOnInit();
if (this.locals.projectId) {
- this.apiV3Service.projects.id(this.locals.projectId).get().subscribe(data => {
- this.project = data;
- });
- }
+ this.apiV3Service.projects.id(this.locals.projectId).get().subscribe(
+ data => {
+ this.project = data;
+ this.cdRef.markForCheck();
+ },
+ () => {
+ this.locals.projectId = null;
+ this.cdRef.markForCheck();
+ },
+ );
+ }
}
onProjectSelectionSave({ type, project }:{ type:PrincipalType, project:any }) {
@@ -105,6 +114,9 @@ export class InviteUserModalComponent extends OpModalComponent implements OnInit
}
onSuccessfulSubmission($event:{ principal:HalResource }) {
+ if (this.principal !== $event.principal && this.type === PrincipalType.User) {
+ this.createdNewPrincipal = true;
+ }
this.principal = $event.principal;
this.goTo(Steps.Success);
}
diff --git a/frontend/src/app/modules/invite-user-modal/message/message.component.html b/frontend/src/app/modules/invite-user-modal/message/message.component.html
index 639aa244bed..07eff7f4bf0 100644
--- a/frontend/src/app/modules/invite-user-modal/message/message.component.html
+++ b/frontend/src/app/modules/invite-user-modal/message/message.component.html
@@ -10,10 +10,15 @@
{{ text.description() }}
</p>
<textarea
- class="op-input"
+ class="op-input op-ium-invite-message-field"
[formControl]="messageControl"
slot="input"
+ #input
autofocus
+ cdkTextareaAutosize
+ cdkAutosizeMinRows="1"
+ cdkAutosizeMaxrows="3"
+ #autosize="cdkTextareaAutosize"
></textarea>
</op-form-field>
</div>
@@ -24,6 +29,6 @@
class="button"
(click)="back.emit()"
>{{ text.backButton }}</button>
- <button class="button">{{ text.nextButton }}</button>
+ <button class="button -highlight">{{ text.nextButton }}</button>
</div>
</form>
diff --git a/frontend/src/app/modules/invite-user-modal/message/message.component.sass b/frontend/src/app/modules/invite-user-modal/message/message.component.sass
index e69de29bb2d..b4366a5fbf7 100644
--- a/frontend/src/app/modules/invite-user-modal/message/message.component.sass
+++ b/frontend/src/app/modules/invite-user-modal/message/message.component.sass
@@ -0,0 +1,2 @@
+.op-ium-invite-message-field
+ height: 8em
diff --git a/frontend/src/app/modules/invite-user-modal/message/message.component.ts b/frontend/src/app/modules/invite-user-modal/message/message.component.ts
index b1be5c553df..f7cd86626ef 100644
--- a/frontend/src/app/modules/invite-user-modal/message/message.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/message/message.component.ts
@@ -5,11 +5,13 @@ import {
EventEmitter,
Output,
ElementRef,
+ ViewChild,
} from '@angular/core';
import {
FormControl,
FormGroup,
} from '@angular/forms';
+import {CdkTextareaAutosize} from '@angular/cdk/text-field';
import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {HalResource} from 'core-app/modules/hal/resources/hal-resource';
import {ProjectResource} from 'core-app/modules/hal/resources/project-resource';
@@ -30,6 +32,9 @@ export class MessageComponent implements OnInit {
@Output() back = new EventEmitter<void>();
@Output() save = new EventEmitter<{message:string}>();
+ @ViewChild('input') input: ElementRef;
+ @ViewChild('autosize') autosize: CdkTextareaAutosize;
+
public text = {
title: () => this.I18n.t('js.invite_user_modal.title.invite_principal_to_project', {
principal: this.principal?.name,
@@ -58,6 +63,11 @@ export class MessageComponent implements OnInit {
this.messageControl?.setValue(this.message);
}
+ ngAfterViewInit() {
+ this.input.nativeElement.focus();
+ this.autosize.resizeToFitContent(true);
+ }
+
onSubmit($e:Event) {
$e.preventDefault();
if (this.messageForm.invalid) {
diff --git a/frontend/src/app/modules/invite-user-modal/principal/principal.component.html b/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
index 921de1d360e..a69fb0679e1 100644
--- a/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
+++ b/frontend/src/app/modules/invite-user-modal/principal/principal.component.html
@@ -18,7 +18,7 @@
(createNew)="createNewFromInput($event)"
></op-ium-principal-search>
- <div
+ <p
*ngIf="isNewPrincipal && type === PrincipalType.User"
slot="input"
>
@@ -27,9 +27,9 @@
class="op-link"
(click)="principalControl?.setValue(null)"
>{{ text.changeUserSelection }}</button>
- </div>
+ </p>
- <div
+ <p
*ngIf="isNewPrincipal && type === PrincipalType.Placeholder"
slot="input"
>
@@ -38,7 +38,7 @@
class="op-link"
(click)="principalControl?.setValue(null)"
>{{ text.changePlaceholderSelection }}</button>
- </div>
+ </p>
<div
slot="errors"
@@ -56,6 +56,6 @@
class="button"
(click)="back.emit()"
>{{ text.backButton }}</button>
- <button class="button">{{ text.nextButton }}</button>
+ <button class="button -highlight">{{ text.nextButton }}</button>
</div>
</form>
diff --git a/frontend/src/app/modules/invite-user-modal/project-selection/project-selection.component.html b/frontend/src/app/modules/invite-user-modal/project-selection/project-selection.component.html
index 9e9c6a733be..77087ba0ac2 100644
--- a/frontend/src/app/modules/invite-user-modal/project-selection/project-selection.component.html
+++ b/frontend/src/app/modules/invite-user-modal/project-selection/project-selection.component.html
@@ -23,24 +23,26 @@
</div>
</op-form-field>
- <div class="op-form-field">
+ <op-form-field>
<op-option-list
[options]="typeOptions"
formControlName="type"
+ slot="input"
></op-option-list>
<div
*ngIf="projectAndTypeForm?.dirty && typeControl?.invalid"
class="op-form-field--errors"
+ slot="errors"
>
<div class="op-form-field--error">
{{ text.type.required }}
</div>
</div>
- </div>
+ </op-form-field>
</div>
<div class="op-modal--footer">
- <button class="button">{{ text.nextButton }}</button>
+ <button class="button -highlight">{{ text.nextButton }}</button>
</div>
</form>
diff --git a/frontend/src/app/modules/invite-user-modal/role/role.component.html b/frontend/src/app/modules/invite-user-modal/role/role.component.html
index 8d87f62b046..f9f3042ca16 100644
--- a/frontend/src/app/modules/invite-user-modal/role/role.component.html
+++ b/frontend/src/app/modules/invite-user-modal/role/role.component.html
@@ -35,6 +35,6 @@
class="button"
(click)="back.emit()"
>{{ text.backButton }}</button>
- <button class="button">{{ text.nextButton }}</button>
+ <button class="button -highlight">{{ text.nextButton }}</button>
</div>
</form>
diff --git a/frontend/src/app/modules/invite-user-modal/success/success.component.ts b/frontend/src/app/modules/invite-user-modal/success/success.component.ts
index 9cf0d7ddae8..b049076fd81 100644
--- a/frontend/src/app/modules/invite-user-modal/success/success.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/success/success.component.ts
@@ -20,6 +20,7 @@ export class SuccessComponent {
@Input() principal:HalResource;
@Input() project:ProjectResource;
@Input() type:PrincipalType;
+ @Input() createdNewPrincipal:boolean;
@Output() close = new EventEmitter<void>();
@@ -30,7 +31,7 @@ export class SuccessComponent {
public text = {
title: () => this.I18n.t('js.invite_user_modal.success.title', {
- principal: this.principal.name,
+ principal: this.createdNewPrincipal ? this.principal.email : this.principal.name,
}),
description: {
User: () => this.I18n.t('js.invite_user_modal.success.description.user', { project: this.project?.name }),
diff --git a/frontend/src/app/modules/invite-user-modal/summary/summary.component.html b/frontend/src/app/modules/invite-user-modal/summary/summary.component.html
index 6657b1e3601..2d86630d5d3 100644
--- a/frontend/src/app/modules/invite-user-modal/summary/summary.component.html
+++ b/frontend/src/app/modules/invite-user-modal/summary/summary.component.html
@@ -19,9 +19,9 @@
</div>
<op-form-field
[label]="text.messageLabel"
- *ngIf="type !== PrincipalType.Placeholder"
+ *ngIf="type !== PrincipalType.Placeholder && message"
>
- <p slot="input">{{ message }}</p>
+ <p slot="input" class="op-ium-summary-message">{{ message }}</p>
</op-form-field>
</div>
diff --git a/frontend/src/app/modules/invite-user-modal/summary/summary.component.sass b/frontend/src/app/modules/invite-user-modal/summary/summary.component.sass
index e69de29bb2d..c87ea89e47f 100644
--- a/frontend/src/app/modules/invite-user-modal/summary/summary.component.sass
+++ b/frontend/src/app/modules/invite-user-modal/summary/summary.component.sass
@@ -0,0 +1,2 @@
+.op-ium-summary-message
+ white-space: pre-wrap
diff --git a/frontend/src/app/modules/invite-user-modal/summary/summary.component.ts b/frontend/src/app/modules/invite-user-modal/summary/summary.component.ts
index 8b3f226c24e..637d8700a86 100644
--- a/frontend/src/app/modules/invite-user-modal/summary/summary.component.ts
+++ b/frontend/src/app/modules/invite-user-modal/summary/summary.component.ts
@@ -59,8 +59,7 @@ export class SummaryComponent {
readonly I18n:I18nService,
readonly elementRef:ElementRef,
readonly api:APIV3Service,
- ) {
- }
+ ) { }
invite() {
return of(this.principal)
diff --git a/frontend/src/app/modules/modal/modal.sass b/frontend/src/app/modules/modal/modal.sass
index 433f10af5f5..5fb6ad8c8b1 100644
--- a/frontend/src/app/modules/modal/modal.sass
+++ b/frontend/src/app/modules/modal/modal.sass
@@ -1,34 +1,32 @@
// TODO: Check out -danger-zone and modal-close-button patterns
.op-modal
- $modal-padding: 2rem
+ --modal-padding: 2rem
+ position: relative
display: flex
flex-direction: column
align-items: stretch
background: white
width: 40rem
- min-height: 20vh
+ min-height: 500px
max-width: 100vw
max-height: 100vh
+ @media (max-width: 680px), (max-height: 500px)
+ --modal-padding: 1rem
+ height: 100vh
+ width: 100vw
+ min-height: unset
+
&_wide
width: 70rem
min-height: 40vh
- &--body
- display: flex
- flex-direction: column
- padding: $modal-padding
- flex-grow: 1
- flex-shrink: 1
- overflow-y: auto
- @include styled-scroll-bar
-
&--header
display: flex
- padding: 2rem $modal-padding 1rem $modal-padding
+ padding: var(--modal-padding) var(--modal-padding) calc(0.5 * var(--modal-padding)) var(--modal-padding)
position: relative
border-bottom: 1px solid #eee
@@ -48,6 +46,15 @@
justify-content: center
align-items: center
+ &--body
+ display: flex
+ flex-direction: column
+ padding: var(--modal-padding)
+ flex-grow: 1
+ flex-shrink: 1
+ overflow-y: auto
+ @include styled-scroll-bar
+
&--title
font-size: 1.3rem
padding: 0
@@ -55,12 +62,22 @@
margin-right: auto
&--footer
- padding: 1rem $modal-padding 2rem $modal-padding
+ display: flex
+ justify-content: flex-end
+ padding: calc(0.5 * var(--modal-padding)) var(--modal-padding) var(--modal-padding) var(--modal-padding)
+ width: 100%
+
+ .button
+ margin-bottom: 0
+
+ @media (max-width: 680px), (max-height: 500px)
+ padding: var(--modal-padding)
&--close-button
height: 100%
- width: 5rem
+ width: 3rem
padding: 0.45rem 0
+ margin: 0 -1rem
display: flex
justify-content: center
align-items: center
diff --git a/spec/support/components/users/invite_user_modal.rb b/spec/support/components/users/invite_user_modal.rb
index 074e003a35d..3bdd5b06515 100644
--- a/spec/support/components/users/invite_user_modal.rb
+++ b/spec/support/components/users/invite_user_modal.rb
@@ -63,7 +63,7 @@ module Components
confirmation_step
# Step 6: Perform invite
- click_modal_button 'Send Invitation'
+ click_modal_button 'Send invitation'
if invite_user?
expect_text "Invite #{principal.mail} to #{project.name}"
@@ -116,7 +116,7 @@ module Components
def invitation_step(next_step: true)
invitation_message invite_message
- click_modal_button 'Review Invitation' if next_step
+ click_modal_button 'Review invitation' if next_step
end
def confirmation_step