mirror of https://github.com/rancher/ui.git
commit
acf4d3cc96
|
|
@ -9,6 +9,9 @@
|
|||
{{#link-to (query-params group="namespace") classNames="btn btn-sm bg-default"}}<i class="icon icon-list-nested"></i>{{/link-to}}
|
||||
{{/tooltip-element}}
|
||||
</div>
|
||||
|
||||
<button {{action 'importYaml'}} class="btn btn-sm bg-default mr-10" disabled={{rbac-prevents resource="configmap" scope="project" permission="create"}}>{{t 'nav.containers.importCompose'}}</button>
|
||||
|
||||
{{#link-to "authenticated.project.config-maps.new" classNames="btn btn-sm bg-primary" disabled=(rbac-prevents resource=resource scope="project" permission="create")}}{{t 'configMapsPage.index.linkTo'}}{{/link-to}}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,10 +38,11 @@
|
|||
</div>
|
||||
|
||||
<div class="box mt-10">
|
||||
<label class="acc-label">{{t 'newConfigMap.values.label'}}</label>
|
||||
{{form-key-value
|
||||
initialMap=primaryResource.data
|
||||
allowEmptyValue=true
|
||||
header=(t 'newConfigMap.values.label')
|
||||
allowUpload=true
|
||||
addActionLabel="newConfigMap.addActionLabel"
|
||||
addInitialEmptyRow=true
|
||||
editing=notView
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { on } from '@ember/object/evented';
|
||||
import { next, debounce } from '@ember/runloop';
|
||||
import Component from '@ember/component';
|
||||
import { get, set, observer } from '@ember/object';
|
||||
import { get, set, observer } from '@ember/object'
|
||||
import Upload from 'shared/mixins/upload';
|
||||
import layout from './template';
|
||||
|
||||
function applyLinesIntoArray(lines, ary) {
|
||||
|
|
@ -55,7 +56,7 @@ function removeEmptyEntries(ary, allowEmptyValue = false) {
|
|||
ary.removeObjects(toRemove);
|
||||
}
|
||||
|
||||
export default Component.extend({
|
||||
export default Component.extend(Upload, {
|
||||
layout,
|
||||
// Inputs
|
||||
initialStr: null,
|
||||
|
|
@ -65,6 +66,7 @@ export default Component.extend({
|
|||
ary: null,
|
||||
allowEmptyValue: false,
|
||||
allowAdd: true,
|
||||
allowUpload: false,
|
||||
allowRemove: true,
|
||||
allowEditKey: true,
|
||||
addInitialEmptyRow: false,
|
||||
|
|
@ -79,6 +81,8 @@ export default Component.extend({
|
|||
valueLabel: 'formKeyValue.value.label',
|
||||
keyPlaceholder: 'formKeyValue.key.placeholder',
|
||||
valuePlaceholder: 'formKeyValue.value.placeholder',
|
||||
uploadAction: 'pastedValues',
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
<div class="clearfix">
|
||||
{{#if header}}
|
||||
<label class="acc-label">{{header}}</label>
|
||||
<div class="pull-left">
|
||||
<label class="acc-label">{{header}}</label>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if (and allowUpload editing)}}
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-sm bg-primary" {{action 'upload'}}>{{t 'uploadFile.label'}} <span class="icon icon-upload"></span></button>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
|
|
@ -75,3 +83,4 @@
|
|||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
<input type="file" accept="text/*" class="hide">
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="modal-yaml">
|
||||
{{input-yaml
|
||||
title=(if editing (t (if readOnly 'modalYaml.title.view' 'modalYaml.title.edit') name=model.resource.displayName) (t 'modalYaml.title.new' type=(uc-first model.resource.displayName)))
|
||||
name=filename
|
||||
filename=filename
|
||||
canChangeName=false
|
||||
value=model.yaml
|
||||
loading=loading
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
import Mixin from '@ember/object/mixin';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { get } from '@ember/object';
|
||||
|
||||
export default Mixin.create({
|
||||
growl: service(),
|
||||
|
||||
actions: {
|
||||
upload() {
|
||||
this.$('INPUT[type=file]')[0].click();
|
||||
},
|
||||
},
|
||||
|
||||
change(event) {
|
||||
const input = event.target;
|
||||
|
||||
if ( input.files && input.files[0] ) {
|
||||
let file = input.files[0];
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onerror = (err) => {
|
||||
get(this, 'growl').fromError(get(err, 'srcElement.error.message'));
|
||||
};
|
||||
|
||||
reader.onload = (event2) => {
|
||||
const out = event2.target.result;
|
||||
|
||||
this.send(get(this, 'uploadAction'), out);
|
||||
input.value = '';
|
||||
};
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
export { default } from 'shared/mixins/upload';
|
||||
Loading…
Reference in New Issue