Skip to content

Commit

Permalink
Merge f30a5f2 into 28be572
Browse files Browse the repository at this point in the history
  • Loading branch information
nertim committed Oct 4, 2018
2 parents 28be572 + f30a5f2 commit 0a41616
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 106 deletions.
20 changes: 20 additions & 0 deletions client/src/app/controls/group-tabs/group-tabs.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<nav *ngIf="tabs && control"
[id]="'group-tab-' + groupId"
role="tablist"
#groupTabs>
<div *ngFor="let tabItem of tabs"
(click)="select(tabItem.id)"
class="clickable group-tab"
[class.selected-container]="tabItem.id === selectedTabId"
[tabindex]="tabItem.id === selectedTabId ? 0 : -1"
(keydown)="onKeyDown($event)"
role="tab"
[id]="'group-tab-item-' + tabItem.id"
[attr.aria-controls]="'group-tab-item-' + tabItem.id"
[attr.aria-selected]="tabItem.id === selectedTabId"
[attr.aria-label]="tabItem.title">

<div [load-image]="tabItem.iconUrl" class="icon-medium"></div>
<h3>{{tabItem.title}}</h3>
</div>
</nav>
37 changes: 37 additions & 0 deletions client/src/app/controls/group-tabs/group-tabs.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@import '../../../sass/common/variables';
nav {
display: flex;
}

.group-tab {
background-color: $border-color;
width: calc(100% / 3);
text-align: center;
height: 83px;
padding-top: 7px;
box-shadow: $card-box-shadow;

h3 {
margin-top: 2px;
font-weight: bold;
}

h4 {
font-size: 12px;
}

&.selected-container {
background-color: $body-bg-color;
}
}

:host-context(#app-root[theme=dark]) {
.group-tab {
background-color: lighten($chrome-color-dark, 10%);
box-shadow: $card-box-shadow-hover-dark;

&.selected-container{
background-color: $chrome-color-dark;
}
}
}
104 changes: 104 additions & 0 deletions client/src/app/controls/group-tabs/group-tabs.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import {
Component,
OnChanges,
ElementRef,
ViewChild,
Input,
SimpleChanges,
Output,
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { KeyCodes } from '../../shared/models/constants';
import { Dom } from '../../shared/Utilities/dom';
import { Subject } from 'rxjs/Subject';

export interface GroupTab {
title: string;
id: string;
iconUrl: string;
}

@Component({
selector: 'group-tabs',
templateUrl: './group-tabs.component.html',
styleUrls: ['./group-tabs.component.scss'],
})
export class GroupTabsComponent implements OnChanges {
@ViewChild('groupTabs') groupTabs: ElementRef;
@Input() control: FormControl;
@Input() tabs: GroupTab[];
@Input() groupId: string;
@Output() valueChanged: Subject<string>;

public selectedTabId: string;
private _originalTabId: string;

constructor() {
this.valueChanged = new Subject<string>();
}

ngOnChanges(changes: SimpleChanges) {
if (changes['control']) {
this._originalTabId = this.control.value;
this.selectedTabId = this.control.value;
}
}

onKeyDown(event: KeyboardEvent) {
if (event.keyCode === KeyCodes.arrowRight || event.keyCode === KeyCodes.arrowLeft) {
let curIndex = this.tabs.findIndex(tab => tab.id === this.selectedTabId);
const tabElements = this._getTabElements();
this._setFocus(false, tabElements, curIndex);

if (event.keyCode === KeyCodes.arrowRight) {
curIndex = this._getTargetIndex(curIndex + 1);
} else {
curIndex = this._getTargetIndex(curIndex - 1);
}

this.select(this.tabs[curIndex].id);
this._setFocus(true, tabElements, curIndex);

event.preventDefault();
}
}

select(tabId: string) {
if (tabId !== this._originalTabId) {
this.control.markAsDirty();
} else {
this.control.markAsPristine();
}

this.control.setValue(tabId);
this.selectedTabId = tabId;
this.valueChanged.next(tabId);
}

private _getTabElements() {
return this.groupTabs.nativeElement.children;
}

private _setFocus(set: boolean, elements: HTMLCollection, index: number) {
const tab = Dom.getTabbableControl(<HTMLElement>elements[index]);

if (set) {
Dom.setFocus(tab);
} else {
Dom.clearFocus(tab);
}
}

private _getTargetIndex(currentIndex: number) {
let targetIndex = 0;
if (currentIndex < 0) {
targetIndex = this.tabs.length - 1;
} else if (currentIndex >= this.tabs.length) {
targetIndex = 0;
} else {
targetIndex = currentIndex;
}

return targetIndex;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<div id="container-shield" *ngIf="isLocked"></div>
<form *ngIf="!loading && containerConfigureInfo && containerConfigureInfo.container && containerConfigureInfo.containerForm" [formGroup]="form" id="container-picker">
<nav id="container-tabs" role="tablist" #containerSettingsTabs>
<div *ngFor="let container of containerSettingsManager.containers"
(click)="selectContainer(container)"
class="clickable container"
[class.selected-container]="container === containerConfigureInfo.container"
[tabindex]="container === containerConfigureInfo.container ? 0 : -1"
(keydown)="onContainerTabKeyPress($event)"
role="tab"
[id]="'container-tab-' + container.id"
[attr.aria-controls]="'container-tab-' + container.id"
[attr.aria-selected]="container === containerConfigureInfo.container"
[attr.aria-label]="container.title">

<div [load-image]="container.iconUrl" class="icon-medium"></div>
<h3>{{container.title}}</h3>
</div>
</nav>
<group-tabs
[control] = "form.controls.containerType"
[tabs] = "containerSettingsManager.containers"
[groupId] = "'container-settings'"
(valueChanged)="selectContainer($event)">
</group-tabs>

<container-configure
*ngIf = "containerConfigureInfo.container.id === 'single'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ $center-column-max-width: calc(#{$spec-card-max-width}*4 - 40px);
#container-picker {
padding-bottom: 60px;

nav {
display: flex;
}

.tiers-header {
margin: 20px 0px 0px 15px;
}
Expand All @@ -47,28 +43,6 @@ $center-column-max-width: calc(#{$spec-card-max-width}*4 - 40px);
}
}

.container {
background-color: $border-color;
width: calc(100% / 3);
text-align: center;
height: 83px;
padding-top: 7px;
box-shadow: $card-box-shadow;

h3 {
margin-top: 2px;
font-weight: bold;
}

h4 {
font-size: 12px;
}

&.selected-container {
background-color: $body-bg-color;
}
}

.expand-icon{
display: inline-block;
height: 13px;
Expand Down Expand Up @@ -125,15 +99,6 @@ $center-column-max-width: calc(#{$spec-card-max-width}*4 - 40px);
background-color: $translucent-shield-color-dark;
}

.container{
background-color: lighten($chrome-color-dark, 10%);
box-shadow: $card-box-shadow-hover-dark;

&.selected-container{
background-color: $chrome-color-dark;
}
}

footer {
background-color:$body-bg-color-dark;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Component, OnDestroy, Input, Injector, ViewChild, ElementRef } from '@angular/core';
import { Component, OnDestroy, Input, Injector } from '@angular/core';
import { FeatureComponent } from '../../shared/components/feature-component';
import { TreeViewInfo } from '../../tree-view/models/tree-view-info';
import { ContainerSettingsInput, ContainerSettingsData, Container, ContainerConfigureData } from './container-settings';
import { ContainerSettingsInput, ContainerSettingsData, ContainerConfigureData, ContainerType } from './container-settings';
import { Observable } from 'rxjs/Observable';
import { ContainerSettingsManager } from './container-settings-manager';
import { KeyCodes, LogCategories } from '../../shared/models/constants';
import { Dom } from '../../shared/Utilities/dom';
import { LogCategories } from '../../shared/models/constants';
import { SiteService } from '../../shared/services/site.service';
import { HttpResult } from '../../shared/models/http-result';
import { ArmObj } from '../../shared/models/arm/arm-obj';
Expand All @@ -31,8 +30,6 @@ export interface StatusMessage {
styleUrls: ['./container-settings.component.scss'],
})
export class ContainerSettingsComponent extends FeatureComponent<TreeViewInfo<ContainerSettingsInput<ContainerSettingsData>>> implements OnDestroy {
@ViewChild('containerSettingsTabs') containerSettingsTabs: ElementRef;

@Input() set viewInfoInput(viewInfo: TreeViewInfo<ContainerSettingsInput<ContainerSettingsData>>) {
this.setInput(viewInfo);
this._viewInfo = viewInfo;
Expand Down Expand Up @@ -171,30 +168,9 @@ export class ContainerSettingsComponent extends FeatureComponent<TreeViewInfo<Co
});
}

public selectContainer(container: Container) {
this.form.controls.containerType.setValue(container.id);
this.containerConfigureInfo.containerForm = this.containerSettingsManager.getContainerForm(this.form, container.id);
this.containerConfigureInfo.container = container;
}

public onContainerTabKeyPress(event: KeyboardEvent) {
const containers = this.containerSettingsManager.containers;
if (event.keyCode === KeyCodes.arrowRight || event.keyCode === KeyCodes.arrowLeft) {
let curIndex = containers.findIndex(container => container === this.containerConfigureInfo.container);
const tabElements = this._getTabElements();
this._updateContainerFocusTab(false, tabElements, curIndex);

if (event.keyCode === KeyCodes.arrowRight) {
curIndex = this._getTargetIndex(containers, curIndex + 1);
} else {
curIndex = this._getTargetIndex(containers, curIndex - 1);
}

this.selectContainer(containers[curIndex]);
this._updateContainerFocusTab(true, tabElements, curIndex);

event.preventDefault();
}
public selectContainer(containerId: ContainerType) {
this.containerConfigureInfo.containerForm = this.containerSettingsManager.getContainerForm(this.form, containerId);
this.containerConfigureInfo.container = this.containerSettingsManager.containers.find(container => container.id === containerId);
}

public clickApply() {
Expand Down Expand Up @@ -275,30 +251,6 @@ export class ContainerSettingsComponent extends FeatureComponent<TreeViewInfo<Co
this.setInput(this._viewInfo);
}

private _getTargetIndex(containers: Container[], targetIndex: number) {
if (targetIndex < 0) {
targetIndex = containers.length - 1;
} else if (targetIndex >= containers.length) {
targetIndex = 0;
}

return targetIndex;
}

private _getTabElements() {
return this.containerSettingsTabs.nativeElement.children;
}

private _updateContainerFocusTab(set: boolean, elements: HTMLCollection, index: number) {
const tab = Dom.getTabbableControl(<HTMLElement>elements[index]);

if (set) {
Dom.setFocus(tab);
} else {
Dom.clearFocus(tab);
}
}

private _markFormGroupDirtyAndValidate(formGroup: FormGroup) {
if (formGroup.controls) {
const keys = Object.keys(formGroup.controls);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ContainerACRService } from './services/container-acr.service';
import { ContainerLogsService } from './services/container-logs.service';
import { ContainerMultiConfigService } from './services/container-multiconfig.service';
import { ContainerValidationService } from './services/container-validation.service';
import { GroupTabsComponent } from '../../controls/group-tabs/group-tabs.component';

@NgModule({
imports: [
Expand All @@ -37,6 +38,7 @@ import { ContainerValidationService } from './services/container-validation.serv
ContainerImageSourcePrivateRegistryComponent,
ContainerLogsComponent,
ContainerContinuousDeliveryComponent,
GroupTabsComponent,
],
providers: [
ContainerSettingsManager,
Expand Down
1 change: 1 addition & 0 deletions client/src/app/site/spec-picker/spec-picker.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div id="spec-picker-container" *ngIf="specManager && specManager.selectedSpecGroup">
<div id="spec-picker-shield" *ngIf="isUpdating || shieldEnabled" [class.spec-picker-shield-menu]="isOpenedFromMenu"></div>

<!-- TODO(michinoy): Switch to using GroupTabs control (WI #3158544)-->
<nav id="spec-group-tabs" role="tablist" #specGroupTabs>
<div *ngFor="let specGroup of specManager.specGroups"
(click)="selectGroup(specGroup)"
Expand Down

0 comments on commit 0a41616

Please sign in to comment.