Skip to content

Commit

Permalink
chore(Authoring Tool): Convert TopBar to Angular (#1356)
Browse files Browse the repository at this point in the history
Remove unused CM topBar
  • Loading branch information
hirokiterashima authored Jul 24, 2023
1 parent 2d8d5b9 commit ccfa3c9
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 448 deletions.
4 changes: 3 additions & 1 deletion src/app/teacher/authoring-tool.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { NotebookAuthoringComponent } from '../../assets/wise5/authoringTool/not
import { StructureAuthoringModule } from '../../assets/wise5/authoringTool/structure/structure-authoring.module';
import { MilestonesAuthoringComponent } from '../../assets/wise5/authoringTool/milestones-authoring/milestones-authoring.component';
import { ChooseComponentLocationComponent } from '../../assets/wise5/authoringTool/node/chooseComponentLocation/choose-component-location.component';
import { TopBarComponent } from '../../assets/wise5/authoringTool/components/top-bar/top-bar.component';
import { ProjectAssetAuthoringModule } from '../../assets/wise5/authoringTool/project-asset-authoring/project-asset-authoring.module';
import { ChooseSimulationComponent } from '../../assets/wise5/authoringTool/addNode/choose-simulation/choose-simulation.component';

Expand All @@ -54,7 +55,8 @@ import { ChooseSimulationComponent } from '../../assets/wise5/authoringTool/addN
RecoveryAuthoringComponent,
RequiredErrorLabelComponent,
RubricAuthoringComponent,
TeacherNodeIconComponent
TeacherNodeIconComponent,
TopBarComponent
],
imports: [
StudentTeacherCommonModule,
Expand Down
10 changes: 5 additions & 5 deletions src/assets/wise5/authoringTool/authoringTool.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
md-theme="at"
>
<at-top-bar
logo-path="{{::$ctrl.logoPath}}"
project-id="$ctrl.projectId"
project-title="$ctrl.projectTitle"
run-id="$ctrl.runId"
run-code="$ctrl.runCode"
[logo-path]="$ctrl.logoPath"
[project-id]="$ctrl.projectId"
[project-title]="$ctrl.projectTitle"
[run-id]="$ctrl.runId"
[run-code]="$ctrl.runCode"
></at-top-bar>
<at-toolbar
ng-if="$ctrl.showToolbar"
Expand Down
7 changes: 5 additions & 2 deletions src/assets/wise5/authoringTool/components/shared/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import { MainMenuComponent } from '../../../common/main-menu/main-menu.component';
import Toolbar from './toolbar/toolbar';
import TopBar from './topBar/topBar';
import * as angular from 'angular';
import { downgradeComponent } from '@angular/upgrade/static';
import { PreviewComponentComponent } from '../preview-component/preview-component.component';
import { PreviewComponentButtonComponent } from '../preview-component-button/preview-component-button.component';
import { TopBarComponent } from '../top-bar/top-bar.component';

const SharedComponents = angular
.module('atShared', [])
Expand All @@ -15,7 +15,10 @@ const SharedComponents = angular
downgradeComponent({ component: MainMenuComponent }) as angular.IDirectiveFactory
)
.component('atToolbar', Toolbar)
.component('atTopBar', TopBar)
.directive(
'atTopBar',
downgradeComponent({ component: TopBarComponent }) as angular.IDirectiveFactory
)
.directive(
'previewComponent',
downgradeComponent({ component: PreviewComponentComponent }) as angular.IDirectiveFactory
Expand Down
156 changes: 0 additions & 156 deletions src/assets/wise5/authoringTool/components/shared/topBar/topBar.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<mat-toolbar class="l-header" color="primary">
<span class="button logo-link">
<a href="{{ contextPath }}/teacher" target="_self">
<img [src]="logoPath" alt="WISE logo" i18n-alt class="logo" />
</a>
</span>
<h3 fxLayout="row" fxLayoutAlign="start center" class="title-header">
<span *ngIf="projectTitle" id="projectTitleSpan">{{ projectTitle }}</span>
<span *ngIf="!projectTitle" id="projectTitleSpan" i18n>Authoring Tool</span>&nbsp;
<span class="mat-caption" *ngIf="projectId" fxLayout="row" fxLayoutAlign="start center">
<span fxHide.xs fxHide.sm fxHide.md>({{ projectInfo }})</span>
<button
mat-icon-button
aria-label="Project Info"
i18n-aria-label
fxHide.gt-md
[matTooltip]="projectInfo"
>
<mat-icon>info</mat-icon>
</button>
<button
mat-icon-button
*ngIf="runId"
fxHide.xs
aria-label="Switch to Grading View"
i18n-aria-label
matTooltip="Switch to Grading View"
i18n-matTooltip
(click)="switchToGradingView()"
>
<mat-icon mat-menu-origin>assignment_turned_in</mat-icon>
</button>
</span>
</h3>
<span fxFlex></span>
<button
mat-button
aria-label="Help"
i18n-aria-label
style="text-transform: none"
(click)="showHelp()"
i18n
>
Help
</button>
<button
mat-icon-button
aria-label="User Menu"
i18n-aria-label
class="mat-icon-button"
[matMenuTriggerFor]="accountMenu"
>
<mat-icon mat-menu-origin>account_box</mat-icon>
</button>
<mat-menu #accountMenu class="account-menu account-menu--fixed-width">
<div
class="account-menu__info"
(click)="$event.stopPropagation()"
fxLayout="row"
fxLayoutAlign="start center"
>
<div class="account-menu__info__title">
<div class="account-menu-avatar" fxLayoutAlign="start center">
<mat-icon style="color: {{ avatarColor }}" class="mat-36"> account_circle </mat-icon>
</div>
</div>
<div class="mat-subtitle-2">
{{ userInfo.firstName }} {{ userInfo.lastName }}
<span class="mat-caption">({{ userInfo.username }})</span>
</div>
</div>
<div class="account-menu__actions" (click)="$event.stopPropagation()" fxLayout="row">
<button mat-button color="primary" class="account-menu-button" (click)="goHome()" i18n>
Go Home
</button>
<span fxFlex></span>
<button mat-button color="primary" class="account-menu-button" (click)="logOut()" i18n>
Sign Out
</button>
</div>
</mat-menu>
</mat-toolbar>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@import 'style/abstracts/variables','style/abstracts/functions', 'style/abstracts/mixins';

.mat-toolbar {
padding: 0 8px;
}

.title-header {
font-weight: inherit !important;
}

.title {
white-space: normal;
line-height: 1.2;

@media (max-width: breakpoint('xs.max')) {
font-size: 14px;
}
}

.mat-mdc-icon-button {
margin: 0 4px;
font-size: 16px;
}

/* TODO(mdc-migration): The following rule targets internal classes of list that may no longer apply for the MDC version. */
.mat-list-item-content {
padding: 0;
}

.account-menu-avatar {
height: 48px;
width: 48px;
}

.account-menu-button {
margin: 8px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { UpgradeModule } from '@angular/upgrade/static';
import { TopBarComponent } from './top-bar.component';
import { ConfigService } from '../../../services/configService';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TeacherProjectService } from '../../../services/teacherProjectService';

class MockUpgradeModule {
$injector: any = {
get() {
return {};
}
};
}

describe('TopBarComponent', () => {
let component: TopBarComponent;
let fixture: ComponentFixture<TopBarComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TopBarComponent],
imports: [
HttpClientTestingModule,
MatIconModule,
MatMenuModule,
MatToolbarModule,
MatTooltipModule,
StudentTeacherCommonServicesModule
],
providers: [TeacherProjectService, { provide: UpgradeModule, useClass: MockUpgradeModule }]
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(TopBarComponent);
component = fixture.componentInstance;
spyOn(TestBed.inject(ConfigService), 'getMyUserInfo').and.returnValue({});
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit ccfa3c9

Please sign in to comment.