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: Task user identity #640

Merged
merged 3 commits into from
Aug 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Launch",
"type": "node",
"request": "launch",
"protocol": "inspector",
"protocol": "legacy",
"program": "${workspaceRoot}/src/client/main.ts",
"stopOnEntry": false,
"args": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TaskCreateBasicDialogComponent extends DynamicForm<Task, TaskCreate
displayName: ["", Validators.maxLength(validation.maxLength.displayName)],
commandLine: ["", Validators.required],
constraints: this.constraintsGroup,
runElevated: ["0"],
userIdentity: [null],
fileGroups: [[]],
resourceFiles: [[]],
environmentSettings: [[]],
Expand Down
32 changes: 19 additions & 13 deletions app/components/task/action/add/task-create-basic-dialog.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<bl-complex-form [formGroup]="form" [submit]="submit" [containerRef]="sidebarRef" [multiUse]="multiUse" [actionName]="actionName">
<bl-form-page main-form-page [title]="title" [formGroup]="form">
<bl-form-section title="General info" subtitle="Basic information about the task">
<div class="form-element">
<md-input-container>
<input mdInput formControlName="id" placeholder="Id">
</md-input-container>
<bl-error controlName="id" code="required">Id is a required field</bl-error>
<bl-error controlName="id" code="maxlength">Id has a maximum length of 64 characters</bl-error>
<bl-error controlName="id" code="pattern">Id can contain any combination of alphanumeric characters including hyphens and underscores</bl-error>
</div>
<div class="grow">
<div class="gcol">
<md-input-container class="form-element">
<input mdInput formControlName="id" placeholder="Id">
</md-input-container>
<bl-error controlName="id" code="required">Id is a required field</bl-error>
<bl-error controlName="id" code="maxlength">Id has a maximum length of 64 characters</bl-error>
<bl-error controlName="id" code="pattern">Id can contain any combination of alphanumeric characters including hyphens and underscores</bl-error>
</div>

<div class="form-element">
<md-input-container>
<input mdInput formControlName="displayName" placeholder="Display name">
</md-input-container>
<bl-error controlName="displayName" code="maxlength">Display name has a maximum length of 1024 characters</bl-error>
<div class="gcol">
<md-input-container class="form-element">
<input mdInput formControlName="displayName" placeholder="Display name">
</md-input-container>
<bl-error controlName="displayName" code="maxlength">Display name has a maximum length of 1024 characters</bl-error>
</div>
</div>

<div class="form-element">
Expand All @@ -32,6 +34,10 @@
<bl-error controlName="maxTaskRetryCount" code="validateRange">Retry count values can range from -1 to 100</bl-error>
</div>
</div>
<div class="form-element pad-top">
<bl-user-identity-picker formControlName="userIdentity" [userAccounts]="userAccounts">
</bl-user-identity-picker>
</div>
</bl-form-section>

