New modal to permit admin select user repo for work
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1859a715df
commit
f79c7b43cd
@ -57,6 +57,11 @@ func initializeGitLabOIDC(router *gin.Engine, authrouter *gin.RouterGroup, admin
|
||||
}
|
||||
|
||||
authrouter.GET("/api/gitlabcri/repositories", GitLab_GetMyRepositories)
|
||||
|
||||
usersRoutes := authrouter.Group("/api/users/:uid")
|
||||
usersRoutes.Use(userHandler)
|
||||
usersRoutes.Use(sameUserMiddleware)
|
||||
usersRoutes.GET("/gitlabcri/repositories", GitLab_GetMyRepositories)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(OAUTH_GITLAB_FILE); err == nil {
|
||||
|
@ -12,6 +12,7 @@
|
||||
export { className as class };
|
||||
|
||||
export let work = {};
|
||||
export let user = null;
|
||||
export let readonly = false;
|
||||
|
||||
let repo_work = null;
|
||||
@ -36,24 +37,28 @@
|
||||
show_logs = repo.getBuildLogs()
|
||||
}
|
||||
|
||||
function refresh_repo_work() {
|
||||
function refresh_repo_work(user) {
|
||||
if (user != null) {
|
||||
repo_work = getRepositories(work.id, user.id);
|
||||
} else {
|
||||
repo_work = getRepositories(work.id);
|
||||
}
|
||||
repo_work.then((repos) => {
|
||||
repo_used = repos[0];
|
||||
updatePullState(repos[0])
|
||||
}, () => {
|
||||
repo_used = new WorkRepository({id_work: work.id});
|
||||
remote_repos = getRemoteRepositories();
|
||||
remote_repos = getRemoteRepositories(user?user.id:null);
|
||||
});
|
||||
}
|
||||
refresh_repo_work();
|
||||
$: refresh_repo_work(user);
|
||||
|
||||
let submitInProgress = false;
|
||||
function submitWorkRepository() {
|
||||
submitInProgress = true;
|
||||
repo_used.save().then(() => {
|
||||
repo_used.save(user).then(() => {
|
||||
submitInProgress = false;
|
||||
refresh_repo_work();
|
||||
refresh_repo_work(user);
|
||||
}, (error) => {
|
||||
submitInProgress = false;
|
||||
ToastsStore.addErrorToast({
|
||||
@ -66,7 +71,7 @@
|
||||
submitInProgress = true;
|
||||
repo.retrieveWork().then(() => {
|
||||
submitInProgress = false;
|
||||
refresh_repo_work();
|
||||
refresh_repo_work(user);
|
||||
}, (error) => {
|
||||
submitInProgress = false;
|
||||
ToastsStore.addErrorToast({msg: "Une erreur s'est produite : " + error});
|
||||
@ -124,7 +129,7 @@
|
||||
type="button"
|
||||
class="btn btn-outline-danger float-end mt-1"
|
||||
disable={submitInProgress || readonly}
|
||||
on:click={() => repo.delete().then(() => { refresh_repo_work() }, (error) => ToastsStore.addErrorToast({msg: "Une erreur s'est produite durant la suppression du lien : " + error}))}
|
||||
on:click={() => repo.delete().then(() => { refresh_repo_work(user) }, (error) => ToastsStore.addErrorToast({msg: "Une erreur s'est produite durant la suppression du lien : " + error}))}
|
||||
>
|
||||
Supprimer cette liaison
|
||||
</button>
|
||||
@ -169,7 +174,7 @@
|
||||
type="button"
|
||||
class="mt-2 btn btn-info"
|
||||
title="Rafraîchir la liste des dépôts"
|
||||
on:click={() => remote_repos = getRemoteRepositories()}
|
||||
on:click={() => remote_repos = getRemoteRepositories(user?user.id:null)}
|
||||
>
|
||||
<i class="bi bi-arrow-clockwise"></i>
|
||||
</button>
|
||||
|
@ -69,12 +69,15 @@ export class WorkRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async save() {
|
||||
async save(user) {
|
||||
let url = this.id?`repositories/${this.id}`:'repositories';
|
||||
|
||||
if (this.id_work) {
|
||||
url = `works/${this.id_work}/` + url;
|
||||
}
|
||||
if (user != null) {
|
||||
url = `users/${user.id}/` + url;
|
||||
}
|
||||
|
||||
const res = await fetch("api/"+url, {
|
||||
method: this.id?'PUT':'POST',
|
||||
|
@ -18,6 +18,7 @@
|
||||
import DateFormat from '../../../components/DateFormat.svelte';
|
||||
import SubmissionStatus from '../../../components/SubmissionStatus.svelte';
|
||||
import SurveyBadge from '../../../components/SurveyBadge.svelte';
|
||||
import WorkRepository from '../../../components/WorkRepository.svelte';
|
||||
import { getRepositories } from '../../../lib/repositories';
|
||||
import { ToastsStore } from '../../../stores/toasts';
|
||||
import { getUsers } from '../../../lib/users';
|
||||
@ -38,6 +39,7 @@
|
||||
|
||||
let show_logs = null;
|
||||
let run_pull_for = {repo: null, user: null, tag: null};
|
||||
let search_repo_for = {repo: null, user: null};
|
||||
</script>
|
||||
|
||||
{#await work then w}
|
||||
@ -96,7 +98,16 @@
|
||||
{/each}
|
||||
</div>
|
||||
{:catch err}
|
||||
<div class="d-flex justify-content-between">
|
||||
-
|
||||
<button
|
||||
class="btn btn-sm btn-info mx-1"
|
||||
title="Choisir un dépôt"
|
||||
on:click={() => { search_repo_for = { repo: null, user, modal: new bootstrap.Modal(document.getElementById('repoModal'))}; search_repo_for.modal.show(); }}
|
||||
>
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
{/await}
|
||||
</td>
|
||||
<td>
|
||||
@ -136,6 +147,22 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" tabindex="-1" id="repoModal">
|
||||
<div class="modal-dialog">
|
||||
<form class="modal-content" on:submit|preventDefault={() => {search_repo_for.modal.hide(); try { search_repo_for.repo.retrieveWork(run_pull_for.tag) } catch(err) { ToastsStore.addToast({color: "danger", title: "Connexion impossible", msg: err}) }; search_repo_for.user = null; }}>
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Repository selector {#if search_repo_for.user}{search_repo_for.user.login}{/if}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{#if search_repo_for.user}
|
||||
<WorkRepository work={w} user={search_repo_for.user} />
|
||||
{/if}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<div class="modal fade" tabindex="-1" id="logsModal">
|
||||
|
Reference in New Issue
Block a user