Skip to content
Snippets Groups Projects
Commit 95bfb79c authored by michael.minelli's avatar michael.minelli
Browse files

EnonceCreate => Add template argument on creation

parent fdde2c1e
No related branches found
No related tags found
No related merge requests found
......@@ -90,6 +90,7 @@ class EnonceCreateCommand extends CommanderCommand {
protected async commandAction(options: any): Promise<void> {
let members!: Array<GitlabUser> | false;
let templateIdOrNamespace: string | null = null;
// Check access and retrieve data
{
......@@ -105,13 +106,13 @@ class EnonceCreateCommand extends CommanderCommand {
}
if ( options.template ) {
let templateIdOrNamespace: string = options.template;
templateIdOrNamespace = options.template;
if ( Number.isNaN(Number(templateIdOrNamespace)) ) {
templateIdOrNamespace = encodeURIComponent(Toolbox.urlToPath(templateIdOrNamespace));
templateIdOrNamespace = Toolbox.urlToPath(templateIdOrNamespace as string);
}
if ( !await DojoBackendManager.checkTemplateAccess(templateIdOrNamespace) ) {
if ( !await DojoBackendManager.checkTemplateAccess(encodeURIComponent(templateIdOrNamespace as string)) ) {
return;
}
}
......@@ -121,7 +122,7 @@ class EnonceCreateCommand extends CommanderCommand {
{
console.log(chalk.cyan('Please wait while we are creating the enonce...'));
const enonce = await DojoBackendManager.createProject(options.name, members);
const enonce = await DojoBackendManager.createProject(options.name, members, templateIdOrNamespace);
console.log(enonce);
}
......
......@@ -60,7 +60,7 @@ class DojoBackendManager {
}
}
public async createProject(name: string, members: Array<GitlabUser>, verbose: boolean = true): Promise<Enonce> {
public async createProject(name: string, members: Array<GitlabUser>, templateIdOrNamespace: string | null, verbose: boolean = true): Promise<Enonce> {
const spinner: ora.Ora = ora('Creating enonce...');
if ( verbose ) {
......@@ -68,10 +68,10 @@ class DojoBackendManager {
}
try {
const response = await axios.post<Enonce>(this.getApiUrl(ApiRoutes.ENONCE_CREATE), {
const response = await axios.post<Enonce>(this.getApiUrl(ApiRoutes.ENONCE_CREATE), Object.assign({
name : name,
members: JSON.stringify(members)
});
}, templateIdOrNamespace ? { template: templateIdOrNamespace } : {}));
return response.data;
} catch ( error ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment