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 layout from './template';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { set, get } from '@ember/object';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
|
|
@ -25,6 +26,8 @@ export default Component.extend({
|
|||
imageTag: '',
|
||||
registryExist: true,
|
||||
savingRegistry: false,
|
||||
selectedRegistry: null,
|
||||
noEditingRegistry: true,
|
||||
},
|
||||
init(){
|
||||
this._super(...arguments);
|
||||
|
|
@ -45,7 +48,8 @@ export default Component.extend({
|
|||
let registry = Object.keys(ele.registries)[0];
|
||||
return {
|
||||
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(){
|
||||
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('modalState.saveDisabled', false);
|
||||
}else{
|
||||
|
|
@ -76,20 +82,64 @@ export default Component.extend({
|
|||
}
|
||||
})),
|
||||
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(){
|
||||
let state = this.get('state');
|
||||
let noEditing = get(this, 'state.noEditingRegistry');
|
||||
this.set('state.savingRegistry', true);
|
||||
this.get('store').createRecord({
|
||||
type: 'dockerCredential',
|
||||
registries: {
|
||||
[`${state.imageRegistry}`]: {
|
||||
username: state.username,
|
||||
password: state.password,
|
||||
if(noEditing){
|
||||
this.get('store').createRecord({
|
||||
type: 'dockerCredential',
|
||||
registries: {
|
||||
[`${state.imageRegistry}`]: {
|
||||
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(()=>{
|
||||
this.set('state.savingRegistry', false);
|
||||
});
|
||||
let serilizedRegistry = selectedOriginRegistry.serialize();
|
||||
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}}
|
||||
</div>
|
||||
{{#if registryField}}
|
||||
{{#if state.registryExist}}
|
||||
{{banner-message icon="icon-success" color='bg-success mb-0 mt-10' message=(concat "Registry " state.imageRegistry " exists")}}
|
||||
{{#if (and state.registryExist state.noEditingRegistry)}}
|
||||
{{#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}}
|
||||
{{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">
|
||||
<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>
|
||||
|
|
@ -27,7 +34,7 @@
|
|||
<div class="col span-12">
|
||||
<div>
|
||||
<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>
|
||||
<label class="acc-label">{{t 'registriesPage.new.form.password.labelText'}}</label>
|
||||
|
|
@ -41,6 +48,11 @@
|
|||
{{/if}}
|
||||
{{t 'newPipeline.save'}}
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ newPipelineStep:
|
|||
pushWarning2: haven't been authenticated, click
|
||||
pushWarning3: to authenticate it.
|
||||
scope: "Scope: Available to all namespaces in this project"
|
||||
registryExist: Registry {registry} registered with {username}
|
||||
task:
|
||||
label: run a script
|
||||
runAsService: Run As a Service
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const DEFAULT_CONFIG = {
|
|||
schedule: '0 * * * *',
|
||||
successfulJobsHistoryLimit: HISTORY_LIMIT,
|
||||
},
|
||||
jobConfig: {
|
||||
job: {
|
||||
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>
|
||||
{{/if}}
|
||||
</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}}
|
||||
<div class="form-control-static">
|
||||
{{#if (eq scaleMode "deployment")}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue