mirror of https://github.com/rancher/ui.git
Merge pull request #1846 from biblesyme/aaron-master
Enable use edit registry in Pipeline Page
This commit is contained in:
commit
97e213b9c2
|
|
@ -4,6 +4,7 @@ import { observer } from '@ember/object';
|
||||||
import {analyzeImageRepo} from 'pipeline/utils/pipelineStep';
|
import {analyzeImageRepo} from 'pipeline/utils/pipelineStep';
|
||||||
import layout from './template';
|
import layout from './template';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
|
import { set, get } from '@ember/object';
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
|
|
@ -25,6 +26,8 @@ export default Component.extend({
|
||||||
imageTag: '',
|
imageTag: '',
|
||||||
registryExist: true,
|
registryExist: true,
|
||||||
savingRegistry: false,
|
savingRegistry: false,
|
||||||
|
selectedRegistry: null,
|
||||||
|
noEditingRegistry: true,
|
||||||
},
|
},
|
||||||
init(){
|
init(){
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
@ -45,7 +48,8 @@ export default Component.extend({
|
||||||
let registry = Object.keys(ele.registries)[0];
|
let registry = Object.keys(ele.registries)[0];
|
||||||
return {
|
return {
|
||||||
label: registry,
|
label: registry,
|
||||||
value: registry
|
value: registry,
|
||||||
|
username: ele.registries[registry].username
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
})),
|
})),
|
||||||
|
|
@ -67,7 +71,9 @@ export default Component.extend({
|
||||||
}),
|
}),
|
||||||
observerRegistry: on('init', observer('state.imageRegistry','state.registries.[]',function(){
|
observerRegistry: on('init', observer('state.imageRegistry','state.registries.[]',function(){
|
||||||
let state = this.get('state');
|
let state = this.get('state');
|
||||||
if(state.registries.find(ele=>state.imageRegistry===ele.value)){
|
let selectedRegistry = state.registries.find(ele=>state.imageRegistry===ele.value);
|
||||||
|
if(selectedRegistry){
|
||||||
|
set(this, 'state.selectedRegistry', selectedRegistry);
|
||||||
this.set('state.registryExist',true);
|
this.set('state.registryExist',true);
|
||||||
this.set('modalState.saveDisabled', false);
|
this.set('modalState.saveDisabled', false);
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -76,20 +82,64 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
actions: {
|
actions: {
|
||||||
|
setState(state, val){
|
||||||
|
set(this, `${state}`, val);
|
||||||
|
let username = get(this, 'state.selectedRegistry.username');
|
||||||
|
if(state === 'state.noEditingRegistry'){
|
||||||
|
set(this, 'state.username', val?'':username);
|
||||||
|
}
|
||||||
|
},
|
||||||
saveRegistry(){
|
saveRegistry(){
|
||||||
let state = this.get('state');
|
let state = this.get('state');
|
||||||
|
let noEditing = get(this, 'state.noEditingRegistry');
|
||||||
this.set('state.savingRegistry', true);
|
this.set('state.savingRegistry', true);
|
||||||
this.get('store').createRecord({
|
if(noEditing){
|
||||||
type: 'dockerCredential',
|
this.get('store').createRecord({
|
||||||
registries: {
|
type: 'dockerCredential',
|
||||||
[`${state.imageRegistry}`]: {
|
registries: {
|
||||||
username: state.username,
|
[`${state.imageRegistry}`]: {
|
||||||
password: state.password,
|
username: state.username,
|
||||||
|
password: state.password,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}).save().finally(()=>{
|
||||||
|
this.set('state.savingRegistry', false);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
let registries = this.get('registries');
|
||||||
|
let selectedRegistry = get(this, 'state.selectedRegistry');
|
||||||
|
let selectedOriginRegistry = registries.find(ele => {
|
||||||
|
return ele.registries[selectedRegistry.value];
|
||||||
|
});
|
||||||
|
if(!selectedOriginRegistry){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}).save().finally(()=>{
|
let serilizedRegistry = selectedOriginRegistry.serialize();
|
||||||
this.set('state.savingRegistry', false);
|
this.get('store').createRecord(
|
||||||
});
|
Object.assign({},serilizedRegistry,{
|
||||||
|
registries: {
|
||||||
|
[`${state.imageRegistry}`]: {
|
||||||
|
username: state.username,
|
||||||
|
password: state.password,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.save().then((registry)=>{
|
||||||
|
let registries = get(this, 'state.registries');
|
||||||
|
set(this, 'state.registries', registries.map(ele=>{
|
||||||
|
if(ele.value = state.imageRegistry){
|
||||||
|
return Object.assign({}, ele, {
|
||||||
|
username: state.username
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ele;
|
||||||
|
}))
|
||||||
|
}).finally(()=>{
|
||||||
|
this.set('state.savingRegistry', false);
|
||||||
|
set(this, 'state.noEditingRegistry', true);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,17 @@
|
||||||
{{input class="form-control" value=state.imageTag disabled=disabled}}
|
{{input class="form-control" value=state.imageTag disabled=disabled}}
|
||||||
</div>
|
</div>
|
||||||
{{#if registryField}}
|
{{#if registryField}}
|
||||||
{{#if state.registryExist}}
|
{{#if (and state.registryExist state.noEditingRegistry)}}
|
||||||
{{banner-message icon="icon-success" color='bg-success mb-0 mt-10' message=(concat "Registry " state.imageRegistry " exists")}}
|
{{#banner-message icon="icon-success" color='bg-success mb-0 mt-10'}}
|
||||||
|
{{t 'newPipelineStep.stepType.build.registryExist' registry=state.imageRegistry username=state.selectedRegistry.username}}
|
||||||
|
<button {{action "setState" "state.noEditingRegistry" false}} class="btn bg-transparent btn-sm pull-right mr-10">Edit Registry</button>
|
||||||
|
{{/banner-message}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{banner-message color='bg-warning mb-0 mt-10' message=(concat "Please add registry " state.imageRegistry " first")}}
|
{{#if state.noEditingRegistry}}
|
||||||
|
{{banner-message color='bg-warning mb-0 mt-10' message=(concat "Please add registry " state.imageRegistry " first")}}
|
||||||
|
{{else}}
|
||||||
|
{{banner-message color='bg-info mb-0 mt-10' message=(concat "Edit registry " state.imageRegistry)}}
|
||||||
|
{{/if}}
|
||||||
<div class="box mt-10">
|
<div class="box mt-10">
|
||||||
<p class="mt-0 mb-0">{{t 'newPipelineStep.stepType.build.scope'}}</p>
|
<p class="mt-0 mb-0">{{t 'newPipelineStep.stepType.build.scope'}}</p>
|
||||||
<p class="mt-10 mb-0">{{t 'registriesPage.new.form.custom.labelText'}}: {{state.imageRegistry}}</p>
|
<p class="mt-10 mb-0">{{t 'registriesPage.new.form.custom.labelText'}}: {{state.imageRegistry}}</p>
|
||||||
|
|
@ -27,7 +34,7 @@
|
||||||
<div class="col span-12">
|
<div class="col span-12">
|
||||||
<div>
|
<div>
|
||||||
<label class="acc-label">{{t 'registriesPage.new.form.username.labelText'}}</label>
|
<label class="acc-label">{{t 'registriesPage.new.form.username.labelText'}}</label>
|
||||||
{{input class="form-control" value=state.username}}
|
{{input class="form-control" autofocus=true value=state.username}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="acc-label">{{t 'registriesPage.new.form.password.labelText'}}</label>
|
<label class="acc-label">{{t 'registriesPage.new.form.password.labelText'}}</label>
|
||||||
|
|
@ -41,6 +48,11 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{t 'newPipeline.save'}}
|
{{t 'newPipeline.save'}}
|
||||||
</button>
|
</button>
|
||||||
|
{{#unless state.noEditingRegistry}}
|
||||||
|
<button class="btn bg-transparent" {{action "setState" "state.noEditingRegistry" true}} disabled={{or state.savingRegistry (eq state.imageRegistry '')}}>
|
||||||
|
{{t 'generic.cancel'}}
|
||||||
|
</button>
|
||||||
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ newPipelineStep:
|
||||||
pushWarning2: haven't been authenticated, click
|
pushWarning2: haven't been authenticated, click
|
||||||
pushWarning3: to authenticate it.
|
pushWarning3: to authenticate it.
|
||||||
scope: "Scope: Available to all namespaces in this project"
|
scope: "Scope: Available to all namespaces in this project"
|
||||||
|
registryExist: Registry {registry} registered with {username}
|
||||||
task:
|
task:
|
||||||
label: run a script
|
label: run a script
|
||||||
runAsService: Run As a Service
|
runAsService: Run As a Service
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ const DEFAULT_CONFIG = {
|
||||||
schedule: '0 * * * *',
|
schedule: '0 * * * *',
|
||||||
successfulJobsHistoryLimit: HISTORY_LIMIT,
|
successfulJobsHistoryLimit: HISTORY_LIMIT,
|
||||||
},
|
},
|
||||||
jobConfig: {
|
job: {
|
||||||
type: 'jobConfig',
|
type: 'jobConfig',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,13 @@
|
||||||
<p class="text-small text-muted" style="margin: 0 0 0 45px;">{{pretty-cron workload.cronJobConfig.schedule 'toString'}}</p>
|
<p class="text-small text-muted" style="margin: 0 0 0 45px;">{{pretty-cron workload.cronJobConfig.schedule 'toString'}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="radio">
|
||||||
|
<label>
|
||||||
|
{{radio-button selection=scaleMode value="job"}}
|
||||||
|
<i class="icon icon-lg icon-file"></i>
|
||||||
|
{{t 'formScale.scaleMode.job'}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="form-control-static">
|
<div class="form-control-static">
|
||||||
{{#if (eq scaleMode "deployment")}}
|
{{#if (eq scaleMode "deployment")}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue