From 116a6c335b1752af57802f29e7b91e746ef08328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Mon, 19 Jan 2015 16:34:56 +0100 Subject: [PATCH] Adding initial contrib modules system --- app/coffee/app.coffee | 6 +- app/coffee/modules/base.coffee | 1 + app/coffee/modules/base/contrib.coffee | 56 ++++++++++++ app/partials/contrib/main.jade | 12 +++ app/partials/views/modules/admin-menu.jade | 4 + .../views/modules/admin-submenu-contrib.jade | 10 ++ app/styles/modules/admin/admin-menu.scss | 5 +- app/styles/modules/admin/contrib.scss | 91 +++++++++++++++++++ main-sass.js | 1 + 9 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 app/coffee/modules/base/contrib.coffee create mode 100644 app/partials/contrib/main.jade create mode 100644 app/partials/views/modules/admin-submenu-contrib.jade create mode 100644 app/styles/modules/admin/contrib.scss diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index 61d742b4..55ae46d0 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -20,6 +20,7 @@ ### @taiga = taiga = {} +@.taigaContribPlugins = @.taigaContribPlugins or [] # Generic function for generate hash from a arbitrary length # collection of parameters. @@ -104,6 +105,8 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven {templateUrl: "/partials/admin-third-parties-gitlab.html"}) $routeProvider.when("/project/:pslug/admin/third-parties/bitbucket", {templateUrl: "/partials/admin-third-parties-bitbucket.html"}) + $routeProvider.when("/project/:pslug/admin/contrib/:plugin", + {templateUrl: "/partials/contrib/main.html"}) # User settings $routeProvider.when("/project/:pslug/user-settings/user-profile", @@ -218,6 +221,7 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven init = ($log, $i18n, $config, $rootscope, $auth, $events, $analytics) -> $i18n.initialize($config.get("defaultLanguage")) $log.debug("Initialize application") + $rootscope.contribPlugins = @.taigaContribPlugins if $auth.isAuthenticated() $events.setupConnection() @@ -256,7 +260,7 @@ modules = [ # Vendor modules "ngRoute", "ngAnimate", -] +].concat(_.map(@.taigaContribPlugins, (plugin) -> plugin.module)) # Main module definition module = angular.module("taiga", modules) diff --git a/app/coffee/modules/base.coffee b/app/coffee/modules/base.coffee index a3d8c812..7e123634 100644 --- a/app/coffee/modules/base.coffee +++ b/app/coffee/modules/base.coffee @@ -95,6 +95,7 @@ urls = { "project-admin-third-parties-github": "/project/:project/admin/third-parties/github" "project-admin-third-parties-gitlab": "/project/:project/admin/third-parties/gitlab" "project-admin-third-parties-bitbucket": "/project/:project/admin/third-parties/bitbucket" + "project-admin-contrib": "/project/:project/admin/contrib/:plugin" # User settings "user-settings-user-profile": "/project/:project/user-settings/user-profile" diff --git a/app/coffee/modules/base/contrib.coffee b/app/coffee/modules/base/contrib.coffee new file mode 100644 index 00000000..1e9f0c6e --- /dev/null +++ b/app/coffee/modules/base/contrib.coffee @@ -0,0 +1,56 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/base/contrib.coffee +### + +taigaContribPlugins = @.taigaContribPlugins = @.taigaContribPlugins or [] + +class ContribController extends taiga.Controller + @.$inject = ["$rootScope", "$scope", "$routeParams", "$tgRepo", "$tgResources", "$tgConfirm", "$appTitle"] + + constructor: (@rootScope, @scope, @params, @repo, @rs, @confirm, @appTitle) -> + @scope.currentPlugin = _.first(_.where(taigaContribPlugins, {"slug": @params.plugin})) + @scope.pluginTemplate = "contrib/#{@scope.currentPlugin.slug}" + @scope.projectSlug = @params.pslug + @scope.adminPlugins = _.where(@rootScope.contribPlugins, {"type": "admin"}) + + promise = @.loadInitialData() + + promise.then () => + @appTitle.set(@scope.project.name) + + promise.then null, => + @confirm.notify("error") + + loadProject: -> + return @rs.projects.get(@scope.projectId).then (project) => + @scope.project = project + @scope.$emit('project:loaded', project) + @scope.$broadcast('project:loaded', project) + return project + + loadInitialData: -> + promise = @repo.resolve({pslug: @params.pslug}).then (data) => + @scope.projectId = data.project + return data + + return promise.then(=> @.loadProject()) + +module = angular.module("taigaBase") +module.controller("ContribController", ContribController) diff --git a/app/partials/contrib/main.jade b/app/partials/contrib/main.jade new file mode 100644 index 00000000..82c097f8 --- /dev/null +++ b/app/partials/contrib/main.jade @@ -0,0 +1,12 @@ +block head + title Taiga Your agile, free, and open source project management tool + +block content + div.wrapper.roles(ng-init="section='admin'", ng-controller="ContribController as ctrl") + sidebar.menu-secondary.sidebar(tg-admin-navigation="contrib") + include ../views/modules/admin-menu + + sidebar.menu-tertiary.sidebar + include ../views/modules/admin-submenu-contrib + + section.main.admin-common.admin-contrib(ng-include="pluginTemplate") diff --git a/app/partials/views/modules/admin-menu.jade b/app/partials/views/modules/admin-menu.jade index 198667f3..00872bf9 100644 --- a/app/partials/views/modules/admin-menu.jade +++ b/app/partials/views/modules/admin-menu.jade @@ -24,3 +24,7 @@ section.admin-menu a(href="" tg-nav="project-admin-third-parties-github:project=project.slug") span.title Third parties span.icon.icon-arrow-right + li#adminmenu-contrib(ng-show="contribPlugins") + a(href="" tg-nav="project-admin-contrib:project=project.slug,plugin=contribPlugins[0].slug") + span.title Contrib plugins + span.icon.icon-arrow-right diff --git a/app/partials/views/modules/admin-submenu-contrib.jade b/app/partials/views/modules/admin-submenu-contrib.jade new file mode 100644 index 00000000..557a0c1e --- /dev/null +++ b/app/partials/views/modules/admin-submenu-contrib.jade @@ -0,0 +1,10 @@ +section.admin-submenu + header + h1 Contrib plugins + + nav + ul + li#adminmenu-contrib(ng-repeat="plugin in adminPlugins") + a(href="", tg-nav="project-admin-contrib:project=projectSlug,plugin=plugin.slug" ng-class="{active: plugin.slug == currentPlugin.slug}") + span.title {{ plugin.name }} + span.icon.icon-arrow-right diff --git a/app/styles/modules/admin/admin-menu.scss b/app/styles/modules/admin/admin-menu.scss index 02e12c55..ff92c3b4 100644 --- a/app/styles/modules/admin/admin-menu.scss +++ b/app/styles/modules/admin/admin-menu.scss @@ -11,6 +11,7 @@ a { display: block; padding: 1rem 0 1rem 1rem; + &.active, &:hover { .icon { opacity: 1; @@ -18,10 +19,6 @@ } } } - .active { - opacity: 1; - transition: opacity .3s linear; - } .icon { color: $blackish; float: right; diff --git a/app/styles/modules/admin/contrib.scss b/app/styles/modules/admin/contrib.scss new file mode 100644 index 00000000..9f7c7cf5 --- /dev/null +++ b/app/styles/modules/admin/contrib.scss @@ -0,0 +1,91 @@ +.admin-contrib { + form { + margin: 1rem 0; + max-width: 700px; + width: 100%; + } + input[type="text"], + textarea { + @extend %title; + } + fieldset { + margin-bottom: 1rem; + } + label { + @extend %title; + display: block; + margin-bottom: .2rem; + } + textarea { + height: 10rem; + } + .button-green { + color: $white; + display: block; + text-align: center; + } + .select-input-text { + .field-with-option { + display: flex; + } + .option-wrapper { + align-items: center; + border: 1px solid $gray-light; + border-left: 0; + border-radius: 0 5px 5px 0; + cursor: pointer; + display: flex; + padding: 0 1rem; + } + .help-copy { + @extend %small; + opacity: 0; + &.visible { + opacity: 1; + transition: opacity .2s linear; + } + } + } + .help { + margin-top: 2rem; + h3 { + font-family: opensans-semibold; + margin-bottom: 1rem; + } + ol { + padding: 0 0 0 2rem; + span { + font-family: opensans-semibold; + } + } + .img { + margin-bottom: 1rem; + } + .alt-image { + @extend %small; + font-style: italic; + } + code { + @extend %small; + background: $whitish; + direction: ltr; + display: block; + font-family: 'courier new', 'monospace'; + line-height: 1.4rem; + margin-bottom: 1rem; + padding: .5rem; + unicode-bidi: embed; + white-space: pre; + width: 100%; + } + .code-info { + padding-left: 1rem; + li { + margin-bottom: .5rem; + } + span { + font-family: opensans-semibold; + } + } + } +} diff --git a/main-sass.js b/main-sass.js index 511ac228..68df15c7 100644 --- a/main-sass.js +++ b/main-sass.js @@ -124,6 +124,7 @@ exports.files = function () { 'modules/admin/default-values', 'modules/admin/project-values', 'modules/admin/third-parties', + 'modules/admin/contrib', //Modules user Settings 'modules/user-settings/user-profile',