Skip to content

Commit

Permalink
no selection modal when only one daemon
Browse files Browse the repository at this point in the history
Signed-off-by: janepie <[email protected]>
  • Loading branch information
janepie committed Sep 27, 2024
1 parent 482bde2 commit 64a8d39
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 45 deletions.
2 changes: 1 addition & 1 deletion js/app_api-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143345,7 +143345,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"compressed":true,"categories":[{"id"
/******/ // This function allow to reference async chunks
/******/ __webpack_require__.u = (chunkId) => {
/******/ // return url for filenames based on template
/******/ return "app_api-" + chunkId + ".js?v=" + {"node_modules_nextcloud_dialogs_dist_chunks_index-C1azEbgd_mjs":"ce0d37e24678dfb5ef24","vendors-node_modules_vue-material-design-icons_Alert_vue-node_modules_vue-material-design-ico-b44ec1":"276c7b3da988dc665f35","src_views_Apps_vue":"c83d1d4fb9f3473331b9","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-CDU2njOJ_mjs":"5cd69d99367c861809dd"}[chunkId] + "";
/******/ return "app_api-" + chunkId + ".js?v=" + {"node_modules_nextcloud_dialogs_dist_chunks_index-C1azEbgd_mjs":"ce0d37e24678dfb5ef24","vendors-node_modules_vue-material-design-icons_Alert_vue-node_modules_vue-material-design-ico-b44ec1":"276c7b3da988dc665f35","src_views_Apps_vue":"1db7dec7e96ddf8caad3","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-CDU2njOJ_mjs":"5cd69d99367c861809dd"}[chunkId] + "";
/******/ };
/******/ })();
/******/
Expand Down
2 changes: 1 addition & 1 deletion js/app_api-main.js.map

Large diffs are not rendered by default.

58 changes: 32 additions & 26 deletions js/app_api-src_views_Apps_vue.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/app_api-src_views_Apps_vue.js.map

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion src/components/Apps/AppItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
:aria-label="enableButtonTooltip"
type="primary"
:disabled="!app.canInstall || installing || isLoading || !defaultDeployDaemonAccessible || isInitializing || isDeploying"
@click="showSelectionModal">
@click="enableButtonAction">
{{ enableButtonText }}
</NcButton>
<NcButton v-else-if="!app.active"
Expand All @@ -106,6 +106,7 @@
<DaemonSelectionModal
v-if="selectDaemonModal"
:show.sync="selectDaemonModal"
:daemons="dockerDaemons"
:app="app" />
</component>
</component>
Expand All @@ -118,6 +119,9 @@ import SvgFilterMixin from './SvgFilterMixin.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import DaemonSelectionModal from './DaemonSelectionModal.vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
export default {
name: 'AppItem',
components: {
Expand Down Expand Up @@ -157,6 +161,7 @@ export default {
scrolled: false,
screenshotLoaded: false,
selectDaemonModal: false,
dockerDaemons: [],
}
},
computed: {
Expand All @@ -181,6 +186,7 @@ export default {
}
image.src = this.app.screenshot
}
this.getAllDockerDaemons()
},
methods: {
async showAppDetails(event) {
Expand All @@ -206,6 +212,21 @@ export default {
showSelectionModal() {
this.selectDaemonModal = true
},
getAllDockerDaemons() {
return axios.get(generateUrl('/apps/app_api/daemons'))
.then(res => {
this.dockerDaemons = res.data.daemons.filter(function(daemon) {
return daemon.accepts_deploy_id === 'docker-install'
})
})
},
enableButtonAction() {
if (this.dockerDaemons.length === 1) {
this.enable(this.app.id, this.dockerDaemons[0])
} else {
this.showSelectionModal()
}
},
},
}
</script>
Expand Down
1 change: 0 additions & 1 deletion src/components/Apps/DaemonSelectionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default {
},
methods: {
closeModal() {
console.warn(this.daemons)
this.$emit('close')
},
},
Expand Down
19 changes: 5 additions & 14 deletions src/components/Apps/DaemonSelectionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="select-modal-body">
<h3>{{ t('app_api', 'Choose Deploy Daemon for {appName}', {appName: app.name }) }}</h3>
<DaemonSelectionList
:daemons.sync="daemons"
:daemons="daemons"
:default-daemon.sync="default_daemon_config"
:app-id="app.id"
@close="closeModal" />
Expand All @@ -16,8 +16,6 @@
<script>
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import DaemonSelectionList from './DaemonSelectionList.vue'
export default {
Expand All @@ -36,31 +34,24 @@ export default {
type: Object,
required: true,
},
daemons: {
type: Array,
required: true,
},
},
data() {
return {
selectDaemonModal: false,
selectedDaemon: 'Cheese',
daemons: [],
default_daemon_config: '',
}
},
mounted() {
this.getAllDaemons()
},
methods: {
closeModal() {
this.$emit('update:show', false)
},
getAllDaemons() {
return axios.get(generateUrl('/apps/app_api/daemons'))
.then(res => {
this.daemons = res.data.daemons
this.default_daemon_config = res.data.default_daemon_config
})
},
},
}
</script>
Expand Down

0 comments on commit 64a8d39

Please sign in to comment.