Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/approve org requests #529

Merged
merged 25 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d973210
started implementation of requests page
agduncan94 Jan 21, 2019
fd6aae6
added a confirmation dilaog to accepting (does not work yet)
agduncan94 Jan 21, 2019
2dde9d9
ability to approve organizations
agduncan94 Jan 21, 2019
9058a71
set up for reject button
agduncan94 Jan 22, 2019
da4c347
can reject and approve, also works with new state field
agduncan94 Jan 22, 2019
aa09258
do not show org requests if you are not admin or curator
agduncan94 Jan 22, 2019
a6b7176
show my pending requests
agduncan94 Jan 22, 2019
8437bfa
some reorg of how orgs are displayed
agduncan94 Jan 22, 2019
ca7b009
added basic org invites to accounts page
agduncan94 Jan 23, 2019
7109cd2
can now accept/reject organization invites
agduncan94 Jan 23, 2019
94e3b33
documentation and some cleanup
agduncan94 Jan 24, 2019
5bfe9df
Merge branch 'develop' into feature/approve-org-requests
agduncan94 Jan 24, 2019
d6ea44c
fix merge issues
agduncan94 Jan 24, 2019
5e6dd10
added some tests for requests page
agduncan94 Jan 24, 2019
955e5ad
properly display names of pending organization owners
agduncan94 Jan 24, 2019
79e6d4f
do not use loading from alert query
agduncan94 Jan 29, 2019
54bda25
Merge branch 'develop' into feature/approve-org-requests
agduncan94 Jan 29, 2019
b90c2ab
updated travis
agduncan94 Jan 30, 2019
52b810e
fix lint and some ng tests
agduncan94 Jan 30, 2019
bde805e
fix requests module
agduncan94 Jan 30, 2019
5ec44ef
loading error
agduncan94 Jan 30, 2019
9bd7dae
fixed cypress tests
agduncan94 Jan 30, 2019
4ef7d54
changes from PR
agduncan94 Jan 30, 2019
26ac936
change some decline back to reject
agduncan94 Jan 31, 2019
520dd11
fixes gary mentioned
agduncan94 Jan 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jdk:
- oraclejdk8
env:
global:
- WEBSERVICE_VERSION="1.6.0-alpha.3"
- WEBSERVICE_VERSION="1.6.0-alpha.4"
addons:
firefox: "latest"
postgresql: "9.6"
Expand Down
122 changes: 119 additions & 3 deletions cypress/integration/group1/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { setTokenUserViewPort } from '../../support/commands';
import { setTokenUserViewPortCurator } from '../../support/commands';

describe('Dropdown test', () => {
// TODO: GitLab tests are commented out
setTokenUserViewPort();
setTokenUserViewPortCurator();

beforeEach(() => {
cy
Expand All @@ -27,6 +27,7 @@ describe('Dropdown test', () => {
url: /extended/,
response: { 'canChangeUsername': true }
});

cy.visit('');

// Select dropdown
Expand Down Expand Up @@ -65,6 +66,121 @@ describe('Dropdown test', () => {
everythingOk();
});
});

describe('Go to requests page', () => {

beforeEach(() => {
// Pending orgs starts with two
const pendingOrganizations = [
{ id: 1000, name: 'OrgOne', status: 'PENDING' },
{ id: 1001, name: 'OrgTwo', status: 'PENDING' }
];

cy
.server()
.route({
method: 'GET',
url: '/organisations/all?type=pending',
response: pendingOrganizations
});

// Logged in user has two memberships, one is not accepted
const memberships = [
{id: 1, role: 'MAINTAINER', accepted: false, organisation: { id: 1000, status: 'PENDING', name: 'orgOne'}},
{id: 2, role: 'MAINTAINER', accepted: true, organisation: { id: 1001, status: 'PENDING', name: 'orgTwo'}}
];
cy
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
response: memberships
});
// Choose dropdown
cy
.get('#dropdown-accounts')
.click();
cy.contains('Requests').click();
});

it('Should have two pending orgs', () => {
// Endpoint should return only one pending organisation after approval
const pendingOrganizations = [{ id: 1001, name: 'OrgTwo', status: 'PENDING' }];
cy
.server()
.route({
method: 'GET',
url: '/organisations/all?type=pending',
response: pendingOrganizations
});

// Stub approve response
cy
.server()
.route({
method: 'POST',
url: '/organisations/1000/approve',
response: []
});

// Ensure that there are two orgs
cy.get('#pending-org-card-0').should('be.visible');
cy.get('#pending-org-card-1').should('be.visible');

// Accept first org
cy.get('#reject-pending-org-0').should('be.visible');
cy.get('#approve-pending-org-0').should('be.visible').click();
cy.get('#approve-pending-org-dialog').should('be.visible').click();

// Ensure that only one org exists now
cy.get('#pending-org-card-0').should('be.visible');
cy.get('#pending-org-card-1').should('not.be.visible');
});

it('Should have a pending invite', () => {
// Stub the accept invite response
cy
.server()
.route({
method: 'POST',
url: '/organisations/1000/invitation?accept=true',
response: []
});

// Membership should have two accepted entries
const memberships = [
{ id: 1, role: 'MAINTAINER', accepted: true, organisation: { id: 1000, status: 'PENDING', name: 'orgOne' }},
{ id: 2, role: 'MAINTAINER', accepted: true, organisation: { id: 1001, status: 'PENDING', name: 'orgTwo' }}
];
cy
.server()
.route({
method: 'GET',
url: '/users/user/memberships',
response: memberships
});

// One invite should be visible
cy.get('#my-org-invites-card-0').should('be.visible');

// Accept org invite
cy.get('#reject-invite-org-0').should('be.visible');
cy.get('#accept-invite-org-0').should('be.visible').click();
cy.get('#accept-pending-org-dialog').should('be.visible').click();

// Should have two orgs in pending list
cy.get('#my-pending-org-card-0').should('be.visible');
cy.get('#my-pending-org-card-1').should('be.visible');
});

it('Should have a pending org request', () => {
// One pending org request should be visible
cy.get('#my-pending-org-card-0').should('be.visible');
});


});