<bl-form-section title="Resource files" subtitle="List of files to be used by this task">
Expand Down
2 changes: 1 addition & 1 deletion app/components/task/details/task-configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<bl-text-property label="Previous State" [value]="decorator.previousState"></bl-text-property>
<bl-text-property label="Creation Time" [value]="decorator.creationTime"></bl-text-property>
<bl-text-property label="Last modified" [value]="decorator.lastModified"></bl-text-property>
<bl-bool-property label="Run elevated" [value]="task.runElevated" yesNo="true"></bl-bool-property>
<bl-text-property label="User identity" [value]="decorator.userIdentitySummary"></bl-text-property>
<bl-text-property label="State transition time" [value]="decorator.stateTransitionTime"></bl-text-property>
<bl-text-property label="Previous state transition time" [value]="decorator.previousStateTransitionTime"></bl-text-property>
<bl-text-property label="Exit conditions" *ngIf="!task.exitConditions" value="None"></bl-text-property>
Expand Down
28 changes: 25 additions & 3 deletions app/models/decorators/task-decorator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Task, TaskState } from "app/models";
import { AutoUserScope, Task, TaskState, UserAccountElevationLevel } from "app/models";
import { DecoratorBase } from "app/utils/decorators";
import { ComputeNodeInfoDecorator } from "./compute-node-info-decorator";
import { TaskConstraintsDecorator } from "./task-constraints-decorator";
Expand All @@ -16,7 +16,6 @@ export class TaskDecorator extends DecoratorBase<Task> {
public previousState: string;
public previousStateTransitionTime: string;
public commandLine: string;
public runElevated: boolean;
public successExitCodes: string;

public exitConditions: {};
Expand All @@ -30,6 +29,7 @@ export class TaskDecorator extends DecoratorBase<Task> {
public stats: {};
public dependsOn: {};
public applicationPackageReferences: any[];
public userIdentitySummary: string;

constructor(task: Task) {
super(task);
Expand All @@ -45,7 +45,6 @@ export class TaskDecorator extends DecoratorBase<Task> {
this.previousState = this.stateField(task.previousState);
this.previousStateTransitionTime = this.dateField(task.previousStateTransitionTime);
this.commandLine = this.stringField(task.commandLine);
this.runElevated = task.runElevated;

this.exitConditions = task.exitConditions || {};
this.resourceFiles = task.resourceFiles || {};
Expand All @@ -58,6 +57,8 @@ export class TaskDecorator extends DecoratorBase<Task> {
this.stats = task.stats || {};
this.dependsOn = task.dependsOn || {};
this.applicationPackageReferences = task.applicationPackageReferences || [];

this._initUserIdentity();
}

private _getStateIcon(state: TaskState): string {
Expand All @@ -73,4 +74,25 @@ export class TaskDecorator extends DecoratorBase<Task> {
return "fa-question-circle-o";
}
}

private _initUserIdentity() {
const userIdentity = this.original.userIdentity;
let value;
if (!userIdentity || (!userIdentity.userName && !userIdentity.autoUser)) {
value = "Task user";
} else if (userIdentity.autoUser) {
const isAdmin = userIdentity.autoUser.elevationLevel === UserAccountElevationLevel.admin;
const isPoolScope = userIdentity.autoUser.scope === AutoUserScope.pool;
const scope = isPoolScope ? "Pool default user" : "Task default user";
if (isAdmin) {
value = `${scope} (Admin)`;
} else {
value = scope;
}
} else {
value = userIdentity.userName;
}

this.userIdentitySummary = value;
}
}
2 changes: 1 addition & 1 deletion app/models/dtos/task-create.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class TaskCreateDto extends Dto<TaskCreateDto> {
public constraints?: ConstraintDto;

@DtoAttr()
public runElevated?: boolean;
public userIdentity?: any;

@DtoAttr()
public multiInstanceSettings?: any;
Expand Down
7 changes: 3 additions & 4 deletions app/models/forms/create-task-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface CreateTaskModel {
environmentSettings: any[];
affinityInfo: any;
constraints: TaskConstraintsModel;
runElevated: boolean;
userIdentity: any;
multiInstanceSettings: any;
applicationPackageReferences: any[];
}
Expand All @@ -36,7 +36,7 @@ export function createTaskFormToJsonData(formData: CreateTaskModel): any {
maxTaskRetryCount: formData.constraints.maxTaskRetryCount,
retentionTime: retentionTime,
},
runElevated: formData.runElevated,
userIdentity: formData.userIdentity,
multiInstanceSettings: null,
applicationPackageReferences: null,
};
Expand All @@ -53,8 +53,7 @@ export function taskToFormModel(task: TaskCreateDto): CreateTaskModel {
resourceFiles: task.resourceFiles,
environmentSettings: task.environmentSettings,
affinityInfo: task.affinityInfo,

runElevated: task.runElevated,
userIdentity: task.userIdentity,
multiInstanceSettings: task.multiInstanceSettings,
applicationPackageReferences: task.applicationPackageReferences,
};
Expand Down
3 changes: 2 additions & 1 deletion app/models/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { TaskDependencies } from "./task-dependencies";
import { TaskExecutionInformation } from "./task-execution-information";
import { TaskExitConditions } from "./task-exit-conditions";
import { TaskOutputFile } from "./task-output-file";
import { UserIdentity } from "./user-identity";

export interface TaskAttributes {
id: string;
Expand Down Expand Up @@ -55,7 +56,7 @@ export class Task extends Record<TaskAttributes> {
@Prop() public previousState: TaskState;
@Prop() public previousStateTransitionTime: Date;
@Prop() public commandLine: string;
@Prop() public runElevated: boolean;
@Prop() public userIdentity: UserIdentity;
@Prop() public exitConditions: TaskExitConditions = new TaskExitConditions();
@ListProp(ResourceFile) public resourceFiles: List<ResourceFile> = List([]);
@ListProp(TaskOutputFile) public outputFiles: List<TaskOutputFile> = List([]);
Expand Down