Dashboard: removed Create Project page and related components (#6911)

* move components

projects/create-project/samples/create-project-samples-tag.filter -> stacks/stack-details/select-template/create-project-samples-tag.filter

projects/project-details/project-details.controller -> /workspaces/workspace-details/workspace-projects/project-details/project-details.controller
projects/project-details/project-details.html -> /workspaces/workspace-details/workspace-projects/project-details/project-details.html
projects/project-details/project-details.styl -> /workspaces/workspace-details/workspace-projects/project-details/project-details.styl

projects/project-details/repository/project-repository-config/* -> /workspaces/workspace-details/workspace-projects/project-details/repository/project-repository-config/*

projects/list-projects/project-item/* -> /workspaces/workspace-details/workspace-projects/project-item/*

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

* code clean-up

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

* remove Create Project page and related components

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

* fix bug which happens during adding a project on Workspace details page

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
6.19.x
Oleksii Kurinnyi 2017-10-30 10:17:03 +02:00 committed by GitHub
parent 0e4ffb7f87
commit af01dfb2d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 203 additions and 3285 deletions

View File

@ -24,7 +24,6 @@ import {DashboardConfig} from './dashboard/dashboard-config';
// switch to a config
import {IdeConfig} from './ide/ide-config';
import {NavbarConfig} from './navbar/navbar-config';
import {ProjectsConfig} from './projects/projects-config';
import {ProxySettingsConfig} from './proxy/proxy-settings.constant';
import {WorkspacesConfig} from './workspaces/workspaces-config';
import {StacksConfig} from './stacks/stacks-config';
@ -409,7 +408,6 @@ new IdeConfig(instanceRegister);
new DiagnosticsConfig(instanceRegister);
new NavbarConfig(instanceRegister);
new ProjectsConfig(instanceRegister);
new WorkspacesConfig(instanceRegister);
new DashboardConfig(instanceRegister);
new StacksConfig(instanceRegister);

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {CheWorkspace} from '../../../../components/api/workspace/che-workspace.factory';
/**
* This class is handling the controller for the add secret key error notification
* @author Oleksii Orel
*/
export class AddSecretKeyNotificationController {
repoURL: string;
workspaceId: string;
workspace: che.IWorkspace;
private $mdDialog: ng.material.IDialogService;
private $location: ng.ILocationService;
/**
* Default constructor.
* @ngInject for Dependency injection
*/
constructor($mdDialog: ng.material.IDialogService, $location: ng.ILocationService, cheWorkspace: CheWorkspace) {
this.$mdDialog = $mdDialog;
this.$location = $location;
this.workspace = cheWorkspace.getWorkspacesById().get(this.workspaceId);
}
/**
* Redirect to IDE preferences.
*/
redirectToConfig(): void {
this.$location.path('ide/' + this.workspace.namespace + '/' + this.workspace.config.name).search({action: 'showPreferences'});
this.$mdDialog.hide();
}
/**
* Callback of the cancel button of the dialog.
*/
hide(): void {
this.$mdDialog.hide();
}
}

View File

@ -1,14 +0,0 @@
<che-popup title="Cannot clone the repository" on-close="addSecretKeyNotificationController.hide()">
<div>
<div class="ssh-key-notification">
This repository requires an SSH key that is not configured: <b>{{addSecretKeyNotificationController.repoURL}}</b>.
</div>
<che-button-notice che-button-title="Close"
ng-click="addSecretKeyNotificationController.hide()">
</che-button-notice>
<che-button-primary che-button-title="Generate Key"
ng-click="addSecretKeyNotificationController.redirectToConfig()"
ng-disabled="!addSecretKeyNotificationController.workspace">
</che-button-primary>
</div>
</che-popup>

View File

@ -1,4 +0,0 @@
.ssh-key-notification
width 100%
margin-top 10px
min-height 30px

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for creating project from configuration file.
* @author Florent Benoit
*/
export class CreateProjectConfFile {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor ($filter) {
this.$filter = $filter;
this.restrict='E';
this.templateUrl = 'app/projects/create-project/config-file/create-project-conf-file.html';
}
/**
* watch data and update json content each time the value is updated
* @param $scope
*/
link($scope) {
// Watch data of the createProject controller and update content with these parameters
$scope.$watch('createProjectCtrl.importProjectData', (newValue) => {
$scope.createProjectCtrl.jsonConfig.content = this.$filter('json')(angular.fromJson(newValue), 2);
}, true);
}
}

View File

@ -1,24 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<form name="createProjectConfigForm">
<div class="create-project-config-panel" layout="row" flex ng-init="createProjectCtrl.setForm(createProjectConfigForm, 'config');">
<textarea ui-codemirror
id="jsonConfig"
name="jsonConfig"
ng-model="createProjectCtrl.jsonConfig.content"
ng-change="createProjectCtrl.update()"
rows="15">
</textarea>
</div>
</form>

View File

@ -1,275 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<che-toolbar che-title="New Workspace">
<che-button-primary class="create-project-header-button"
che-button-title="Create"
ng-click="!createProjectCtrl.checkValidFormState() || createProjectCtrl.create()"
ng-disabled="!createProjectCtrl.checkValidFormState() || !createProjectCtrl.isReadyToCreate()"
ng-show="!createProjectCtrl.isCreateProjectInProgress() || createProjectCtrl.getCurrentProgressStep() === (createProjectCtrl.getCreationSteps().length - 1)">
</che-button-primary>
</che-toolbar>
<md-progress-linear md-mode="indeterminate" class="projects-list-projects-progress"
ng-hide="createProjectCtrl.stacksInitialized || createProjectCtrl.workspaces.length"></md-progress-linear>
<md-content id="create-project-content-page"
md-scroll-y flex
class="projects-create-project">
<div ng-if="createProjectCtrl.isCreateProjectInProgress()">
<div id="create-project-panel" class="create-project-progress-panel">
<che-loader class="che-loader-panel" layout="column">
<!--crane and terminals-->
<div class="che-loader-animation-panel main-page" layout="row" flex>
<div layout="column"
hide-xs hide-sm
layout-align="end start">
<che-loader-crane che-all-steps="createProjectCtrl.getCreationSteps()"
che-exclude-steps="[createProjectCtrl.getCreationSteps().length-1]"
che-step="{{createProjectCtrl.getCurrentProgressStep()}}"
che-switch-on-iteration="true">
</che-loader-crane>
</div>
<div layout="column"
layout-align="center center"
flex="auto">
<che-steps-container class="create-project-working-log"
che-all-steps="createProjectCtrl.getCreationSteps()"
che-current-step="createProjectCtrl.getCurrentProgressStep()"></che-steps-container>
</div>
</div>
<!--bottom bar-->
<div class="che-loader-bottom-bar" flex="none">
<div class="main-page" layout="row" layout-align="center stretch">
<div flex="50" layout="column" layout-align="end start">
</div>
</div>
</div>
</che-loader>
</div>
</div>
<div ng-if="!createProjectCtrl.isCreateProjectInProgress()">
<!-- Select source -->
<che-label-container id="create-project-source-id"
che-label-name="Select Source"
che-label-description="Choose where the initial source code for this project will come from. The choice of templates and samples will vary by the stack chosen.">
<md-radio-group ng-model="createProjectCtrl.selectSourceOption"
ng-change="createProjectCtrl.onSourceOptionChanged()">
<md-radio-button value="select-source-new">New from blank, template, or sample project</md-radio-button>
<md-radio-button value="select-source-existing">Import from existing location</md-radio-button>
</md-radio-group>
<div ng-show="createProjectCtrl.selectSourceOption === 'select-source-existing'">
<md-tabs md-stretch-tabs="auto"
md-dynamic-height
md-no-ink-bar
md-selected="createProjectCtrl.selectedTabIndex">
<md-tab md-on-select="createProjectCtrl.setCurrentTab('git')">
<md-tab-label>
<span class="che-tab-label-title">Git Repository</span>
</md-tab-label>
<md-tab-body>
<create-project-git class="projects-create-project-tab" layout="column"></create-project-git>
</md-tab-body>
</md-tab>
<md-tab md-on-select="createProjectCtrl.setCurrentTab('github')">
<md-tab-label>
<span class="che-tab-label-title">GitHub</span>
</md-tab-label>
<md-tab-body>
<form name="createProjectGitHubForm">
<create-project-github ng-init="createProjectCtrl.setForm(createProjectGitHubForm, 'github')"
class="projects-create-project-tab"
che-form="createProjectGitHubForm"
che-repository-model="createProjectCtrl.selectedGitHubRepository"
che-repository-select="createProjectCtrl.selectGitHubRepository(createProjectCtrl.selectedGitHubRepository)"
che-is-current-tab="createProjectCtrl.getCurrentTab() === 'github'"
layout="column"></create-project-github>
</form>
</md-tab-body>
</md-tab>
<md-tab md-on-select="createProjectCtrl.setCurrentTab('zip')">
<md-tab-label>
<span class="che-tab-label-title">Zip</span>
</md-tab-label>
<md-tab-body>
<create-project-zip class="projects-create-project-tab" layout="column"></create-project-zip>
</md-tab-body>
</md-tab>
</md-tabs>
</div>
</che-label-container>
<!-- Select stack -->
<che-label-container che-label-name="{{createProjectCtrl.workspaces.length ? 'Select Workspace' : 'Select Stack'}}"
che-label-description="{{createProjectCtrl.workspaces.length ? 'Select existing workspace or create it from stack' : 'Select stack'}}, recipe or image used to define your environment runtime. Workspace environments are used to build and run your project.">
<ng-form name="workspaceResourceForm">
<md-radio-group ng-model="createProjectCtrl.workspaceResource"
ng-init="createProjectCtrl.setWorkspaceResourceForm(workspaceResourceForm)"
ng-change="createProjectCtrl.workspaceResourceOnChange()">
<!-- radio-button: existing workspace-->
<md-radio-button value="existing-workspace" ng-disabled="createProjectCtrl.workspaces.length === 0">Select existing workspace</md-radio-button>
<div ng-if="createProjectCtrl.workspaceResource === 'existing-workspace'">
<create-project-workspaces che-workspace="createProjectCtrl.workspaceSelected"
che-workspace-change="createProjectCtrl.onWorkspaceChange()"></create-project-workspaces>
</div>
<!-- radio-button: from config -->
<md-radio-button value="from-config">Create from configuration</md-radio-button>
<div ng-if="createProjectCtrl.workspaceResource === 'from-config'">
<che-workspace-config-import workspace-config="createProjectCtrl.workspaceConfig"
workspace-config-on-change="createProjectCtrl.updateWorkspaceConfigImport(config)"></che-workspace-config-import>
</div>
<!-- radio-button: from stack -->
<md-radio-button value="from-stack">Create new workspace from stack</md-radio-button>
<div ng-if="createProjectCtrl.workspaceResource === 'from-stack'">
<workspace-select-stack workspace-stack-on-change="createProjectCtrl.changeWorkspaceStack(config, stackId)"
workspace-name="createProjectCtrl.workspaceName"
environment-name=""
workspace-imported-recipe=""></workspace-select-stack>
</div>
</md-radio-group>
</ng-form>
</che-label-container>
<!-- Workspace -->
<che-label-container ng-show="createProjectCtrl.stackLibraryOption !== 'existing-workspace'"
che-label-name="Configure workspace"
che-panel-id="create-project-workspace"
che-label-description="A workspace contains projects and runtime environments. If your stack requires a new workspace, configure it here.">
<ng-form name="workspaceInformationForm">
<div class="create-project-nested-container"
ng-init="createProjectCtrl.setWorkspaceInformationForm(workspaceInformationForm)">
<che-label-container che-label-name="Name">
<div class="create-project-input">
<che-input che-form="workspaceInformationForm"
che-name="workspaceName"
che-place-holder="Name of the workspace"
aria-label="Name of the workspace"
ng-model="createProjectCtrl.workspaceName"
ng-change="createProjectCtrl.workspaceNameChange(workspaceInformationForm)"
ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 1000, 'blur': 0 } }"
required
unique-workspace-name="createProjectCtrl.existingWorkspaceName"
ng-minlength="3"
ng-maxlength="100"
ng-pattern="/^[A-Za-z0-9_\-\.]+$/">
<div ng-message="required">A name is required.</div>
<div ng-message="pattern">Workspace name may contain digits, latin letters, _ , . , - and should start
only with digits, latin
letters or underscores
</div>
<div ng-message="minlength">The name has to be more than 3 characters long.</div>
<div ng-message="maxlength">The name has to be less than 100 characters long.</div>
<div ng-message="uniqueWorkspaceName">This workspace name is already used.</div>
</che-input>
</div>
</che-label-container>
<che-label-container che-label-name="RAM">
<div data-ng-repeat="(environmentKey, environmentValue) in createProjectCtrl.workspaceConfig.environments">
<span ng-if="createProjectCtrl.getObjectKeys(createProjectCtrl.workspaceConfig.environments).length > 1"
class="workspace-environment-name">ENVIRONMENT: {{environmentKey}}</span>
<div>
<div data-ng-repeat="machine in createProjectCtrl.getStackMachines(environmentValue) as machines">
<div class="workspace-machine" ng-if="machine.attributes && machine.attributes.memoryLimitBytes">
<span ng-if="machines.length > 1">MACHINE: {{machine.name}}</span>
<che-workspace-ram-allocation-slider
ng-model="machine.attributes.memoryLimitBytes"
che-on-change="createProjectCtrl.workspaceRamChange(machine.name, machine.attributes.memoryLimitBytes)"></che-workspace-ram-allocation-slider>
</div>
</div>
</div>
</div>
</che-label-container>
</div>
</ng-form>
</che-label-container>
<!-- Template -->
<che-label-container id="create-project-source-template"
ng-show="createProjectCtrl.selectSourceOption === 'select-source-new'"
che-label-name="Template"
che-label-description="Select a code template to create a new project in the workspace.">
<md-radio-group ng-model="createProjectCtrl.templatesChoice">
<md-radio-button value="templates-samples">Ready-to-run project samples</md-radio-button>
<create-project-samples current-stack-tags="createProjectCtrl.currentStackTags"
project-sample-on-select="createProjectCtrl.projectSampleOnSelect(template)"
ng-if="createProjectCtrl.templatesChoice === 'templates-samples'"></create-project-samples>
<md-radio-button ng-if="createProjectCtrl.enableWizardProject"
ng-click="createProjectCtrl.selectWizardProject()"
value="templates-wizard">Wizard-driven templates
</md-radio-button>
</md-radio-group>
</che-label-container>
<!-- Project -->
<che-label-container che-label-name="Project Metadata"
id="create-project-source-information"
class="che-label-container-last">
<ng-form name="projectInformationForm">
<div class="create-project-nested-container"
ng-init="createProjectCtrl.setProjectInformationForm(projectInformationForm);">
<che-label-container che-label-name="Name">
<div class="create-project-input">
<che-input che-form="projectInformationForm"
che-name="name"
che-place-holder="Name of the project"
aria-label="Name of the project"
ng-model="createProjectCtrl.projectName"
required
unique-project-name="createProjectCtrl.getWorkspaceProjects()"
ng-maxlength="128"
ng-pattern="/^[A-Za-z0-9_\-\.]+$/">
<div ng-message="required">A name is required.</div>
<div ng-message="uniqueProjectName">This project name is already used.</div>
<div ng-message="pattern">The name should not contain special characters like space, dollar, etc.</div>
<div ng-message="maxlength">The name has to be less than 128 characters long.</div>
<div ng-message="md-maxlength">The name has to be less than 128 characters long.</div>
</che-input>
</div>
</che-label-container>
<che-label-container che-label-name="Description"
ng-if="createProjectCtrl.importProjectData.project.type && createProjectCtrl.importProjectData.project.type.length > 0">
<div class="create-project-input">
<che-input che-form="projectInformationForm"
che-name="description"
che-place-holder="Description of the project"
aria-label="Description of the project"
che-width="auto"
ng-model="createProjectCtrl.projectDescription"
ng-maxlength="256">
<div ng-message="maxlength">The name has to be less than 256 characters long.</div>
<div ng-message="md-maxlength">The name has to be less than 256 characters long.</div>
</che-input>
</div>
</che-label-container>
</div>
</ng-form>
</che-label-container>
<che-button-primary id="create-project-button-import"
che-button-title="Create"
ng-click="!createProjectCtrl.checkValidFormState() || createProjectCtrl.create()"
ng-disabled="!createProjectCtrl.checkValidFormState() || !createProjectCtrl.isReadyToCreate()"
class="projects-create-project-button"
></che-button-primary>
<div class="create-project-empty-space"></div>
</div>
</md-content>

View File

@ -1,144 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* This class is handling the service for the creation of projects
* @author Florent Benoit
*/
export class CreateProjectSvc {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor ($timeout, $compile, $location) {
this.$timeout = $timeout;
this.$compile = $compile;
this.$location = $location;
this.init = false;
this.ideAction = '';
this.createProjectInProgress = false;
this.currentProgressStep = 0;
this.creationSteps = [
{text: 'Creating and initializing workspace', inProgressText: 'Provision workspace and associating it with the existing user', logs: '', hasError: false},
{text: 'Starting workspace runtime', inProgressText: 'Retrieving the stack\'s image and launching it', logs: '', hasError: false},
{text: 'Starting workspace agent', inProgressText: 'Agents provide RESTful services like intellisense and SSH', logs: '', hasError: false},
{text: 'Creating project', inProgressText: 'Creating and configuring project', logs: '', hasError: false},
{text: 'Project created', inProgressText: 'Opening project', logs: '', hasError: false}
];
}
getStepText(stepNumber) {
let entry = this.creationSteps[stepNumber];
if (this.currentProgressStep >= stepNumber) {
return entry.inProgressText;
} else {
return entry.text;
}
}
getProjectCreationSteps() {
return this.creationSteps;
}
setCurrentProgressStep(currentProgressStep) {
this.currentProgressStep = currentProgressStep;
}
getCurrentProgressStep() {
return this.currentProgressStep;
}
hasInit() {
return this.init;
}
resetCreateProgress() {
this.creationSteps.forEach((step) => {
step.logs = '';
step.hasError = false;
});
this.currentProgressStep = 0;
this.createProjectInProgress = false;
}
isCreateProjectInProgress() {
return this.createProjectInProgress;
}
setCreateProjectInProgress(value) {
this.createProjectInProgress = value;
}
setWorkspaceOfProject(workspaceOfProject) {
this.workspaceOfProject = workspaceOfProject;
}
getWorkspaceOfProject() {
return this.workspaceOfProject;
}
setWorkspaceNamespace(namespace) {
this.namespace = namespace;
}
getWorkspaceNamespace() {
return this.namespace;
}
setProject(project) {
this.project = project;
}
getProject() {
return this.project;
}
hasIdeAction() {
return this.getIDEAction().length > 0;
}
getIDEAction() {
return this.ideAction;
}
setIDEAction(ideAction) {
this.ideAction = ideAction;
}
getIDELink() {
let link = '#/ide/' + this.getWorkspaceNamespace() + '/' + this.getWorkspaceOfProject();
if (this.hasIdeAction()) {
link = link + '?action=' + this.ideAction;
}
return link;
}
redirectToIDE() {
let path = '/ide/' + this.getWorkspaceNamespace() + '/' + this.getWorkspaceOfProject();
this.$location.path(path);
if (this.getIDEAction()) {
this.$location.search({'action': this.getIDEAction()});
}
}
}

View File

@ -1,81 +0,0 @@
//TODO change colors
$item-enabled-color-bg = $default-dark-color
$item-enabled-color-fg = $white-color
$item-disabled-color-bg = $clear-foggy-sky-color
$item-disabled-color-fg = $stroke-color
$item-error-color-bg = $auth-error-color
$item-output-bg = $cat-gray-color
$item-output-fg = $dark-menacing-sky-color
che-button-primary#create-project-button-import button
margin 30px 0 100px
font-size 1.2em
width 100% !important
.create-project-box md-icon
font-size 24px
md-select.create-project-select
width 100%
margin-top 0
margin-bottom 0
.projects-create-project > md-card:first-child .che-panel-content
padding 0
.projects-create-project > md-card:first-child md-tabs-content-wrapper
padding-left 24px
padding-right 24px
padding-bottom 25px
.create-project-progress-panel
margin-left 24px
margin-top 32px
margin-bottom 10px
margin-right 24px
background-color #fff
box-shadow 0 2px 6px 0 rgba(0, 0, 0, 0.4)
.create-project-header-button .che-button
font-size 15px !important
box-shadow 0 0 0 0 rgba(0, 0, 0, 0.26) !important
.create-project-minimize-icon
font-size 40px
cursor pointer
outline none
.stack-label-info
color $label-info-color
margin-bottom 12px
margin-top 7px
.create-project-progress-panel .che-loader-animation-panel
border none !important
.create-project-working-log
margin-top 35px
.create-project-download-logs-link
margin-right 8px
.projects-create-project
padding 0 14px
md-tabs
min-height 185px
.che-label-container-content .create-project-input
margin -6px 0
.che-label-container-content .create-project-nested-container
margin -25px 0
.workspace-environment-name + div
margin-top 8px
.workspace-machine
margin-left 45px
.che-ram-allocation-slider .slider-wrapper
margin-bottom -15px

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* This class is handling the controller for the git part
* @author Florent Benoit
*/
export class CreateProjectGitController {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor() {
this.focus = false;
}
/**
* Input for setting the GIT URL gets the focus
*/
setFocus() {
this.focus = true;
}
/**
* Input for setting the GIT URL losts the focus
*/
lostFocus() {
this.focus = false;
}
}

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for creating project from git.
* @author Florent Benoit
*/
export class CreateProjectGit {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor() {
this.controller = 'CreateProjectGitController';
this.controllerAs = 'createProjectGitCtrl';
this.bindToController = true;
this.restrict = 'E';
this.templateUrl = 'app/projects/create-project/git/create-project-git.html';
}
/**
* Watch the data and update project name if location is updated
* @param $scope
*/
link($scope) {
// Watch data of the createProject controller and update project name
$scope.$watch('createProjectCtrl.importProjectData', (newValue) => {
if ('git' !== $scope.createProjectCtrl.currentTab) {
return;
}
// no focus, abort
if (!$scope.createProjectGitCtrl.focus) {
return;
}
// get current url
var uri = newValue.source.location;
if (!uri || uri === '') {
return;
}
// search if repository is ending with . (for example .git) or the last name
var indexFinishProjectName = uri.lastIndexOf('.');
var indexStartProjectName;
if (uri.lastIndexOf('/') !== -1) {
indexStartProjectName = uri.lastIndexOf('/') + 1;
} else {
indexStartProjectName = uri.lastIndexOf(':') + 1;
}
var name;
// extract name with .../dummy.git
if (indexStartProjectName !== 0 && indexStartProjectName < indexFinishProjectName) {
name = uri.substring(indexStartProjectName, indexFinishProjectName);
} else if (indexStartProjectName !== 0) {
// extract ...../dummy
name = uri.substring(indexStartProjectName);
} else {
// unable to do something
name = '';
}
// able to extract something, change it
if (name !== '') {
$scope.createProjectCtrl.importProjectData.project.name = name;
}
}, true);
}
}

View File

@ -1,33 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<form name="createProjectGitForm" class="create-project-git">
<div layout="row" flex ng-init="createProjectCtrl.setForm(createProjectGitForm, 'git')"></div>
<che-label-container che-label-name="Git URL">
<div class="create-project-git-input">
<che-input che-form="createProjectGitForm"
che-name="remoteGitURL"
che-place-holder="Url of the git repository"
aria-label="Url of the git repository"
che-width="auto"
ng-focus="$parent.createProjectGitCtrl.setFocus()"
ng-blur="$parent.createProjectGitCtrl.lostFocus()"
ng-model="createProjectCtrl.importProjectData.source.location"
git-url
required>
<div ng-message="gitUrl">Invalid Git URL</div>
<div ng-message="required">A repository URL is required.</div>
</che-input>
</div>
</che-label-container>
</form>

View File

@ -1,6 +0,0 @@
.create-project-git
.che-label-container
padding-bottom 0
.che-label-container-content .create-project-git-input
margin -6px 0

View File

@ -1,209 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* This class is handling the controller for the GitHub part
* @author Stéphane Daviet
* @author Florent Benoit
*/
export class CreateProjectGithubController {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor (cheAPI, $rootScope, $http, $q, $window, $mdDialog, $location, $browser, $filter, GitHub, githubPopup, gitHubTokenStore,
cheBranding, githubOrganizationNameResolver, $timeout, $scope) {
this.cheAPI = cheAPI;
this.$http = $http;
this.$rootScope = $rootScope;
this.$q = $q;
this.$window = $window;
this.$mdDialog = $mdDialog;
this.$location = $location;
this.$browser = $browser;
this.$filter = $filter;
this.GitHub = GitHub;
this.gitHubTokenStore = gitHubTokenStore;
this.githubPopup = githubPopup;
this.cheBranding = cheBranding;
this.githubOrganizationNameResolver = githubOrganizationNameResolver;
this.$timeout = $timeout;
this.productName = cheBranding.getName();
this.profile = cheAPI.getProfile().getProfile();
this.currentTokenCheck = null;
this.resolveOrganizationName = this.githubOrganizationNameResolver.resolve;
this.organizations = [];
this.gitHubRepositories = [];
this.state = 'IDLE';
this.isGitHubOAuthProviderAvailable = false;
let oAuthProviderPromise = this.cheAPI.getOAuthProvider().fetchOAuthProviders().then(() => {
this.isGitHubOAuthProviderAvailable = this.cheAPI.getOAuthProvider().isOAuthProviderRegistered('github');
});
let tabOpenDefer = this.$q.defer();
$scope.$watch(() => {return this.isCurrentTab;}, (isVisible) => {
if (isVisible) {
tabOpenDefer.resolve();
}
});
// check token validity and load repositories
this.$q.all([
oAuthProviderPromise,
tabOpenDefer.promise,
this.profile.$promise
]).then(() => {
if (this.isGitHubOAuthProviderAvailable) {
this.currentUserId = this.profile.userId;
this.askLoad();
} else {
this.state = 'NO_REPO';
}
});
}
askLoad() {
this.state = 'LOADING';
this.checkTokenValidity().then(() => {
this.loadRepositories();
}).catch(() => {
this.state = 'NO_REPO';
});
}
authenticateWithGitHub() {
if (!this.isGitHubOAuthProviderAvailable) {
this.$mdDialog.show({
controller: 'NoGithubOauthDialogController',
controllerAs: 'noGithubOauthDialogController',
bindToController: true,
clickOutsideToClose: true,
templateUrl: 'app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.html'
});
return;
}
var redirectUrl = this.$location.protocol() + '://'
+ this.$location.host() + ':'
+ this.$location.port()
+ this.$browser.baseHref()
+ 'gitHubCallback.html';
return this.githubPopup.open('/api/oauth/authenticate'
+ '?oauth_provider=github'
+ '&scope=' + ['user', 'repo', 'write:public_key'].join(',')
+ '&userId=' + this.currentUserId
+ '&redirect_after_login='
+ redirectUrl,
{
width: 1020,
height: 618
})
.then( () => {
return this.getAndStoreRemoteToken();
}, (rejectionReason) => {
return this.$q.reject(rejectionReason);
});
}
getAndStoreRemoteToken() {
return this.$http({method: 'GET', url: '/api/oauth/token?oauth_provider=github'}).then( (result) => {
if (!result.data) {
return false;
}
this.gitHubTokenStore.setToken(result.data.token);
this.$http({method: 'POST', url: '/api/github/ssh/generate'});
this.askLoad();
return true;
});
}
checkTokenValidity() {
if (this.currentTokenCheck) {
return this.currentTokenCheck;
}
this.currentTokenCheck = this.GitHub.user().get( () => {
this.currentTokenCheck = null;
return this.$q.defer().resolve(true);
}, () => {
this.currentTokenCheck = null;
return this.$q.defer().reject(false);
}).$promise;
return this.currentTokenCheck;
}
checkGitHubAuthentication() {
return this.checkTokenValidity().then( () => {
return this.$q.defer().resolve('true');
});
}
loadRepositories() {
this.checkGitHubAuthentication().then( () => {
var user = this.GitHub.user().get();
this.organizations.push(user);
this.GitHub.organizations().query().$promise.then((organizations) => {
this.organizations = this.organizations.concat(organizations);
var organizationNames = []; //'login'
this.organizations.forEach((organization) => {
if (organization.login) {
organizationNames.push(organization.login);
}
});
this.GitHub.userRepositories().query().$promise.then((repositories) => {
this.gitHubRepositories = this.$filter('filter')(repositories, (repository) => {
return organizationNames.indexOf(repository.owner.login) >= 0;
});
this.state = 'LOADED';
});
});
}, function () {
this.state = 'LOAD_ERROR';
});
}
selectRepository(gitHubRepository) {
this.selectedRepository = gitHubRepository;
this.$timeout(() => {
this.repositorySelectNotify();
// broadcast event
this.$rootScope.$broadcast('create-project-github:selected');
});
}
resolveOrganizationType(organization) {
return organization.name ? 'Your account' : 'Your organization\'s account';
}
}

