Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-30 00:06:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-30 00:06:13 +0300
commit839c080dd0976f19c274eee1331c47985490cd41 (patch)
treeda3af62d5469f80c7555f9e8df11c18049e0334e /app
parent8263f6ee3131cdea3c6041785c32771a6af0b24f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/environments/components/environment_item.vue53
-rw-r--r--app/assets/javascripts/environments/components/environments_table.vue51
-rw-r--r--app/controllers/snippets_controller.rb10
-rw-r--r--app/policies/global_policy.rb3
-rw-r--r--app/policies/personal_snippet_policy.rb3
-rw-r--r--app/views/layouts/header/_new_dropdown.haml3
-rw-r--r--app/views/snippets/_actions.html.haml12
7 files changed, 98 insertions, 37 deletions
diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue
index 748673f05bb..d480984da70 100644
--- a/app/assets/javascripts/environments/components/environment_item.vue
+++ b/app/assets/javascripts/environments/components/environment_item.vue
@@ -43,16 +43,21 @@ export default {
mixins: [environmentItemMixin],
props: {
+ canReadEnvironment: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
+
model: {
type: Object,
required: true,
default: () => ({}),
},
- canReadEnvironment: {
- type: Boolean,
- required: false,
- default: false,
+ tableData: {
+ type: Object,
+ required: true,
},
},
@@ -447,9 +452,13 @@ export default {
class="gl-responsive-table-row"
role="row"
>
- <div class="table-section section-wrap section-15 text-truncate" role="gridcell">
+ <div
+ class="table-section section-wrap text-truncate"
+ :class="tableData.name.spacing"
+ role="gridcell"
+ >
<div v-if="!model.isFolder" class="table-mobile-header" role="rowheader">
- {{ s__('Environments|Environment') }}
+ {{ tableData.name.title }}
</div>
<span v-if="shouldRenderDeployBoard" class="deploy-board-icon" @click="toggleDeployBoard">
@@ -489,7 +498,8 @@ export default {
</div>
<div
- class="table-section section-10 deployment-column d-none d-sm-none d-md-block"
+ class="table-section deployment-column d-none d-sm-none d-md-block"
+ :class="tableData.deploy.spacing"
role="gridcell"
>
<span v-if="shouldRenderDeploymentID" class="text-break-word">
@@ -508,7 +518,11 @@ export default {
</span>
</div>
- <div class="table-section section-15 d-none d-sm-none d-md-block" role="gridcell">
+ <div
+ class="table-section d-none d-sm-none d-md-block"
+ :class="tableData.build.spacing"
+ role="gridcell"
+ >
<a v-if="shouldRenderBuildName" :href="buildPath" class="build-link cgray">
<tooltip-on-truncate
:title="buildName"
@@ -522,8 +536,14 @@ export default {
</a>
</div>
- <div v-if="!model.isFolder" class="table-section section-20" role="gridcell">
- <div role="rowheader" class="table-mobile-header">{{ s__('Environments|Commit') }}</div>
+ <div
+ v-if="!model.isFolder"
+ class="table-section"
+ :class="tableData.commit.spacing"
+ role="gridcell"
+ >
+ <div role="rowheader" class="table-mobile-header">{{ tableData.commit.title }}</div>
+
<div v-if="hasLastDeploymentKey" class="js-commit-component table-mobile-content">
<commit-component
:tag="commitTag"
@@ -539,8 +559,14 @@ export default {
</div>
</div>
- <div v-if="!model.isFolder" class="table-section section-10" role="gridcell">
- <div role="rowheader" class="table-mobile-header">{{ s__('Environments|Updated') }}</div>
+ <div
+ v-if="!model.isFolder"
+ class="table-section"
+ :class="tableData.date.spacing"
+ role="gridcell"
+ >
+ <div role="rowheader" class="table-mobile-header">{{ tableData.date.title }}</div>
+
<span v-if="canShowDate" class="environment-created-date-timeago table-mobile-content">
{{ deployedDate }}
</span>
@@ -548,7 +574,8 @@ export default {
<div
v-if="!model.isFolder && displayEnvironmentActions"
- class="table-section section-30 table-button-footer"
+ class="table-section table-button-footer"
+ :class="tableData.actions.spacing"
role="gridcell"
>
<div class="btn-group table-action-buttons" role="group">
diff --git a/app/assets/javascripts/environments/components/environments_table.vue b/app/assets/javascripts/environments/components/environments_table.vue
index 4464f5e5578..2d2e09c6190 100644
--- a/app/assets/javascripts/environments/components/environments_table.vue
+++ b/app/assets/javascripts/environments/components/environments_table.vue
@@ -4,6 +4,7 @@
*/
import { GlLoadingIcon } from '@gitlab/ui';
import _ from 'underscore';
+import { s__ } from '~/locale';
import environmentTableMixin from 'ee_else_ce/environments/mixins/environments_table_mixin';
import EnvironmentItem from './environment_item.vue';
@@ -41,6 +42,34 @@ export default {
: env,
);
},
+ tableData() {
+ return {
+ // percent spacing for cols, should add up to 100
+ name: {
+ title: s__('Environments|Environment'),
+ spacing: 'section-15',
+ },
+ deploy: {
+ title: s__('Environments|Deployment'),
+ spacing: 'section-10',
+ },
+ build: {
+ title: s__('Environments|Job'),
+ spacing: 'section-15',
+ },
+ commit: {
+ title: s__('Environments|Commit'),
+ spacing: 'section-20',
+ },
+ date: {
+ title: s__('Environments|Updated'),
+ spacing: 'section-10',
+ },
+ actions: {
+ spacing: 'section-30',
+ },
+ };
+ },
},
methods: {
folderUrl(model) {
@@ -79,20 +108,20 @@ export default {
<template>
<div class="ci-table" role="grid">
<div class="gl-responsive-table-row table-row-header" role="row">
- <div class="table-section section-15 environments-name" role="columnheader">
- {{ s__('Environments|Environment') }}
+ <div class="table-section" :class="tableData.name.spacing" role="columnheader">
+ {{ tableData.name.title }}
</div>
- <div class="table-section section-10 environments-deploy" role="columnheader">
- {{ s__('Environments|Deployment') }}
+ <div class="table-section" :class="tableData.deploy.spacing" role="columnheader">
+ {{ tableData.deploy.title }}
</div>
- <div class="table-section section-15 environments-build" role="columnheader">
- {{ s__('Environments|Job') }}
+ <div class="table-section" :class="tableData.build.spacing" role="columnheader">
+ {{ tableData.build.title }}
</div>
- <div class="table-section section-20 environments-commit" role="columnheader">
- {{ s__('Environments|Commit') }}
+ <div class="table-section" :class="tableData.commit.spacing" role="columnheader">
+ {{ tableData.commit.title }}
</div>
- <div class="table-section section-10 environments-date" role="columnheader">
- {{ s__('Environments|Updated') }}
+ <div class="table-section" :class="tableData.date.spacing" role="columnheader">
+ {{ tableData.date.title }}
</div>
</div>
<template v-for="(model, i) in sortedEnvironments" :model="model">
@@ -101,6 +130,7 @@ export default {
:key="`environment-item-${i}`"
:model="model"
:can-read-environment="canReadEnvironment"
+ :table-data="tableData"
/>
<div
@@ -132,6 +162,7 @@ export default {
:key="`env-item-${i}-${index}`"
:model="children"
:can-read-environment="canReadEnvironment"
+ :table-data="tableData"
/>
<div :key="`sub-div-${i}`">
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 5805d068e21..54774df5e76 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -15,13 +15,9 @@ class SnippetsController < ApplicationController
before_action :snippet, only: [:show, :edit, :destroy, :update, :raw]
- # Allow read snippet
+ before_action :authorize_create_snippet!, only: [:new, :create]
before_action :authorize_read_snippet!, only: [:show, :raw]
-
- # Allow modify snippet
before_action :authorize_update_snippet!, only: [:edit, :update]
-
- # Allow destroy snippet
before_action :authorize_admin_snippet!, only: [:destroy]
skip_before_action :authenticate_user!, only: [:index, :show, :raw]
@@ -140,6 +136,10 @@ class SnippetsController < ApplicationController
return render_404 unless can?(current_user, :admin_personal_snippet, @snippet)
end
+ def authorize_create_snippet!
+ return render_404 unless can?(current_user, :create_personal_snippet)
+ end
+
def snippet_params
params.require(:personal_snippet).permit(:title, :content, :file_name, :private, :visibility_level, :description)
end
diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb
index eca73f0a241..f212bb06bc9 100644
--- a/app/policies/global_policy.rb
+++ b/app/policies/global_policy.rb
@@ -75,12 +75,15 @@ class GlobalPolicy < BasePolicy
rule { ~anonymous }.policy do
enable :read_instance_metadata
+ enable :create_personal_snippet
end
rule { admin }.policy do
enable :read_custom_attribute
enable :update_custom_attribute
end
+
+ rule { external_user }.prevent :create_personal_snippet
end
GlobalPolicy.prepend_if_ee('EE::GlobalPolicy')
diff --git a/app/policies/personal_snippet_policy.rb b/app/policies/personal_snippet_policy.rb
index 03869412d0c..5c62bdd0d95 100644
--- a/app/policies/personal_snippet_policy.rb
+++ b/app/policies/personal_snippet_policy.rb
@@ -17,9 +17,6 @@ class PersonalSnippetPolicy < BasePolicy
enable :create_note
end
- rule { ~anonymous }.enable :create_personal_snippet
- rule { external_user }.prevent :create_personal_snippet
-
rule { internal_snippet & ~external_user }.policy do
enable :read_personal_snippet
enable :create_note
diff --git a/app/views/layouts/header/_new_dropdown.haml b/app/views/layouts/header/_new_dropdown.haml
index e28efb09be5..30109621515 100644
--- a/app/views/layouts/header/_new_dropdown.haml
+++ b/app/views/layouts/header/_new_dropdown.haml
@@ -38,4 +38,5 @@
%li= link_to _('New project'), new_project_path, class: 'qa-global-new-project-link'
- if current_user.can_create_group?
%li= link_to _('New group'), new_group_path
- %li= link_to _('New snippet'), new_snippet_path, class: 'qa-global-new-snippet-link'
+ - if current_user.can?(:create_personal_snippet)
+ %li= link_to _('New snippet'), new_snippet_path, class: 'qa-global-new-snippet-link'
diff --git a/app/views/snippets/_actions.html.haml b/app/views/snippets/_actions.html.haml
index 9952f373156..a408278f7c9 100644
--- a/app/views/snippets/_actions.html.haml
+++ b/app/views/snippets/_actions.html.haml
@@ -7,8 +7,9 @@
- if can?(current_user, :admin_personal_snippet, @snippet)
= link_to snippet_path(@snippet), method: :delete, data: { confirm: _("Are you sure?") }, class: "btn btn-grouped btn-inverted btn-remove", title: _('Delete Snippet') do
= _("Delete")
- = link_to new_snippet_path, class: "btn btn-grouped btn-success btn-inverted", title: _("New snippet") do
- = _("New snippet")
+ - if can?(current_user, :create_personal_snippet)
+ = link_to new_snippet_path, class: "btn btn-grouped btn-success btn-inverted", title: _("New snippet") do
+ = _("New snippet")
- if @snippet.submittable_as_spam_by?(current_user)
= link_to _('Submit as spam'), mark_as_spam_snippet_path(@snippet), method: :post, class: 'btn btn-grouped btn-spam', title: _('Submit as spam')
.d-block.d-sm-none.dropdown
@@ -17,9 +18,10 @@
= icon('caret-down')
.dropdown-menu.dropdown-menu-full-width
%ul
- %li
- = link_to new_snippet_path, title: _("New snippet") do
- = _("New snippet")
+ - if can?(current_user, :create_personal_snippet)
+ %li
+ = link_to new_snippet_path, title: _("New snippet") do
+ = _("New snippet")
- if can?(current_user, :admin_personal_snippet, @snippet)
%li
= link_to snippet_path(@snippet), method: :delete, data: { confirm: _("Are you sure?") }, title: _('Delete Snippet') do