-
Notifications
You must be signed in to change notification settings - Fork 60
/
selectProject.html
122 lines (117 loc) · 5.76 KB
/
selectProject.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<span ng-if="$ctrl.noProjectsCantCreate" class="no-projects-cant-create">
<pf-empty-state config="$ctrl.noProjectsConfig"></pf-empty-state>
<p ng-if="!$ctrl.noProjectsCantCreateMessage">
A cluster admin can create a project for you by running the command:
<div class="code-block">
<code>oc adm <span class="command-arg">new-project</span> <projectname> <span class="command-arg">--admin={{$ctrl.user.metadata.name || '<YourUsername>'}}</span></code>
</div>
</p>
<div ng-if="$ctrl.noProjectsCantCreateMessage" ng-bind-html="$ctrl.noProjectsCantCreateMessage | linky : '_blank'"></div>
</span>
<!-- Use `ng-show` instead of `ng-if` so that the form exists and the `canI` works when projects load. -->
<ng-form name="$ctrl.forms.selectProjectForm" ng-show="$ctrl.numProjectChoices >= 1">
<div class="form-group" ng-class="{'has-error' : $ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject ||
($ctrl.forms.selectProjectForm.selectProject.$touched &&
$ctrl.forms.selectProjectForm.selectProject.$invalid)}">
<h3 ng-if="$ctrl.canOnlyCreateProject()">Create Project</h3>
<label ng-if="!$ctrl.canOnlyCreateProject() && !$ctrl.hideLabel" class="control-label required">Add to Project</label>
<ui-select
ng-if="!$ctrl.canOnlyCreateProject()"
ng-disabled="$ctrl.numProjectChoices === 1"
name="selectProject"
ng-model="$ctrl.selectedProject"
ng-change="$ctrl.onSelectProjectChange()"
ng-required="$ctrl.isRequired"
search-enabled="$ctrl.searchEnabled"
uis-open-close="$ctrl.onOpenClose(isOpen)">
<ui-select-match placeholder="{{$ctrl.placeholder}}">
{{$select.selected | displayName}}
</ui-select-match>
<!-- refresh-delay must be set using ng-attr-refresh-delay to work as a dynamic value -->
<ui-select-choices
repeat="project in $ctrl.getProjectChoices() track by (project | uid)"
refresh="$ctrl.refreshChoices($select.search)"
ng-attr-refresh-delay="{{$ctrl.refreshDelay}}"
group-by="$ctrl.groupChoicesBy">
<span ng-bind-html="project | displayName | highlightKeywords : $select.search"></span>
<span ng-if="project | displayName : true" class="small text-muted">
<span ng-if="project.metadata.name">–</span>
<span ng-bind-html="project.metadata.name | highlightKeywords : $select.search"></span>
</span>
</ui-select-choices>
</ui-select>
<div ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.cannotAddToProject">
<span class="help-block">
You are not authorized to add to this project.
</span>
</div>
<div class="has-error" ng-if="$ctrl.forms.selectProjectForm.selectProject.$error.required &&
$ctrl.forms.selectProjectForm.selectProject.$touched">
<span class="help-block">
Please select <span ng-if="$ctrl.canCreate && !$ctrl.hideCreateProject">or create</span> a project.
</span>
</div>
</div>
</ng-form>
<ng-form name="$ctrl.forms.createProjectForm"
ng-if="$ctrl.isNewProject()">
<div class="form-group">
<label for="name" class="control-label required">Project Name</label>
<div ng-class="{'has-error': ($ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched) ||
$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique}">
<input class="form-control"
name="name"
id="name"
placeholder="my-project"
type="text"
required
take-focus
minlength="2"
maxlength="63"
pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?"
aria-describedby="nameHelp"
ng-model="$ctrl.selectedProject.metadata.name"
osc-unique="$ctrl.existingProjectNames"
ng-model-options="{ updateOn: 'default blur' }"
ng-change="$ctrl.onNewProjectNameChange()"
autocorrect="off"
autocapitalize="off"
spellcheck="false">
</div>
<div class="help-block">A unique name for the project.</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.minlength && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Name must have at least two characters.
</span>
</div>
<div class="has-error" ng-if="$ctrl.forms.createProjectForm.name.$error.pattern && $ctrl.forms.createProjectForm.name.$touched">
<span id="nameHelp" class="help-block">
Project names may only contain lower-case letters, numbers, and dashes.
They may not start or end with a dash.
</span>
</div>
<div class="has-error" ng-if="$ctrl.nameTaken || $ctrl.forms.createProjectForm.name.$error.oscUnique">
<span class="help-block">
This name is already in use. Please choose a different name.
</span>
</div>
</div>
<div class="form-group">
<label for="displayName" class="control-label">Project Display Name</label>
<input class="form-control"
name="displayName"
id="displayName"
placeholder="My Project"
type="text"
ng-model="$ctrl.selectedProject.metadata.annotations['new-display-name']">
</div>
<div class="form-group">
<label for="description" class="control-label">Project Description</label>
<textarea class="form-control"
name="description"
id="description"
placeholder="A short description."
ng-model="$ctrl.selectedProject.metadata.annotations['openshift.io/description']"></textarea>
</div>
</ng-form>
<div ng-if="!$ctrl.noProjectsCantCreate && $ctrl.showDivider" class="select-project-divider"></div>