View File

@ -1,65 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for creating project from github.
* @author Florent Benoit
*/
export class CreateProjectGithub {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor($http, $q, $window, $location, $browser, $filter, GitHub, githubPopup, gitHubTokenStore, githubOrganizationNameResolver) {
this.$http = $http;
this.$q = $q;
this.$window = $window;
this.$location = $location;
this.$browser = $browser;
this.$filter = $filter;
this.GitHub = GitHub;
this.gitHubTokenStore = gitHubTokenStore;
this.githubPopup = githubPopup;
this.githubOrganizationNameResolver = githubOrganizationNameResolver;
this.controller = 'CreateProjectGithubController';
this.controllerAs = 'createProjectGithubCtrl';
this.bindToController = true;
this.restrict = 'E';
this.templateUrl = 'app/projects/create-project/github/create-project-github.html';
// scope values
this.scope = {
createProjectGitHubForm: '=cheForm',
selectedRepository: '=cheRepositoryModel',
repositorySelectNotify: '&cheRepositorySelect',
isCurrentTab: '=cheIsCurrentTab'
};
}
link($scope) {
// Watch data of the createProject controller and update content with these parameters
$scope.$watch('createProjectCtrl.importProjectData.source.project.location', (newValue) => {
var matchRepository = this.$filter('filter')($scope.createProjectGithubCtrl.gitHubRepositories, function (repository) {
return repository.clone_url === newValue;
});
if (matchRepository) {
$scope.createProjectGithubCtrl.selectedRepository = matchRepository[0];
} else {
$scope.createProjectGithubCtrl.selectedRepository = undefined;
}
});
}
}

View File

@ -1,72 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<div class="create-project-github-panel" layout="row" flex></div>
<p ng-if="createProjectGithubCtrl.state == 'LOAD_ERROR'" class="alert alert-danger" style="margin-bottom: 15px">
We have a problem authenticating you with GitHub.
</p>
<div layout="column" layout-align="space-around flex-start" ng-show="createProjectGithubCtrl.state == 'NO_REPO'">
<div class="github-create-project-github-warningempty">Your GitHub repositories will appear here</div>
<div>GitHub repositories can easily be imported in {{createProjectGithubCtrl.productName}}</div>
<che-button-default class="github-create-project-github-button"
che-button-icon="fa fa-github"
che-button-title="Connect your github account"
ng-click="createProjectGithubCtrl.authenticateWithGitHub()">
</che-button-default>
</div>
<div ng-show="createProjectGithubCtrl.state === 'LOADING'">
<md-progress-linear md-mode="indeterminate"></md-progress-linear>
&nbsp;
</div>
<div ng-if="createProjectGithubCtrl.state == 'LOADED'">
<div layout="row" layout-align="space-around flex-start">
<div layout="row" flex="45" class="github-create-project-search-component">
<md-icon flex-gt-sm="5" md-font-icon="fa fa-search"></md-icon>
<input id="nameFilter" class="github-create-project-search-input" flex
ng-model="createProjectGithubCtrl.repositoryName" type="text" placeholder="Start typing here">
</div>
<div layout="row" flex="45" class="github-create-project-dropdown-component">
<select flex id="organizationFilter" class="github-create-project-select"
ng-model="createProjectGithubCtrl.organizationName"
ng-options="createProjectGithubCtrl.resolveOrganizationName(organization) group by createProjectGithubCtrl.resolveOrganizationType(organization) for organization in createProjectGithubCtrl.organizations">
<option value="">All Organizations</option>
</select>
</div>
</div>
<che-list class="github-create-project-repositories-list">
<che-list-item
ng-repeat="gitHubRepository in createProjectGithubCtrl.gitHubRepositories | githubFilterRepositories:createProjectGithubCtrl.organizationName:createProjectGithubCtrl.repositoryName | orderBy:'name'"
ng-click="createProjectGithubCtrl.selectRepository(gitHubRepository)" flex-gt-sm="100" flex="33"
ng-class="{'github-create-project-active' : gitHubRepository == createProjectGithubCtrl.selectedRepository}">
<div layout-gt-sm="row" flex="100" layout-align="start flex-start" class="project-list-row">
<div class="github-create-project-icons" flex-gt-sm="5">
<span ng-if="!gitHubRepository.fork" class="github-create-project-icon fa fa-folder"></span>
<span ng-if="gitHubRepository.fork" class="github-create-project-icon fa fa-code-fork" title="forked"></span>
<span ng-if="gitHubRepository.private" class="github-create-project-icon fa fa-lock" title="private"></span>
</div>
<div flex-gt-sm="45" layout="column">
<div class="github-create-project-repository-name">{{gitHubRepository.name}}</div>
<div class="github-create-project-repository-details">{{gitHubRepository.description}}</div>
</div>
<div flex-gt-sm="40">
{{gitHubRepository.clone_url}}
</div>
</div>
</che-list-item>
</che-list>
</div>

View File

@ -1,64 +0,0 @@
.github-create-project span
margin-left 5px
.github-create-project
cursor pointer
.create-project-github-panel
margin 15px
.github-create-project .icons
margin-right 20px
.github-create-project-select
display block
width 100%
background-color #fafafa
background-image none
border 1px solid #e5e5e5
border-radius 0
-webkit-box-shadow inset 0 1px 1px rgba(0, 0, 0, .075)
-webkit-transition border-color ease-in-out .15s, box-shadow ease-in-out .15s
transition border-color ease-in-out .15s, box-shadow ease-in-out .15s
.github-create-project-repository-name
font-size 16px
line-height 19px
color $label-primary-color
margin-bottom 3px
.github-create-project-repositories-list
max-height 400px
overflow auto
margin 2px
.github-create-project-repository-details
font-size 12px
line-height 15px
color $label-info-color
.github-create-project-icons
color $label-info-color
.github-create-project-icon
margin-left 10px
.github-create-project-search-component
border-bottom $label-primary-color 1px solid
margin-bottom 30px
.github-create-project-search-input
border none
outline none
.github-create-project-dropdown-component
margin-bottom 27px
.github-create-project-github-button
margin-top 10px
button
margin-left 0
.github-create-project-github-warningempty
margin-bottom 10px
color $label-info-color

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* @ngdoc controller
* @name projects.create-project.github.oauth-dialog.controller:NoGithubOauthDialogController
* @description This class is handling the controller for the no Github oAuth dialog
* @author Florent Benoit
*/
export class NoGithubOauthDialogController {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor($mdDialog, $rootScope) {
this.$mdDialog = $mdDialog;
this.name = $rootScope.branding.name;
this.message = $rootScope.branding.oauthDocs;
}
/**
* It will hide the dialog box.
*/
hide() {
this.$mdDialog.hide();
}
}

View File

@ -1,7 +0,0 @@
<che-popup title="GitHub oAuth" on-close="noGithubOauthDialogController.hide()">
<div class="no-github-oauth-content" flax>
<div>GitHub oAuth is not configured. {{noGithubOauthDialogController.message}}</div>
<che-button-notice che-button-title="Close"
ng-click="noGithubOauthDialogController.hide()"></che-button-notice>
</div>
</che-popup>

View File

@ -1,6 +0,0 @@
.no-github-oauth-content
width 100%
& > div
margin-top 10px
min-height 40px

View File

