-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Concurrent Authors): Make into Angular component (#1172)
Update styles, layout, and message text Co-authored-by: Jonathan Lim-Breitbart <breity10@gmail.com>
- Loading branch information
1 parent
6209ad5
commit 2fbac01
Showing
9 changed files
with
107 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
.../wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="warn"> | ||
<b>{{ message }}</b> | ||
</div> |
48 changes: 48 additions & 0 deletions
48
...se5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ConcurrentAuthorsMessageComponent } from './concurrent-authors-message.component'; | ||
import { ConfigService } from '../../services/configService'; | ||
|
||
class MockConfigService { | ||
getMyUsername(): string { | ||
return 'aa'; | ||
} | ||
} | ||
|
||
let component: ConcurrentAuthorsMessageComponent; | ||
let fixture: ComponentFixture<ConcurrentAuthorsMessageComponent>; | ||
describe('ConcurrentAuthorsMessageComponent', () => { | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ConcurrentAuthorsMessageComponent], | ||
providers: [{ provide: ConfigService, useClass: MockConfigService }] | ||
}); | ||
fixture = TestBed.createComponent(ConcurrentAuthorsMessageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
ngOnChanges(); | ||
}); | ||
|
||
function ngOnChanges() { | ||
describe('ngOnChanges()', () => { | ||
it('should set empty message when there are no other authors', () => { | ||
expectMessage(['aa'], ''); | ||
}); | ||
it('should set message to other authors when there are other authors', () => { | ||
expectMessage( | ||
['aa', 'bb'], | ||
"Also currently editing this unit: bb. Be careful not to overwrite each other's work!" | ||
); | ||
expectMessage( | ||
['aa', 'bb', 'cc'], | ||
"Also currently editing this unit: bb, cc. Be careful not to overwrite each other's work!" | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
function expectMessage(authors: string[], message: string) { | ||
component.authors = authors; | ||
component.ngOnChanges(); | ||
expect(component.message).toEqual(message); | ||
} |
23 changes: 23 additions & 0 deletions
23
...ts/wise5/authoringTool/concurrent-authors-message/concurrent-authors-message.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { ConfigService } from '../../services/configService'; | ||
|
||
@Component({ | ||
selector: 'concurrent-authors-message', | ||
templateUrl: 'concurrent-authors-message.component.html' | ||
}) | ||
export class ConcurrentAuthorsMessageComponent { | ||
@Input() authors: string[] = []; | ||
message: string = ''; | ||
|
||
constructor(private configService: ConfigService) {} | ||
|
||
ngOnChanges() { | ||
this.authors.splice(this.authors.indexOf(this.configService.getMyUsername()), 1); | ||
this.message = | ||
this.authors.length > 0 | ||
? $localize`Also currently editing this unit: ${this.authors.join( | ||
', ' | ||
)}. Be careful not to overwrite each other's work!` | ||
: ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters