diff --git a/app/authenticated/project/config-maps/index/template.hbs b/app/authenticated/project/config-maps/index/template.hbs
index 95f0073b4..c0d0e58d5 100644
--- a/app/authenticated/project/config-maps/index/template.hbs
+++ b/app/authenticated/project/config-maps/index/template.hbs
@@ -9,6 +9,9 @@
{{#link-to (query-params group="namespace") classNames="btn btn-sm bg-default"}} {{/link-to}}
{{/tooltip-element}}
+
+ {{t 'nav.containers.importCompose'}}
+
{{#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}}
diff --git a/app/components/cru-config-map/template.hbs b/app/components/cru-config-map/template.hbs
index 453802785..987659ccd 100644
--- a/app/components/cru-config-map/template.hbs
+++ b/app/components/cru-config-map/template.hbs
@@ -38,10 +38,11 @@
-
{{t 'newConfigMap.values.label'}}
{{form-key-value
initialMap=primaryResource.data
allowEmptyValue=true
+ header=(t 'newConfigMap.values.label')
+ allowUpload=true
addActionLabel="newConfigMap.addActionLabel"
addInitialEmptyRow=true
editing=notView
diff --git a/lib/shared/addon/components/form-key-value/component.js b/lib/shared/addon/components/form-key-value/component.js
index 57e96bb92..290d68192 100644
--- a/lib/shared/addon/components/form-key-value/component.js
+++ b/lib/shared/addon/components/form-key-value/component.js
@@ -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);
diff --git a/lib/shared/addon/components/form-key-value/template.hbs b/lib/shared/addon/components/form-key-value/template.hbs
index a2143ecd2..5dd1d2dcc 100644
--- a/lib/shared/addon/components/form-key-value/template.hbs
+++ b/lib/shared/addon/components/form-key-value/template.hbs
@@ -1,6 +1,14 @@
{{#if header}}
-
{{header}}
+
+ {{header}}
+
+ {{/if}}
+
+ {{#if (and allowUpload editing)}}
+
+ {{t 'uploadFile.label'}}
+
{{/if}}
@@ -75,3 +83,4 @@
{{/if}}
+
\ No newline at end of file
diff --git a/lib/shared/addon/components/modal-yaml/template.hbs b/lib/shared/addon/components/modal-yaml/template.hbs
index 728b01c10..65f9b782c 100644
--- a/lib/shared/addon/components/modal-yaml/template.hbs
+++ b/lib/shared/addon/components/modal-yaml/template.hbs
@@ -1,7 +1,7 @@
{{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
diff --git a/lib/shared/addon/mixins/upload.js b/lib/shared/addon/mixins/upload.js
new file mode 100644
index 000000000..92bea9e68
--- /dev/null
+++ b/lib/shared/addon/mixins/upload.js
@@ -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);
+ }
+ }
+});
diff --git a/lib/shared/app/mixins/upload.js b/lib/shared/app/mixins/upload.js
new file mode 100644
index 000000000..2c678ae9f
--- /dev/null
+++ b/lib/shared/app/mixins/upload.js
@@ -0,0 +1 @@
+export { default } from 'shared/mixins/upload';