@ -1,37 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* This class is handling the controller for the project error notification
* @author Oleksii Orel
*/
export class ProjectErrorNotificationController {
title: string;
content: string;
private $mdDialog: ng.material.IDialogService;
/**
* Default constructor.
* @ngInject for Dependency injection
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;
}
/**
* Callback of the cancel button of the dialog.
*/
hide() {
this.$mdDialog.hide();
}
}

View File

@ -1,8 +0,0 @@
<che-popup title="{{projectErrorNotificationController.title}}" on-close="projectErrorNotificationController.hide()">
<div class="ssh-key-notification">
<div>{{projectErrorNotificationController.content}}</div>
<che-button-notice che-button-title="Close"
ng-click="projectErrorNotificationController.hide()">
</che-button-notice>
</div>
</che-popup>

View File

@ -1,4 +0,0 @@
.ssh-key-notification
width 100%
margin-top 10px
min-height 30px

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
export class CreateProjectSamplesTagFilter {
constructor(register: che.IRegisterService) {
// register this factory
register.filter('sampleTagFilter', () => {
return (templates: Array<che.IStack>, tagFilter: Array<string>) => {
if (!templates) {
return [];
}
if (!tagFilter || !tagFilter.length) {
return templates;
}
let filtered: Array<che.IStack> = [];
templates.forEach((template: che.IStack) => {
for (let i: number = 0; i < template.tags.length; i++) {
for (let j: number = 0; j < tagFilter.length; j++) {
if (template.tags[i].toLowerCase() === tagFilter[j].toLowerCase()) {
filtered.push(template);
return;
}
}
}
});
return filtered.length ? filtered : templates;
};
});
}
}

View File

@ -1,116 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {CheAPI} from '../../../../components/api/che-api.factory';
/**
* This class is handling the controller for the samples part
* @author Florent Benoit
*/
export class CreateProjectSamplesController {
$filter: ng.IFilterService;
templates: Array<che.IProjectTemplate>;
filteredAndSortedTemplates: Array<che.IProjectTemplate>;
selectedTemplateName: string = '';
currentStackTags: string[];
projectSampleOnSelect: Function;
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor($scope: ng.IScope, $filter: ng.IFilterService, cheAPI: CheAPI) {
this.$filter = $filter;
this.templates = cheAPI.getProjectTemplate().getAllProjectTemplates();
if (!this.templates.length) {
const templatesPromise = cheAPI.getProjectTemplate().fetchTemplates();
templatesPromise.finally(() => {
this.templates = cheAPI.getProjectTemplate().getAllProjectTemplates();
this.filterAndSortTemplates();
});
}
$scope.$watch(() => {
return this.currentStackTags;
}, () => {
this.filterAndSortTemplates();
});
}
/**
* Returns list of filtered and sorted templates.
*
* @return {che.IProjectTemplate[]}
*/
getTemplates(): che.IProjectTemplate[] {
return this.filteredAndSortedTemplates;
}
/**
* Filters templates by tags and sort them by project type and template name.
*/
filterAndSortTemplates(): void {
let stackTags = !this.currentStackTags ? [] : this.currentStackTags.map((tag: string) => tag.toLowerCase());
let filteredTemplates;
if (!stackTags.length) {
filteredTemplates = this.templates;
} else {
filteredTemplates = this.templates.filter((template: che.IProjectTemplate) => {
let templateTags = template.tags.map((tag: string) => tag.toLowerCase());
return stackTags.some((tag: string) => templateTags.indexOf(tag) > -1);
});
}
this.filteredAndSortedTemplates = this.$filter('orderBy')(filteredTemplates, ['projectType', 'displayName']);
if (this.filteredAndSortedTemplates.length) {
this.initItem(this.filteredAndSortedTemplates[0]);
}
}
/**
* Callback when a template is selected and also give the controller on which to select the data
* @param template: che.IProjectTemplate - the selected template
*/
selectTemplate(template: che.IProjectTemplate): void {
if (!template) {
return;
}
// set selected item
this.selectedTemplateName = template.name;
this.projectSampleOnSelect({template: template});
}
/**
* Select the first element in the list
* @param {che.IProjectTemplate} template
*/
initItem(template: che.IProjectTemplate): void {
if (!template || this.selectedTemplateName === template.name) {
return;
}
this.selectTemplate(template);
}
/**
* Helper method used to get the length of keys of the given object
* @param {Array<any>} items
* @returns {number} length of keys
*/
getItemsSize(items: Array<any>): number {
return items.length;
}
}

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for creating project from samples.
* @author Florent Benoit
*/
export class CreateProjectSamples {
bindToController: boolean;
restrict: string;
controller: string;
templateUrl: string;
controllerAs: string;
scope: {
[propName: string]: string
};
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor() {
this.restrict = 'E';
this.templateUrl = 'app/projects/create-project/samples/create-project-samples.html';
this.controller = 'CreateProjectSamplesController';
this.controllerAs = 'createProjectSamplesController';
this.bindToController = true;
this.scope = {
currentStackTags: '=',
projectSampleOnSelect: '&'
};
}
}

View File

@ -1,34 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<md-content flex class="projects-create-project-samples">
<che-list class="projects-create-project-samples-list">
<div ng-repeat="template in createProjectSamplesController.getTemplates()">
<che-list-item flex>
<div layout-gt-sm="row" flex layout-align="start center">
<div ng-init="$first && createProjectSamplesController.initItem(template)"
ng-click="createProjectSamplesController.selectTemplate(template)"
class="projects-create-project-samples-list-item"
ng-class="{'projects-create-project-samples-list-item-active' : template.name === createProjectSamplesController.selectedTemplateName}"
data-template-name="{{template.name}}"
layout="column" flex>
<div class="projects-create-project-samples-list-samplename">{{template.displayName}}</div>
<div class="projects-create-project-samples-list-sampledescription">{{template.description}}</div>
</div>
</div>
</che-list-item>
</div>
<div ng-show="!createProjectSamplesController.getItemsSize(createProjectSamplesController.getTemplates())">
No matching sample.
</div>
</che-list>
</md-content>

View File

@ -1,44 +0,0 @@
.projects-create-project-samples-list-item
outline none
padding 5px 10px
cursor pointer
.projects-create-project-samples-list-item-active
background-color $primary-color
.projects-create-project-samples-list-samplename
line-height initial
font-size 12px
color $label-primary-color
.projects-create-project-samples-list-sampledescription
line-height initial
font-size 10px
color $label-info-color
.projects-create-project-samples-list-item-active .projects-create-project-samples-list-samplename
color white
.projects-create-project-samples-list-item-active .projects-create-project-samples-list-sampledescription
color white
.projects-create-project-samples-header-projecttype
color $label-info-color
.projects-create-project-samples-search-component
border-bottom $label-primary-color 1px solid
margin-bottom 30px
#create-project-templates md-radio-button
margin-left 0
margin-bottom 20px
.projects-create-project-samples-list
margin 0
.projects-create-project-samples-list .che-list-content>div:first-child
border-top 1px solid $list-separator-color
.projects-create-project-samples
padding-left 30px
max-height 400px

View File

@ -1,41 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* @ngdoc controller
* @name projects.create-project.controller:CreateProjectWorkspacesController
* @description This class is handling the controller for the 'select existing workspace' widget.
* @author Oleksii Orel
*/
export class CreateProjectWorkspacesController {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor($timeout, cheAPI) {
this.$timeout = $timeout;
this.workspaces = cheAPI.getWorkspace().getWorkspaces();
}
/**
* Callback when workspace has been select
* @param workspace the workspace to use
*/
onWorkspaceSelect(workspace) {
this.workspace = workspace;
this.$timeout(() => {
this.onWorkspaceChange();
});
}
}

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for displaying select workspace widget.
* @author Oleksii Orel
*/
export class CreateProjectWorkspaces {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor() {
this.restrict = 'E';
this.templateUrl = 'app/projects/create-project/workspaces/create-project-workspaces.html';
this.bindToController = true;
this.controller = 'CreateProjectWorkspacesController';
this.controllerAs = 'createProjectWorkspacesController';
// scope values
this.scope = {
workspace: '=cheWorkspace',
onWorkspaceChange: '&cheWorkspaceChange'
};
}
}

View File

@ -1,35 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<md-content flex class="create-project-workspace-list">
<div ng-show="createProjectWorkspacesController.workspaces.length">
<che-list class="samples-list">
<che-list-item ng-repeat="workspace in createProjectWorkspacesController.workspaces"
ng-init="$first && createProjectWorkspacesController.onWorkspaceSelect(createProjectWorkspacesController.workspace ? createProjectWorkspacesController.workspace : workspace)"
flex>
<div layout-gt-sm="row" flex layout-align="start center">
<div class="list-item"
ng-class="{'list-item-active' : createProjectWorkspacesController.workspace.id === workspace.id}"
ng-click="createProjectWorkspacesController.onWorkspaceSelect(workspace)" layout="column" flex>
<div class="list-item-name">{{workspace.config.name}}</div>
<div ng-show="workspace.attributes && workspace.attributes.stackId" class="list-item-description">
{{workspace.attributes.stackId}} stack
</div>
</div>
</div>
</che-list-item>
</che-list>
</div>
<div ng-show="!createProjectWorkspacesController.workspaces.length" class="list-empty">
- No workspaces inside
</div>
</md-content>

View File

@ -1,37 +0,0 @@
.create-project-workspace-list
padding-left 30px
max-height 400px
.samples-list
box-sizing content-box
max-height 205px
overflow-y auto
margin 0
.che-list-item:first-child
border-top 1px solid $list-separator-color
.list-item
outline none
padding 5px 10px
cursor pointer
min-height 41px
.list-item-name
font-size 12px
line-height initial
color $label-primary-color
.list-item-description
font-size 10px
line-height initial
color $label-info-color
.list-item-active
background-color $primary-color
.list-item-active *
color $white-color
.list-empty
font-size 12px

View File

@ -1,28 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for creating project from zip.
* @author Florent Benoit
*/
export class CreateProjectZip {
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor () {
this.restrict='E';
this.templateUrl = 'app/projects/create-project/zip/create-project-zip.html';
}
}

View File

@ -1,33 +0,0 @@
<!--
Copyright (c) 2015-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<form name="createProjectZipForm" layout="column" class="create-project-zip">
<div layout="row" flex ng-init="createProjectCtrl.setForm(createProjectZipForm, 'zip');"></div>
<che-label-container che-label-name="Zip URL">
<div class="create-project-zip-input">
<che-input che-form="createProjectZipForm"
che-name="remotezipURL"
che-place-holder="Url of the zip file"
aria-label="Url of the zip file"
che-width="auto"
ng-model="createProjectCtrl.importProjectData.source.location"
required>
<div ng-message="required">A zip URL is required.</div>
</che-input>
<md-checkbox ng-model="createProjectCtrl.importProjectData.source.parameters.skipFirstLevel"
aria-label="Skip the root folder of the archive"
class="create-project-zip-checkbox">
Skip the root folder of the archive
</md-checkbox>
</div>
</che-label-container>
</form>

View File

@ -1,10 +0,0 @@
.create-project-zip
.che-label-container
padding-bottom 0
.che-label-container-content .create-project-zip-input
margin -6px 0
.create-project-zip-checkbox
margin-top 20px
color $label-primary-color

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for items in project list.
* Expects in parent scope:
* @param{string} workspaceId
* @param{object} project
*/
export class CheProjectItem {
/**
* Default constructor.
*/
constructor() {
this.restrict = 'E';
// we require ngModel as we want to use it inside our directive
this.require = ['ngModel'];
// scope values
this.scope = {
workspace: '=cheProjectItemWorkspace',
project: '=cheProjectItemProject',
profileCreationDate: '=cheProfileCreationDate',
isDisplayWorkspace: '=cheDisplayWorkspace',
isSelectable: '=cheSelectable',
isSelect: '=?ngModel',
onCheckboxClick: '&?cheOnCheckboxClick',
hasAction: '=?cheHasAction'
};
this.templateUrl = 'app/projects/list-projects/project-item/project-item.html';
this.controller = 'ProjectItemCtrl';
this.controllerAs = 'projectItemCtrl';
this.bindToController = true;
}
}

View File

@ -1,24 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {ProjectRepositoryController} from '../repository/project-repository.controller';
import {ProjectRepository} from '../repository/project-repository.directive';
export class ProjectRepositoryConfig {
constructor(register) {
register.controller('ProjectRepositoryController', ProjectRepositoryController);
register.directive('projectRepository', ProjectRepository);
}
}

View File

@ -1,3 +0,0 @@
/*@import 'create-project/create-project'
@import 'list-projects/list-projects'
*/

View File

