-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3df8a15
commit 17dac15
Showing
8 changed files
with
291 additions
and
276 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/main/client/app/pages/modules/import/manual-import.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template> | ||
<div class="col-md-4"> | ||
<b-card no-body> | ||
<b-button | ||
size="lg" | ||
variant="outline-danger" | ||
squared | ||
@click="toggle" | ||
> | ||
<font-awesome-icon :icon="['fab', 'superpowers']" /> manually | ||
</b-button> | ||
|
||
<b-card v-if="selected === 'manual'"> | ||
<b-card-text> | ||
<b-form-group | ||
label="Enter the module name" | ||
label-for="module-name" | ||
> | ||
<b-form-input | ||
id="module-name" | ||
v-model="moduleName" | ||
trim | ||
/> | ||
</b-form-group> | ||
</b-card-text> | ||
|
||
<b-button | ||
:disabled="! moduleName" | ||
href="#" | ||
variant="primary" | ||
@click="createModule" | ||
> | ||
Import manually | ||
</b-button> | ||
</b-card> | ||
|
||
<template v-slot:footer> | ||
<em>Import a module manually (only for users with superpowers)</em> | ||
</template> | ||
</b-card> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios'; | ||
export default { | ||
name: 'ManualImport', | ||
props: { | ||
selected: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data: () => ({ moduleName: null }), | ||
methods: { | ||
toggle() { | ||
this.$emit('toggle'); | ||
}, | ||
async createModule() { | ||
let module = { | ||
name: this.moduleName, | ||
}; | ||
const response = await axios.post('/api/modules', module); | ||
module = response.data; | ||
await this.$router.push({ name: 'module', params: { id: module.id } }); | ||
}, | ||
}, | ||
}; | ||
</script> |
122 changes: 122 additions & 0 deletions
122
src/main/client/app/pages/modules/import/registry-import.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<template> | ||
<div class="col-md-4"> | ||
<b-card no-body> | ||
<b-button | ||
size="lg" | ||
variant="outline-secondary" | ||
:class="'btn-' + registry" | ||
squared | ||
@click="toggle" | ||
> | ||
<font-awesome-icon :icon="['fab', registry]" /> from {{ registry }} | ||
</b-button> | ||
|
||
<b-card v-if="selected === registry"> | ||
<b-card-text> | ||
<label for="repoSelect">Select your {{ registry }} repository</label> | ||
<vue-multiselect | ||
id="repoSelect" | ||
v-model="selectedRepository" | ||
placeholder="Type to search" | ||
label="fullName" | ||
:options="repositories" | ||
:loading="isLoading" | ||
@open="search" | ||
> | ||
<span slot="noResult">Oops! No repository found. </span> | ||
</vue-multiselect> | ||
</b-card-text> | ||
|
||
<b-button | ||
:disabled="! selectedRepository" | ||
variant="primary" | ||
@click="importRepository" | ||
> | ||
Import this repository ! | ||
</b-button> | ||
</b-card> | ||
|
||
<template v-slot:footer> | ||
<em>Import an existing module code from existing {{ registry }} repository</em> | ||
</template> | ||
</b-card> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import axios from 'axios'; | ||
export default { | ||
name: 'RegistryImport', | ||
props: { | ||
registry: { | ||
type: String, | ||
required: true, | ||
}, | ||
selected: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data: () => ( | ||
{ | ||
selectedRepository: null, | ||
repositories: [], | ||
isLoading: false, | ||
loaded: false, | ||
isImporting: false, | ||
} | ||
), | ||
methods: { | ||
toggle() { | ||
this.$emit('toggle'); | ||
}, | ||
async search() { | ||
if (!this.loaded) { | ||
this.isLoading = true; | ||
const response = await axios.get(`/api/registries/${this.registry}/repositories`); | ||
this.repositories = response.data; | ||
this.loaded = true; | ||
this.isLoading = false; | ||
} | ||
}, | ||
async importRepository() { | ||
this.isImporting = true; | ||
this.$bvToast.toast('Importing module from repository', { | ||
noCloseButton: true, | ||
solid: true, | ||
variant: 'info', | ||
toaster: 'b-toaster-top-center', | ||
}); | ||
const id = this.selectedRepository.id ? this.selectedRepository.id : this.selectedRepository.fullName; | ||
const response = await axios.get(`/api/registries/${this.registry}/repositories/${id}/import`); | ||
const module = response.data; | ||
await this.$router.push({ name: 'module', params: { id: module.id } }); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
.btn-gitlab { | ||
color: #fca326; | ||
} | ||
.btn-gitlab:hover { | ||
background-color: #fca326; | ||
border-color: #fca326; | ||
color: #fff; | ||
} | ||
.btn-github { | ||
color: #333; | ||
} | ||
.btn-github:hover { | ||
background-color: #333; | ||
border-color: #333; | ||
color: #fff; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.