Skip to content

Commit

Permalink
Dashboard: code clean-up (#7384)
Browse files Browse the repository at this point in the history
* code clean-up

make typescript files from src/components/* compliant to typescript
and project's tslint rules

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>

* fixup! code clean-up
  • Loading branch information
akurinnoy authored Nov 16, 2017
1 parent 9f27440 commit a4b0a78
Show file tree
Hide file tree
Showing 125 changed files with 1,692 additions and 1,599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class CheAPIBuilder {
* The Che Profile builder
* @returns {CheProfileBuilder}
*/
getProfileBuilder() {
getProfileBuilder(): CheProfileBuilder {
return new CheProfileBuilder();
}

Expand Down
30 changes: 15 additions & 15 deletions dashboard/src/components/api/builder/che-profile-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,61 +17,62 @@
*/
export class CheProfileBuilder {

private profile: che.IProfile;

/**
* Default constructor.
*/
constructor() {
this.profile = {};
this.profile = {} as che.IProfile;
this.profile.attributes = {};
}


/**
* Sets the email of the user
* @param email the email to use
* @param {string} email the email to use
* @returns {CheProfileBuilder}
*/
withEmail(email) {
withEmail(email: string): CheProfileBuilder {
this.profile.email = email;
return this;
}

/**
* Sets the firstName of the user
* @param firstName the firstName to use
* @param {string} firstName the firstName to use
* @returns {CheProfileBuilder}
*/
withFirstName(firstName) {
withFirstName(firstName: string): CheProfileBuilder {
return this.withAttribute('firstName', firstName);
}

/**
* Sets the lastName of the user
* @param lastName the lastName to use
* @param {string} lastName the lastName to use
* @returns {CheProfileBuilder}
*/
withLastName(lastName) {
withLastName(lastName: string): CheProfileBuilder {
return this.withAttribute('lastName', lastName);
}

/**
* Sets the id of the profile
* @param id the id to use
* @param {string} id the id to use
* @returns {CheProfileBuilder}
*/
withId(id) {
this.profile.id = id;
withId(id: string): CheProfileBuilder {
this.profile.userId = id;
return this;
}

/**
* Sets an attribute on the profile
* @param name the attribute name
* @param name the attribute value
* @param {string} name the attribute name
* @param {string} value the attribute value
* @returns {CheProfileBuilder}
*/
withAttribute(name, value) {
withAttribute(name: string, value: string): CheProfileBuilder {
this.profile.attributes[name] = value;
return this;
}
Expand All @@ -81,9 +82,8 @@ export class CheProfileBuilder {
* Build the user
* @returns {CheProfileBuilder.profile|*}
*/
build() {
build(): che.IProfile {
return this.profile;
}


}
36 changes: 12 additions & 24 deletions dashboard/src/components/api/builder/che-projectdetails-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,76 +16,64 @@
*/
export class CheProjectDetailsBuilder {

private projectDetails: che.IProjectTemplate;

/**
* Default constructor.
*/
constructor() {
this.projectDetails = {};
this.projectDetails.creationDate = new Date().getTime();
this.projectDetails.modificationDate = new Date().getTime();
this.projectDetails = {} as che.IProjectTemplate;
this.projectDetails.mixins = [];
this.projectDetails.problems = [];
this.projectDetails.description = '';
}

/**
* Sets workspaceId
* @param workspaceId the workspace ID
* @param {string} workspaceId the workspace ID
* @returns {CheProjectDetailsBuilder}
*/
withWorkspaceId(workspaceId) {
withWorkspaceId(workspaceId: string): CheProjectDetailsBuilder {
this.projectDetails.workspaceId = workspaceId;
return this;
}

/**
* Sets workspaceName
* @param workspaceName the workspace name
* @param {string} workspaceName the workspace name
* @returns {CheProjectDetailsBuilder}
*/
withWorkspaceName(workspaceName) {
withWorkspaceName(workspaceName: string): CheProjectDetailsBuilder {
this.projectDetails.workspaceName = workspaceName;
return this;
}

/**
* Sets Name
* @param Name the project's name
* @param {string} name the project's name
* @returns {CheProjectDetailsBuilder}
*/
withName(name) {
withName(name: string): CheProjectDetailsBuilder {
this.projectDetails.name = name;
return this;
}

/**
* Sets permissions
* @param permissions the project's permissions
* @returns {CheProjectDetailsBuilder}
*/
withPermissions(permissions) {
this.projectDetails.permissions = permissions;
return this;
}

/**
* Sets type
* @param type the project's type
* @param {string} type the project's type
* @returns {CheProjectDetailsBuilder}
*/
withType(type) {
withType(type: string): CheProjectDetailsBuilder {
this.projectDetails.type = type;
return this;
}


/**
* Build the project details
* @returns {CheProjectDetailsBuilder.projectDetails|*}
*/
build() {
build(): che.IProjectTemplate {
return this.projectDetails;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ describe('CheProjectReferenceBuilder', function(){
/**
* For creating builders.
*/
var apiBuilder;
let apiBuilder;

/**
* setup module
*/
beforeEach(angular.mock.module('userDashboard'));


/**
* Inject builder
*/
Expand All @@ -39,17 +38,14 @@ describe('CheProjectReferenceBuilder', function(){
*/
it('check builder', function() {

var projectReferenceBuilder = apiBuilder.getProjectReferenceBuilder();

var name = 'myProject';
var projectReference = projectReferenceBuilder.withName(name).build();
const projectReferenceBuilder = apiBuilder.getProjectReferenceBuilder();

const name = 'myProject';
const projectReference = projectReferenceBuilder.withName(name).build();

// check values
expect(projectReference.name).toEqual(name);

});



});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @author Florent Benoit
*/
export class CheProjectReferenceBuilder {
private projectReference: any;

/**
* Default constructor.
Expand All @@ -23,13 +24,12 @@ export class CheProjectReferenceBuilder {
this.projectReference = {};
}


/**
* Sets the name of the project reference
* @param name the name to use
* @param {string} name the name to use
* @returns {CheProjectReferenceBuilder}
*/
withName(name) {
withName(name: string): CheProjectReferenceBuilder {
this.projectReference.name = name;
return this;
}
Expand All @@ -38,10 +38,9 @@ export class CheProjectReferenceBuilder {
* Build the project reference
* @returns {CheProjectReferenceBuilder.projectReference|*}
*/
build() {
build(): CheProjectReferenceBuilder {
return this.projectReference;
}


}

25 changes: 13 additions & 12 deletions dashboard/src/components/api/builder/che-projecttemplate-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,49 @@
*/
export class CheProjectTemplateBuilder {

constructor() {
this.template = {};
this.template.source = {};
this.template.config = {};
template: che.IProjectTemplate;

constructor() {
this.template = {} as che.IProjectTemplate;
this.template.source = {} as che.IProjectSource;
}
withDescription(desc) {

withDescription(desc: string): CheProjectTemplateBuilder {
this.template.description = desc;
return this;
}

withSourceParameters(parameters) {
withSourceParameters(parameters: {[paramName: string]: string}): CheProjectTemplateBuilder {
this.template.source.parameters = parameters;
return this;
}

withSourceType(type) {
withSourceType(type: string): CheProjectTemplateBuilder {
this.template.source.type = type;
return this;
}

withSourceLocation(location) {
withSourceLocation(location: string): CheProjectTemplateBuilder {
this.template.source.location = location;
return this;
}

withDisplayname(name) {
withDisplayname(name: string): CheProjectTemplateBuilder {
this.template.displayName = name;
return this;
}

withCategory(category) {
withCategory(category: string): CheProjectTemplateBuilder {
this.template.category = category;
return this;
}

withProjectType(projectType) {
withProjectType(projectType: string): CheProjectTemplateBuilder {
this.template.projectType = projectType;
return this;
}

build() {
build(): che.IProjectTemplate {
return this.template;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,40 @@
*/
export class CheProjectTypeAttributeDescriptorBuilder {

private attribute: any;

constructor() {
this.attribute = {};
this.attribute.values = [];
}

withName(name) {
withName(name: string): CheProjectTypeAttributeDescriptorBuilder {
this.attribute.name = name;
return this;
}

withRequired(required) {
withRequired(required: boolean): CheProjectTypeAttributeDescriptorBuilder {
this.attribute.required = required;
return this;
}

withVariable(variable) {
withVariable(variable: any): CheProjectTypeAttributeDescriptorBuilder {
this.attribute.variable = variable;
return this;
}

withDescription(description) {
withDescription(description: string): CheProjectTypeAttributeDescriptorBuilder {
this.attribute.description = description;
return this;
}

withValues(values) {
withValues(values: any): CheProjectTypeAttributeDescriptorBuilder {
this.attribute.values = values;
return this;
}

build() {
build(): any {
return this.attribute;
}


}
Loading

0 comments on commit a4b0a78

Please sign in to comment.