@@ -123,36 +123,46 @@ export default {
123123 * @return {*} void
124124 */
125125 emitSubmit () {
126- if (this .activeTab == 1 ) {
127- const cleanedCommand = this .dockerCliCommands .replace (/ `#. *? `/ g , ' ' ).replace (/ #. * $ / gm , ' ' ).trim ();
128- this .dockerComposeCommands = Composerize (cleanedCommand, null , ' v3x' );
129- this .dockerComposeCommands = this .addTitleToYaml (this .dockerComposeCommands )
130- this .$emit (' update' , this .dockerComposeCommands )
131- this .$emit (' close' )
132- } else if (this .activeTab == 0 ) {
133- this .dockerComposeCommands = this .addTitleToYaml (this .dockerComposeCommands )
134- this .errors = " "
135- this .$emit (' update' , this .dockerComposeCommands )
136- this .$emit (' close' )
137- } else if (this .activeTab == 2 ) {
138- if (this .appFileLoaded ) {
139- this .errors = " "
126+ switch (this .activeTab ) {
127+ case 0 :
128+ this .dockerComposeCommands = this .addTitleToYaml (this .dockerComposeCommands )
129+ this .errors = ' '
130+ this .$emit (' update' , this .dockerComposeCommands )
140131 this .$emit (' close' )
141- } else {
142- this .errors = this .$t (' Please import a valid App file' )
143- this .parseError = true ;
132+ break
133+ case 1 : {
134+ const cleanedCommand = this .dockerCliCommands .replace (/ `#. *? `/ g , ' ' ).replace (/ #. * $ / gm , ' ' ).trim ()
135+ this .dockerComposeCommands = Composerize (cleanedCommand)
136+ this .dockerComposeCommands = this .addTitleToYaml (this .dockerComposeCommands )
137+ this .$emit (' update' , this .dockerComposeCommands )
138+ this .$emit (' close' )
139+ break
144140 }
141+ case 2 :
142+ if (this .appFileLoaded ) {
143+ this .errors = ' '
144+ this .$emit (' close' )
145+ }
146+ else {
147+ this .errors = this .$t (' Please import a valid App file' )
148+ this .parseError = true
149+ }
150+ break
145151 }
146152 },
147153
148154 addTitleToYaml (yaml ) {
149155 const yamlObj = parse (yaml)
156+ if (yamlObj[' x-casaos' ] !== undefined )
157+ return yaml
158+
150159 const serviceName = Object .keys (yamlObj .services )[0 ]
151- if (serviceName == undefined ) return stringify (yamlObj)
160+ if (serviceName === undefined )
161+ return stringify (yamlObj)
152162 yamlObj[' x-casaos' ] = {}
153163 yamlObj[' x-casaos' ].title = {}
154164 yamlObj[' x-casaos' ].title .en_us = serviceName
155- yamlObj[' x-casaos' ].icon = ` https://cdn.jsdelivr.net/gh/IceWhaleTech/CasaOS-AppStore@ main/Apps /${ serviceName} /icon .png`
165+ yamlObj[' x-casaos' ].icon = ` https://icon.casaos.io/ main/all /${ serviceName} .png`
156166 return stringify (yamlObj)
157167 },
158168
0 commit comments