Skip to content

Commit

Permalink
Merged PR 205: Merge ux to master
Browse files Browse the repository at this point in the history
Related work items: #13382
  • Loading branch information
Kees Verhaar authored and chrismason committed Jun 13, 2017
2 parents fc02767 + 7e40e4b commit 43398f7
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,20 @@ export class BoardConfiguration {
* @param context The context of the team to initialize the board for
* @param backlog The board to initialize
*/
private async initializeBoard(context: CoreContracts.TeamContext, backlog: WorkContracts.CategoryConfiguration) {
private async initializeBoard(context: CoreContracts.TeamContext, backlog: WorkContracts.BacklogLevelConfiguration) {
let fakepage: JQuery = $("#fakepage");
let collectionUri: string = VSS.getWebContext().collection.uri;
let url = encodeURI(collectionUri + context.project + "/" + context.team + "/_backlogs/board/" + backlog.name);

let workClient: WorkClient.WorkHttpClient2_3 = WorkClient.getClient();
let teamSettings = await workClient.getTeamSettings(context);

let backlogVisible: boolean = teamSettings.backlogVisibilities[backlog.referenceName];
let backlogVisible: boolean = teamSettings.backlogVisibilities[backlog.id];
if (backlogVisible === false) {
// If the backlog is not visible, we won't be able to fake the displaying of it. So, we'll temporarily enable it.
console.log("Temporarily enabling backlog " + backlog.referenceName + " for team " + context.team);
console.log("Temporarily enabling backlog " + backlog.id + " for team " + context.team);
let backlogVisibilities: { [key: string]: boolean } = {};
backlogVisibilities[backlog.referenceName] = true;
backlogVisibilities[backlog.id] = true;

let updateSettings: WorkContracts.TeamSettingsPatch = {
backlogIteration: null,
Expand All @@ -210,9 +210,9 @@ export class BoardConfiguration {

if (backlogVisible === false) {
// If the backlog was not visible, we'll hide it again.
console.log("Disabling backlog " + backlog.referenceName + " for team " + context.team);
console.log("Disabling backlog " + backlog.id + " for team " + context.team);
let backlogVisibilities: { [key: string]: boolean } = {};
backlogVisibilities[backlog.referenceName] = false;
backlogVisibilities[backlog.id] = false;

let updateSettings: WorkContracts.TeamSettingsPatch = {
backlogIteration: null,
Expand All @@ -239,15 +239,15 @@ export class BoardConfiguration {
};

let boardCards: WorkContracts.BoardCardSettings[] = new Array();
let process = await workClient.getProcessConfiguration(context.project);
let allBacklogs: WorkContracts.CategoryConfiguration[] = [];
allBacklogs = process.portfolioBacklogs;
let backlogs = await workClient.getBacklogConfigurations(context);
let allBacklogs: WorkContracts.BacklogLevelConfiguration[] = [];
allBacklogs = backlogs.portfolioBacklogs;
// allBacklogs = process.portfolioBacklogs.filter(b => b.name === "Epics");
allBacklogs.push(process.requirementBacklog);
allBacklogs.push(backlogs.requirementBacklog);
try {
for (let backlogIndex = 0; backlogIndex < allBacklogs.length; backlogIndex++) {
let backlog = allBacklogs[backlogIndex];
console.log("Getting settings for board " + backlog.name + " (" + backlog.referenceName + ") of team " + context.team);
console.log("Getting settings for board " + backlog.name + " (" + backlog.id + ") of team " + context.team);
let success: boolean = false;
let tries: number = 0;
let board: WorkContracts.Board = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ export class CopySettingsWizard {

// Create the required pages
this._workItemMappingPage = new WorkItemMappingPage();
this._workItemMappingPage.OnMappingValidated = ((validationResult) => {
this._workItemMappingPage.OnMappingValidated = ((validationResult, failedBacklog) => {
this._navigationControl.setButtonState(NavigationControl.NavigationButtonType.NEXT, { isEnabled: validationResult, isVisible: true });

if (!validationResult) {
this._showError(`Mapping for backlog "${failedBacklog}" is invalid. Please correct the configured mapping.`);
} else {
this._hideError();
}
});

// Create the navigation control
Expand Down Expand Up @@ -150,6 +156,11 @@ export class CopySettingsWizard {
_errorMessageBar.show();
}

private _hideError() {
let _errorMessageBar: JQuery = $("#errorMessageBar");
_errorMessageBar.hide();
}

/**
* Event called when a new option setting is selected.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta charset="UTF8">
<title>Import Export Kanban</title>
<script src="../libs/VSS.SDK.min.js"></script>
<script src="../libs/q.js"></script>
<script src="../libs/ai.0.js"></script>
</head>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import WorkContracts = require("TFS/Work/Contracts");
import * as tc from "TelemetryClient";
import telemetryClientSettings = require("../telemetryClientSettings");

import { BoardConfiguration, IBoardColumnDifferences } from "../board_configuration";
import { BoardConfiguration, IBoardColumnDifferences, IBoardSettings } from "../board_configuration";
import { SelectedTeam } from "../TeamSelectorControl";

// Placeholders for pure JavaScript functions
Expand All @@ -14,7 +14,7 @@ declare function initializeDropdowns(): void;

export class WorkItemMappingPage {
public RefreshBoardDifferences: boolean = true;
public OnMappingValidated: (validationResult: boolean) => void;
public OnMappingValidated: (validationResult: boolean, failedBacklog?: string) => void;

private _boardDifferences: IBoardColumnDifferences[];

Expand All @@ -37,25 +37,46 @@ export class WorkItemMappingPage {

let waitControl = Controls.create(StatusIndicator.WaitControl, rootContainer, waitControlOptions);

waitControl.startWait();
if (this.RefreshBoardDifferences) {
waitControl.startWait();

this.RefreshBoardDifferences = false;
let boardService = new BoardConfiguration();
let sourceSettings: IBoardSettings;
let targetSettings: IBoardSettings;

try {
let sourceSettings = await boardService.getCurrentConfigurationAsync(sourceTeam.team.name);
let targetSettings = await boardService.getCurrentConfigurationAsync(destinationTeam.team.name);
sourceSettings = await boardService.getCurrentConfigurationAsync(sourceTeam.team.name);
targetSettings = await boardService.getCurrentConfigurationAsync(destinationTeam.team.name);
} catch (e) {
console.log(`Failed getting source or target board settings: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed getting source or target board settings: ${e.message}`);
throw e;
} finally {
waitControl.endWait();
}

try {
this._boardDifferences = boardService.getTeamColumnDifferences(sourceSettings, targetSettings);
console.log(this._boardDifferences);
} catch (e) {
console.log(`Failed getting board differences: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed getting board differences: ${e.message}`);
throw e;
} finally {
waitControl.endWait();
}

try {
this._createBacklogPivots();
} catch (e) {
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(e.message);
console.log(`Failed to create backlog pivots: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed to create backlog pivots: ${e.message}`);
throw e;
} finally {
waitControl.endWait();
}
} else {
// this._createBacklogPivots();
}
waitControl.endWait();
}

public GetBoardMappings(): IBoardColumnDifferences[] {
Expand All @@ -73,17 +94,38 @@ export class WorkItemMappingPage {
let $pivotContainer = $("#pivot-container");

this._boardDifferences.forEach((difference, index, allDifferences) => {
let $menu = this._createPivotHeader(difference.backlog);
if (index === 0) {
$menu.addClass("is-selected");
}
console.log(`Creating pivot for backlog ${difference.backlog}`);
try {
let $menu = this._createPivotHeader(difference.backlog);
if (index === 0) {
$menu.addClass("is-selected");
}

let $content = this._createPivotContent(difference);
$menu.appendTo($pivotMenu);
$content.appendTo($pivotContainer);
let $content = this._createPivotContent(difference);
$menu.appendTo($pivotMenu);
$content.appendTo($pivotContainer);
} catch (e) {
console.log(`Failed creating pivot for backlog ${difference.backlog}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed to create pivot for backlog ${difference.backlog}: ${e.message}`);
throw e;
}
});
initializePivots();
initializeDropdowns();

try {
initializePivots();
} catch (e) {
console.log(`Failed initializing pivots: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed initializing pivots: ${e.message}`);
throw e;
}

try {
initializeDropdowns();
} catch (e) {
console.log(`Failed initializing dropdowns: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Failed to initialize dropdowns: ${e.message}`);
throw e;
}
}

/**
Expand Down Expand Up @@ -144,7 +186,13 @@ export class WorkItemMappingPage {
.text(differences.mappings[index].targetColumn.name)
.appendTo($left);
let $right = $("<div />").addClass("ms-Grid-col ms-u-sm6 ms-u-md6");
this._createDropdown(differences.backlog, differences.mappings[index].targetColumn.id, differences.mappings[index].potentialMatches).appendTo($right);
try {
this._createDropdown(differences.backlog, differences.mappings[index].targetColumn.id, differences.mappings[index].potentialMatches).appendTo($right);
} catch (e) {
console.log(`Error creating dropdown for target column ${differences.mappings[index].targetColumn.name} of board ${differences.backlog}: ${e}`);
tc.TelemetryClient.getClient(telemetryClientSettings.settings).trackException(`Error creating dropdown for target column ${differences.mappings[index].targetColumn.name} of board ${differences.backlog}: ${e.message}`);
throw e;
}
$left.appendTo($row);
$right.appendTo($row);
$row.appendTo($grid);
Expand All @@ -165,9 +213,14 @@ export class WorkItemMappingPage {
// $("<label />").addClass("ms-Label").text("").appendTo($div);
$("<i />").addClass("ms-Dropdown-caretDown ms-Icon ms-Icon--ChevronDown").appendTo($div);
let $select = $("<select />").addClass("ms-Dropdown-select");
options.forEach(item => {
$("<option />").val(item.id).text(item.name).appendTo($select);
});
if (options.length > 0) {
options.forEach(item => {
$("<option />").val(item.id).text(item.name).appendTo($select);
});
} else {
// Add an empty option
$("<option />").appendTo($select);
}
$select.change({backlog: backlog, targetColumnId: targetColumnId}, (e) => {
let value = $(e.target).val();
let text = $(e.target).find(":selected").text();
Expand Down Expand Up @@ -199,7 +252,7 @@ export class WorkItemMappingPage {
let currentMapping = mappingsForCurrentBoard[currentMappingIndex];
if ( currentMapping.sourceColumn === undefined || currentMapping.targetColumn === undefined ) {
console.log("Mapping for board " + this._boardDifferences[currentBoardIndex].backlog + " is invalid!");
this.OnMappingValidated(false);
this.OnMappingValidated(false, this._boardDifferences[currentBoardIndex].backlog);
return false;
}
}
Expand Down

0 comments on commit 43398f7

Please sign in to comment.