describe('Go to enabled Dockstore Account Controls', () => {
beforeEach(() => {
// Select dropdown accounts
Expand All @@ -85,7 +201,7 @@ describe('Dropdown test', () => {
cy.contains('Yes, delete my account').should('be.disabled');
cy.get('#deleteUserUsernameInput').type('potato');
cy.contains('Yes, delete my account').should('be.disabled');
cy.get('#deleteUserUsernameInput').clear().type('user_A');
cy.get('#deleteUserUsernameInput').clear().type('user_curator');
cy.contains('Yes, delete my account').should('not.be.disabled').click();
cy.url().should('eq', Cypress.config().baseUrl + '/login');
});
Expand Down
10 changes: 10 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ export function setTokenUserViewPort() {
localStorage.setItem('ng2-ui-auth_token', 'imamafakedockstoretoken');
});
}

export function setTokenUserViewPortCurator() {
beforeEach(() => {
// Login by adding user obj and token to local storage
localStorage.setItem('dockstore.ui.userObj',
'{\"id\": 4, \"username\": \"user_curator\", \"isAdmin\": \"false\", \"name\": \"user_curator\", \"curator\": \"true\"}');
localStorage.setItem('ng2-ui-auth_token', 'imamafakedockstoretoken2');
});
}

export function goToUnexpandedSidebarEntry(organization: string, repo: (RegExp | string)) {
// This is needed because of a possible defect in the implementation.
// All expansion panels are shown before any of them are expanded (after some logic of choosing which to expanded).
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import { StargazersModule } from './stargazers/stargazers.module';
import { StarredEntriesComponent } from './starredentries/starredentries.component';
import { StarringModule } from './starring/starring.module';
import { SitemapComponent } from './sitemap/sitemap.component';
import { RequestsModule } from './loginComponents/requests.module';

export const myCustomTooltipDefaults: MatTooltipDefaultOptions = {
showDelay: 500,
Expand Down Expand Up @@ -164,7 +165,8 @@ export const myCustomSnackbarDefaults: MatSnackBarConfig = {
SearchModule,
ApiModule.forRoot(getApiConfig),
CustomMaterialModule,
RefreshAlertModule
RefreshAlertModule,
RequestsModule
],
providers: [
AccountsService,
Expand Down
3 changes: 3 additions & 0 deletions src/app/loginComponents/accounts/accounts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
<app-controls></app-controls>
</ng-template>
</mat-tab>
<mat-tab label="Requests">
<requests></requests>
</mat-tab>
</mat-tab-group>
</div>
26 changes: 26 additions & 0 deletions src/app/loginComponents/requests.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RequestsComponent, OrganizationRequestConfirmDialogComponent,
OrganizationInviteConfirmDialogComponent } from './requests/requests.component';
import { CustomMaterialModule } from './../shared/modules/material.module';
import { RouterModule } from '@angular/router';
import { FlexLayoutModule } from '@angular/flex-layout';
@NgModule({
imports: [
CommonModule,
CustomMaterialModule,
RouterModule,
FlexLayoutModule
],
declarations: [
RequestsComponent,
OrganizationRequestConfirmDialogComponent,
OrganizationInviteConfirmDialogComponent
], exports: [
RequestsComponent,
OrganizationRequestConfirmDialogComponent,
OrganizationInviteConfirmDialogComponent
], entryComponents: [ OrganizationRequestConfirmDialogComponent,
OrganizationInviteConfirmDialogComponent],
})
export class RequestsModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h1 mat-dialog-title>{{data.approve ? 'Accept' : 'Decline'}} Invite to {{data.name}}</h1>

<div mat-dialog-content>
<p>Are you sure you want to <strong>{{data.approve ? 'accept' : 'decline'}}</strong> the organization invite from <strong>{{data.name}}</strong>?</p>
</div>
<div mat-dialog-actions>
<div fxFlex></div>
<button mat-button (click)="onNoClick()">No Thanks</button>
<span *ngIf="data.approve; else rejectBlock">
<button mat-flat-button id="accept-pending-org-dialog" [mat-dialog-close]="{ 'id': data.id, 'approve': data.approve }">Accept</button>
</span>
<ng-template #rejectBlock>
<button mat-flat-button id="reject-pending-org-dialog" [mat-dialog-close]="{ 'id': data.id, 'approve': data.approve }">Decline</button>
</ng-template>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h1 mat-dialog-title>{{data.approve ? 'Approve' : 'Reject'}} Organization</h1>

<div mat-dialog-content>
<p>Are you sure you want to <strong>{{data.approve ? 'approve' : 'reject'}}</strong> the organization <strong>{{data.name}}</strong>?</p>
</div>
<div mat-dialog-actions>
<div fxFlex></div>
<button mat-button (click)="onNoClick()">No Thanks</button>
<span *ngIf="data.approve; else rejectBlock">
<button mat-flat-button id="approve-pending-org-dialog" [mat-dialog-close]="{ 'id': data.id, 'approve': data.approve }">Approve</button>
</span>
<ng-template #rejectBlock>
<button mat-flat-button id="reject-pending-org-dialog" [mat-dialog-close]="{ 'id': data.id, 'approve': data.approve }">Reject</button>
</ng-template>
</div>
Loading