@ -1,99 +0,0 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {CreateProjectController} from './create-project/create-project.controller';
import {CreateProjectSvc} from './create-project/create-project.service';
import {CreateProjectGithubController} from './create-project/github/create-project-github.controller';
import {CreateProjectGit} from './create-project/git/create-project-git.directive';
import {CreateProjectGitController} from './create-project/git/create-project-git.controller';
import {CreateProjectGithub} from './create-project/github/create-project-github.directive';
import {AddSecretKeyNotificationController} from './create-project/add-ssh-key-notification/add-ssh-key-notification.controller';
import {NoGithubOauthDialogController} from './create-project/github/oauth-dialog/no-github-oauth-dialog.controller';
import {CreateProjectSamplesController} from './create-project/samples/create-project-samples.controller';
import {CreateProjectSamples} from './create-project/samples/create-project-samples.directive';
import {CreateProjectWorkspacesController} from './create-project/workspaces/create-project-workspaces.controller';
import {CreateProjectWorkspaces} from './create-project/workspaces/create-project-workspaces.directive';
import {CreateProjectSamplesTagFilter} from './create-project/samples/create-project-samples-tag.filter';
import {CreateProjectZip} from './create-project/zip/create-project-zip.directive';
import {CreateProjectConfFile} from './create-project/config-file/create-project-conf-file.directive';
import {ProjectDetailsController} from './project-details/project-details.controller';
import {ProjectRepositoryConfig} from './project-details/repository/project-repository-config';
import {CheProjectItem} from './list-projects/project-item/project-item.directive';
import {ProjectItemCtrl} from './list-projects/project-item/project-item.controller';
import {ProjectErrorNotificationController} from './create-project/project-error-notification/project-error-notification.controller';
export class ProjectsConfig {
constructor(register: che.IRegisterService) {
new CreateProjectSamplesTagFilter(register);
register.controller('ProjectDetailsController', ProjectDetailsController);
register.controller('CreateProjectGitController', CreateProjectGitController);
register.directive('createProjectGit', CreateProjectGit);
register.controller('CreateProjectGithubController', CreateProjectGithubController);
register.directive('createProjectGithub', CreateProjectGithub);
register.controller('NoGithubOauthDialogController', NoGithubOauthDialogController);
register.controller('AddSecretKeyNotificationController', AddSecretKeyNotificationController);
register.controller('ProjectErrorNotificationController', ProjectErrorNotificationController);
register.controller('CreateProjectSamplesController', CreateProjectSamplesController);
register.directive('createProjectSamples', CreateProjectSamples);
register.controller('CreateProjectWorkspacesController', CreateProjectWorkspacesController);
register.directive('createProjectWorkspaces', CreateProjectWorkspaces);
register.directive('createProjectZip', CreateProjectZip);
register.directive('createProjectConfFile', CreateProjectConfFile);
register.service('createProjectSvc', CreateProjectSvc);
register.controller('CreateProjectController', CreateProjectController);
register.directive('cheProjectItem', CheProjectItem);
register.controller('ProjectItemCtrl', ProjectItemCtrl);
let locationCreateProjectProvider = {
title: 'New Project',
templateUrl: 'app/projects/create-project/create-project.html',
controller: 'CreateProjectController',
controllerAs: 'createProjectCtrl'
};
// config routes
register.app.config(function ($routeProvider) {
$routeProvider.accessWhen('/project/:namespace*/:workspaceName/:projectName', {
title: (params) => {return params.workspaceName + ' | ' + params.projectName},
templateUrl: 'app/projects/project-details/project-details.html',
controller: 'ProjectDetailsController',
controllerAs: 'projectDetailsController'
})
.accessWhen('/create-project', locationCreateProjectProvider)
.accessWhen('/create-project/:tabName', locationCreateProjectProvider);
});
//// config files
new ProjectRepositoryConfig(register);
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
export class SamplesTagFilter {
static filter() {
return (templates: Array<che.IStack>, tagFilter: Array<string>) => {
if (!templates) {
return [];
}
if (!tagFilter || !tagFilter.length) {
return templates;
}
const filtered: Array<che.IStack> = [];
templates.forEach((template: che.IStack) => {
for (let i: number = 0; i < template.tags.length; i++) {
for (let j: number = 0; j < tagFilter.length; j++) {
if (template.tags[i].toLowerCase() === tagFilter[j].toLowerCase()) {
filtered.push(template);
return;
}
}
}
});
return filtered.length ? filtered : templates;
};
}
}

View File

@ -37,7 +37,7 @@
</che-list-header>
<che-list flex>
<che-list-item
ng-repeat="template in filteredTemplates = (selectTemplateController.templates | sampleTagFilter:selectTemplateController.stack.tags | orderBy:['projectType', selectTemplateController.projectsOrderBy])">
ng-repeat="template in filteredTemplates = (selectTemplateController.templates | samplesTagFilter:selectTemplateController.stack.tags | orderBy:['projectType', selectTemplateController.projectsOrderBy])">
<div flex="100"
layout="row"
layout-align="start stretch"

View File

@ -18,6 +18,7 @@ import {ListComponents} from './stack-details/list-components/list-components.di
import {ListComponentsController} from './stack-details/list-components/list-components.controller';
import {EditComponentDialogController} from './stack-details/list-components/edit-component-dialog/edit-component-dialog.controller';
import {SelectTemplateController} from './stack-details/select-template/select-template.controller';
import {SamplesTagFilter} from './stack-details/select-template/samples-tag.filter';
import {ImportStackController} from './list-stacks/import-stack/import-stack.controller';
import {ImportStackService} from './stack-details/import-stack.service';
import {StackValidationService} from './stack-details/stack-validation.service';
@ -42,6 +43,7 @@ export class StacksConfig {
register.controller('StackController', StackController);
register.controller('EditComponentDialogController', EditComponentDialogController);
register.controller('SelectTemplateController', SelectTemplateController);
register.filter('samplesTagFilter', SamplesTagFilter.filter);
register.controller('ImportStackController', ImportStackController);
register.service('importStackService', ImportStackService);
register.service('stackValidationService', StackValidationService);

View File

@ -317,7 +317,11 @@ export class CreateWorkspaceSvc {
}
private getIDE(): any {
return (this.$document.find('#ide-application-iframe') as any).contentWindow.IDE;
const jqIframe = this.$document.find('#ide-application-iframe');
if (!jqIframe || jqIframe.length === 0) {
return null;
}
return (jqIframe as any).contentWindow.IDE;
}
}

View File

@ -9,7 +9,10 @@
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {ConfirmDialogService} from '../../../components/service/confirm-dialog/confirm-dialog.service';
import {ConfirmDialogService} from '../../../../../components/service/confirm-dialog/confirm-dialog.service';
import {CheNotification} from '../../../../../components/notification/che-notification.factory';
import {CheAPI} from '../../../../../components/api/che-api.factory';
import {CheProject} from '../../../../../components/api/che-project';
/**
* Controller for a project details
@ -17,13 +20,39 @@ import {ConfirmDialogService} from '../../../components/service/confirm-dialog/c
* @author Oleksii Orel
*/
export class ProjectDetailsController {
private $log: ng.ILogService;
private cheNotification: CheNotification;
private cheAPI: CheAPI;
private $location: ng.ILocationService;
private lodash: any;
private $timeout: ng.ITimeoutService;
private confirmDialogService: ConfirmDialogService;
private namespace: string;
private workspaceName: string;
private projectName: string;
private projectPath: string;
private loading: boolean = true;
private workspace: che.IWorkspace;
private timeoutPromise: ng.IPromise<any>;
private projectService: CheProject;
private invalidProject: boolean;
private projectDetails: che.IProjectTemplate;
private projectDescription: string;
/**
* Default constructor that is using resource injection
* @ngInject for Dependency injection
*/
constructor($scope, $log, $route, $location, cheAPI, confirmDialogService, cheNotification, lodash, $timeout) {
constructor($scope: ng.IScope,
$log: ng.ILogService,
$route: ng.route.IRouteService,
$location: ng.ILocationService,
$timeout: ng.ITimeoutService,
cheAPI: CheAPI,
confirmDialogService: ConfirmDialogService,
cheNotification: CheNotification,
lodash: any) {
this.$log = $log;
this.cheNotification = cheNotification;
this.cheAPI = cheAPI;
@ -51,7 +80,7 @@ export class ProjectDetailsController {
} else {
this.loading = false;
}
}, (error) => {
}, (error: any) => {
this.cheNotification.showError(error.data.message ? error.data.message : 'Failed to get runtime of the project workspace.');
this.$log.log('error', error);
});
@ -59,7 +88,6 @@ export class ProjectDetailsController {
this.fetchProjectDetails();
}
this.timeoutPromise;
$scope.$on('$destroy', () => {
if (this.timeoutPromise) {
$timeout.cancel(this.timeoutPromise);
@ -67,7 +95,7 @@ export class ProjectDetailsController {
});
}
fetchProjectDetails() {
fetchProjectDetails(): void {
this.loading = true;
if (this.workspace.status !== 'STARTING' && this.workspace.status !== 'RUNNING') {
@ -88,7 +116,7 @@ export class ProjectDetailsController {
this.projectService.fetchProjectDetails(this.workspace.id, this.projectPath).then(() => {
this.loading = false;
this.updateProjectDetails();
}, (error) => {
}, (error: any) => {
if (error.status === 304) {
this.loading = false;
this.updateProjectDetails();
@ -99,27 +127,27 @@ export class ProjectDetailsController {
}
});
}
}, (error) => {
}, (error: any) => {
this.$log.error(error);
this.loading = false;
});
}
updateProjectDetails() {
updateProjectDetails(): void {
this.projectDetails = this.projectService.getProjectDetailsByKey(this.projectPath);
this.projectName = angular.copy(this.projectDetails.name);
this.projectDescription = angular.copy(this.projectDetails.description);
this.loading = false;
}
updateLocation() {
updateLocation(): void {
if (this.$location.path().endsWith(this.projectDetails.name)) {
return;
}
this.$location.path('/project/' + this.namespace + '/' + this.workspaceName + '/' + this.projectDetails.name);
this.$location.path('/workspace/' + this.namespace + '/' + this.workspaceName + '/' + this.projectDetails.name);
}
setProjectDetails(projectDetails) {
setProjectDetails(projectDetails: che.IProjectTemplate): void {
projectDetails.description = this.projectDescription;
let promise = this.projectService.updateProjectDetails(projectDetails);
@ -127,13 +155,13 @@ export class ProjectDetailsController {
this.cheNotification.showInfo('Project information successfully updated.');
this.updateLocation();
if (this.isNameChanged()) {
this.projectService.fetchProjectDetails(this.projectPath).then(() => {
this.projectService.fetchProjectDetails(this.workspace.id, this.projectPath).then(() => {
this.updateProjectDetails();
});
} else {
this.projectDescription = projectDetails.description;
}
}, (error) => {
}, (error: any) => {
this.projectDetails.description = this.projectDescription;
this.cheNotification.showError(error.data.message ? error.data.message : 'Update information failed.');
this.$log.log('error', error);
@ -141,7 +169,7 @@ export class ProjectDetailsController {
}
isNameChanged() {
isNameChanged(): boolean {
if (this.projectDetails) {
return this.projectName !== this.projectDetails.name;
} else {
@ -149,7 +177,7 @@ export class ProjectDetailsController {
}
}
isDescriptionChanged() {
isDescriptionChanged(): boolean {
if (this.projectDetails) {
return this.projectDescription !== this.projectDetails.description;
} else {
@ -157,7 +185,7 @@ export class ProjectDetailsController {
}
}
updateInfo(isInputFormValid) {
updateInfo(isInputFormValid: boolean): void {
this.$timeout.cancel(this.timeoutPromise);
if (!isInputFormValid || !(this.isNameChanged() || this.isDescriptionChanged())) {
@ -169,7 +197,7 @@ export class ProjectDetailsController {
}, 500);
}
doUpdateInfo() {
doUpdateInfo(): void {
if (this.isNameChanged()) {
let promise = this.projectService.rename(this.projectDetails.name, this.projectName);
@ -184,7 +212,7 @@ export class ProjectDetailsController {
} else {
this.setProjectDetails(this.projectDetails);
}
}, (error) => {
}, (error: any) => {
this.projectDetails.name = this.projectName;
this.cheNotification.showError(error.data.message ? error.data.message : 'Update information failed.');
this.$log.log('error', error);
@ -194,7 +222,7 @@ export class ProjectDetailsController {
}
}
deleteProject() {
deleteProject(): void {
let content = 'Would you like to delete the project \'' + this.projectDetails.name + '\' ?';
this.confirmDialogService.showConfirmDialog('Remove project', content, 'Delete').then(() => {
// remove it !
@ -213,7 +241,7 @@ export class ProjectDetailsController {
* Returns list of projects of current workspace excluding current project
* @returns {*|Array}
*/
getWorkspaceProjects() {
getWorkspaceProjects(): Array<che.IProject> {
let projects = this.cheAPI.getWorkspace().getWorkspaceProjects()[this.workspace.id];
let _projects = this.lodash.filter(projects, (project) => { return project.name !== this.projectName});
return _projects;
@ -223,7 +251,7 @@ export class ProjectDetailsController {
* Returns current status of workspace
* @returns {String}
*/
getWorkspaceStatus() {
getWorkspaceStatus(): string {
if (!this.workspace) {
return 'unknown';
}

View File

@ -10,30 +10,38 @@
*/
'use strict';
import {gitMixinId, subversionMixinId} from '../repository/project-repository-data';
import {gitMixinId, subversionMixinId} from './project-repository-data';
import {CheAPI} from '../../../../../../components/api/che-api.factory';
import {WorkspaceStatus} from '../../../../../../components/api/workspace/che-workspace.factory';
import {CheWorkspaceAgent} from '../../../../../../components/api/che-workspace-agent';
export class ProjectRepositoryController {
private cheAPI: CheAPI;
private lodash: any;
private remoteGitRepositories: any[] = [];
private localGitRepository: any = null;
private remoteSvnRepository: any = null;
private isEmptyState: boolean = false;
private wsagent: CheWorkspaceAgent;
/**
* Controller for the project local repository and remote repositories details
* @ngInject for Dependency injection
* @author Oleksii Orel
*/
constructor($route, cheAPI, lodash) {
constructor($route: ng.route.IRouteService,
cheAPI: CheAPI,
lodash: any) {
this.cheAPI = cheAPI;
this.lodash = lodash;
this.remoteGitRepositories = [];
this.localGitRepository = null;
this.remoteSvnRepository = null;
this.isEmptyState = false;
const namespace = $route.current.params.namespace;
const workspaceName = $route.current.params.workspaceName;
const projectPath = '/' + $route.current.params.projectName;
var namespace = $route.current.params.namespace;
var workspaceName = $route.current.params.workspaceName;
var projectPath = '/' + $route.current.params.projectName;
let workspace = this.cheAPI.getWorkspace().getWorkspaceByName(namespace, workspaceName);
if (workspace && (workspace.status === 'STARTING' || workspace.status === 'RUNNING')) {
const workspace = this.cheAPI.getWorkspace().getWorkspaceByName(namespace, workspaceName);
if (workspace && (WorkspaceStatus[workspace.status] === WorkspaceStatus.RUNNING || WorkspaceStatus[workspace.status] === 'RUNNING')) {
this.cheAPI.getWorkspace().fetchStatusChange(workspace.id, 'RUNNING').then(() => {
return this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id);
}).then(() => {
@ -43,11 +51,11 @@ export class ProjectRepositoryController {
let promise = this.wsagent.getProject().fetchProjectDetails(workspace.id, projectPath);
promise.then(() => {
var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
const projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
this.updateRepositories(projectDetails);
});
} else {
var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
const projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
this.updateRepositories(projectDetails);
}
}
@ -55,7 +63,7 @@ export class ProjectRepositoryController {
}
}
updateRepositories(projectDetails) {
updateRepositories(projectDetails: che.IProjectTemplate): void {
if (!projectDetails.mixins || !projectDetails.mixins.length) {
this.isEmptyState = true;
return;
@ -64,7 +72,7 @@ export class ProjectRepositoryController {
if (projectDetails.mixins.indexOf(subversionMixinId) !== -1) {
//update remote svn url
if (!this.wsagent.getSvn().getRemoteUrlByKey(projectDetails.workspaceId, projectDetails.path)) {
let promise = this.wsagent.getSvn().fetchRemoteUrl(projectDetails.workspaceId, projectDetails.path);
const promise = this.wsagent.getSvn().fetchRemoteUrl(projectDetails.workspaceId, projectDetails.path);
promise.then(() => {
this.remoteSvnRepository = this.wsagent.getSvn().getRemoteUrlByKey(projectDetails.workspaceId, projectDetails.path);
@ -77,7 +85,7 @@ export class ProjectRepositoryController {
if (projectDetails.mixins.indexOf(gitMixinId) !== -1) {
//update git local url
if (!this.wsagent.getGit().getLocalUrlByKey(projectDetails.path)) {
let promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.path);
const promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.path);
promise.then(() => {
this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.path);
@ -88,7 +96,7 @@ export class ProjectRepositoryController {
//update git remote urls
if (!this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path)) {
let promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.path);
const promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.path);
promise.then(() => {
this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path);

View File

@ -14,24 +14,16 @@
* Defines a directive for displaying project repository widget.
* @author Oleksii Orel
*/
export class ProjectRepository {
export class ProjectRepository implements ng.IDirective {
restrict = 'E';
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor() {
this.restrict = 'E';
templateUrl = 'app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.html';
this.templateUrl = 'app/projects/project-details/repository/project-repository.html';
controller = 'ProjectRepositoryController';
controllerAs = 'projectRepositoryController';
this.controller = 'ProjectRepositoryController';
this.controllerAs = 'projectRepositoryController';
bindToController = true;
this.bindToController = true;
this.scope = true;
}
scope = true;
}

View File

@ -9,6 +9,7 @@
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
import {CheWorkspace} from '../../../../../components/api/workspace/che-workspace.factory';
/**
* @ngdoc controller
@ -17,18 +18,24 @@
* @author Florent Benoit
*/
export class ProjectItemCtrl {
private $location: ng.ILocationService;
private cheWorkspace: CheWorkspace;
private workspace: che.IWorkspace;
private project: che.IProject;
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
constructor($location, cheWorkspace) {
constructor($location: ng.ILocationService,
cheWorkspace: CheWorkspace) {
this.$location = $location;
this.cheWorkspace = cheWorkspace;
}
redirectToProjectDetails() {
this.$location.path('/project/' + this.workspace.namespace + '/' + this.workspace.config.name + '/' + this.project.name);
redirectToProjectDetails(): void {
this.$location.path('/workspace/' + this.workspace.namespace + '/' + this.workspace.config.name + '/' + this.project.name);
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2015-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
/**
* Defines a directive for items in project list.
* Expects in parent scope:
* @param{string} workspaceId
* @param{object} project
*/
export class CheProjectItem implements ng.IDirective {
restrict = 'E';
// we require ngModel as we want to use it inside our directive
require = ['ngModel'];
// scope values
scope = {
workspace: '=cheProjectItemWorkspace',
project: '=cheProjectItemProject',
profileCreationDate: '=cheProfileCreationDate',
isDisplayWorkspace: '=cheDisplayWorkspace',
isSelectable: '=cheSelectable',
isSelect: '=?ngModel',
onCheckboxClick: '&?cheOnCheckboxClick',
hasAction: '=?cheHasAction'
};
templateUrl = 'app/workspaces/workspace-details/workspace-projects/project-item/project-item.html';
controller = 'ProjectItemCtrl';
controllerAs = 'projectItemCtrl';
bindToController = true;
}

View File

@ -24,6 +24,11 @@ import {WorkspaceDetailsSshCtrl} from './workspace-details/workspace-ssh/workspa
import {WorkspaceDetailsProjectsCtrl} from './workspace-details/workspace-projects/workspace-details-projects.controller';
import {WorkspaceDetailsProjects} from './workspace-details/workspace-projects/workspace-details-projects.directive';
import {WorkspaceDetailsProjectsService} from './workspace-details/workspace-projects/workspace-details-projects.service';
import {ProjectDetailsController} from './workspace-details/workspace-projects/project-details/project-details.controller';
import {ProjectRepositoryController} from './workspace-details/workspace-projects/project-details/repository/project-repository.controller';
import {ProjectRepository} from './workspace-details/workspace-projects/project-details/repository/project-repository.directive';
import {CheProjectItem} from './workspace-details/workspace-projects/project-item/project-item.directive';
import {ProjectItemCtrl} from './workspace-details/workspace-projects/project-item/project-item.controller';
import {AddProjectPopoverController} from './workspace-details/workspace-projects/add-project-popover/add-project-popover.controller';
import {AddProjectPopover} from './workspace-details/workspace-projects/add-project-popover/add-project-popover.directive';
import {WorkspaceDetailsService} from './workspace-details/workspace-details.service';
@ -70,6 +75,7 @@ import {ImportZipProjectController} from './create-workspace/project-source-sele
import {ImportZipProjectService} from './create-workspace/project-source-selector/add-import-project/import-zip-project/import-zip-project.service';
import {ImportZipProject} from './create-workspace/project-source-selector/add-import-project/import-zip-project/import-zip-project.directive';
import {ImportGithubProjectController} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.controller';
import {NoGithubOauthDialogController} from './create-workspace/project-source-selector/add-import-project/import-github-project/oauth-dialog/no-github-oauth-dialog.controller';
import {ImportGithubProjectService} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.service';
import {ImportGithubProject} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.directive';
import {GithubRepositoryItem} from './create-workspace/project-source-selector/add-import-project/import-github-project/github-repository-item/github-repository-item.directive';
@ -142,7 +148,6 @@ import {MachineAgents} from './workspace-details/workspace-machine-agents/machin
import {MachineAgentsController} from './workspace-details/workspace-machine-agents/machine-agents.controller';
import {CheWorkspace} from '../../components/api/workspace/che-workspace.factory';
/**
* @ngdoc controller
* @name workspaces:WorkspacesConfig
@ -177,6 +182,11 @@ export class WorkspacesConfig {
register.controller('WorkspaceDetailsProjectsCtrl', WorkspaceDetailsProjectsCtrl);
register.directive('workspaceDetailsProjects', WorkspaceDetailsProjects);
register.controller('ProjectDetailsController', ProjectDetailsController);
register.controller('ProjectRepositoryController', ProjectRepositoryController);
register.directive('projectRepository', ProjectRepository);
register.directive('cheProjectItem', CheProjectItem);
register.controller('ProjectItemCtrl', ProjectItemCtrl);
register.service('workspaceDetailsProjectsService', WorkspaceDetailsProjectsService);
register.controller('AddProjectPopoverController', AddProjectPopoverController);
register.directive('addProjectPopover', AddProjectPopover);
@ -242,6 +252,7 @@ export class WorkspacesConfig {
register.service('importGithubProjectService', ImportGithubProjectService);
register.directive('importGithubProject', ImportGithubProject);
register.directive('githubRepositoryItem', GithubRepositoryItem);
register.controller('NoGithubOauthDialogController', NoGithubOauthDialogController);
register.controller('ImportZipProjectController', ImportZipProjectController);
register.service('importZipProjectService', ImportZipProjectService);
register.directive('importZipProject', ImportZipProject);
@ -333,6 +344,14 @@ export class WorkspacesConfig {
controller: 'ListWorkspacesCtrl',
controllerAs: 'listWorkspacesCtrl'
})
.accessWhen('/workspace/:namespace*/:workspaceName/:projectName', {
title: (params: any) => {
return params.workspaceName + ' | ' + params.projectName;
},
templateUrl: 'app/workspaces/workspace-details/workspace-projects/project-details/project-details.html',
controller: 'ProjectDetailsController',
controllerAs: 'projectDetailsController'
})
.accessWhen('/workspace/:namespace*/:workspaceName', {
title: (params: any) => {
return params.workspaceName;