diff options
Diffstat (limited to 'app')
10 files changed, 75 insertions, 21 deletions
diff --git a/app/assets/javascripts/boards/components/sidebar/board_sidebar_time_tracker.vue b/app/assets/javascripts/boards/components/sidebar/board_sidebar_time_tracker.vue index 5d61f7b2887..a35b3f14be4 100644 --- a/app/assets/javascripts/boards/components/sidebar/board_sidebar_time_tracker.vue +++ b/app/assets/javascripts/boards/components/sidebar/board_sidebar_time_tracker.vue @@ -29,6 +29,7 @@ export default { <template> <issuable-time-tracker + :issuable-id="activeBoardItem.id.toString()" :issuable-iid="activeBoardItem.iid.toString()" :limit-to-hours="timeTrackingLimitToHours" :initial-time-tracking="initialTimeTracking" diff --git a/app/assets/javascripts/frequent_items/utils.js b/app/assets/javascripts/frequent_items/utils.js index 88519d934cb..27ef47df8c8 100644 --- a/app/assets/javascripts/frequent_items/utils.js +++ b/app/assets/javascripts/frequent_items/utils.js @@ -35,13 +35,15 @@ export const getTopFrequentItems = (items) => { }; export const updateExistingFrequentItem = (frequentItem, item) => { - const accessedOverHourAgo = - Math.abs(item.lastAccessedOn - frequentItem.lastAccessedOn) / HOUR_IN_MS > 1; + // `frequentItem` comes from localStorage and it's possible it doesn't have a `lastAccessedOn` + const neverAccessed = !frequentItem.lastAccessedOn; + const shouldUpdate = + neverAccessed || Math.abs(item.lastAccessedOn - frequentItem.lastAccessedOn) / HOUR_IN_MS > 1; return { ...item, - frequency: accessedOverHourAgo ? frequentItem.frequency + 1 : frequentItem.frequency, - lastAccessedOn: accessedOverHourAgo ? Date.now() : frequentItem.lastAccessedOn, + frequency: shouldUpdate ? frequentItem.frequency + 1 : frequentItem.frequency, + lastAccessedOn: shouldUpdate ? Date.now() : frequentItem.lastAccessedOn, }; }; diff --git a/app/assets/javascripts/nav/components/top_nav_container_view.vue b/app/assets/javascripts/nav/components/top_nav_container_view.vue index 6f98f85ff90..36e4a278da9 100644 --- a/app/assets/javascripts/nav/components/top_nav_container_view.vue +++ b/app/assets/javascripts/nav/components/top_nav_container_view.vue @@ -20,6 +20,10 @@ export default { type: String, required: true, }, + currentItem: { + type: Object, + required: true, + }, containerClass: { type: String, required: false, @@ -43,6 +47,12 @@ export default { { id: 'secondary', menuItems: this.linksSecondary }, ].filter((x) => x.menuItems?.length); }, + currentItemTimestamped() { + return { + ...this.currentItem, + lastAccessedOn: Date.now(), + }; + }, }, mounted() { // For historic reasons, the frequent-items-app component requires this too start up. @@ -62,7 +72,7 @@ export default { > <div class="frequent-items-dropdown-content gl-w-full! gl-pt-0!"> <vuex-module-provider :vuex-module="frequentItemsVuexModule"> - <frequent-items-app v-bind="$attrs" /> + <frequent-items-app :current-item="currentItemTimestamped" v-bind="$attrs" /> </vuex-module-provider> </div> </div> diff --git a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue index 58167b3934a..d472b67d976 100644 --- a/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue +++ b/app/assets/javascripts/sidebar/components/time_tracking/sidebar_time_tracking.vue @@ -17,6 +17,10 @@ export default { required: false, default: '', }, + issuableId: { + type: String, + required: true, + }, issuableIid: { type: String, required: true, @@ -60,6 +64,7 @@ export default { <div class="block"> <issuable-time-tracker :full-path="fullPath" + :issuable-id="issuableId" :issuable-iid="issuableIid" :limit-to-hours="limitToHours" /> diff --git a/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue b/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue index 3feff8639a1..87ddbbf256a 100644 --- a/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue +++ b/app/assets/javascripts/sidebar/components/time_tracking/time_tracker.vue @@ -31,7 +31,11 @@ export default { directives: { GlModal: GlModalDirective, }, - inject: ['issuableType'], + inject: { + issuableType: { + default: null, + }, + }, props: { limitToHours: { type: Boolean, @@ -43,6 +47,11 @@ export default { required: false, default: '', }, + issuableId: { + type: String, + required: false, + default: '', + }, issuableIid: { type: String, required: false, @@ -83,15 +92,18 @@ export default { return timeTrackingQueries[this.issuableType].query; }, skip() { - // We don't fetch info via GraphQL in following cases - // 1. Time tracking info was provided via prop - // 2. issuableIid and fullPath are not provided. - if (!this.initialTimeTracking) { - return false; - } else if (this.issuableIid && this.fullPath) { - return false; + // Skip the query if either of the conditions are true + // 1. issuableType is not provided + // 2. Time tracking info was provided via prop + // 3. issuableIid and fullPath are not provided + if (!this.issuableType || !timeTrackingQueries[this.issuableType]) { + return true; + } else if (this.initialTimeTracking) { + return true; + } else if (!this.issuableIid || !this.fullPath) { + return true; } - return true; + return false; }, variables() { return { @@ -108,7 +120,7 @@ export default { }, computed: { isTimeTrackingInfoLoading() { - return this.$apollo?.queries.issuableTimeTracking.loading ?? false; + return this.$apollo?.queries.issuableTimeTracking?.loading ?? false; }, timeEstimate() { return this.timeTracking?.timeEstimate || 0; @@ -146,7 +158,7 @@ export default { isTimeReportSupported() { return ( [IssuableType.Issue, IssuableType.MergeRequest].includes(this.issuableType) && - this.issuableIid + this.issuableId ); }, }, @@ -240,7 +252,7 @@ export default { :title="__('Time tracking report')" :hide-footer="true" > - <time-tracking-report :limit-to-hours="limitToHours" :issuable-iid="issuableIid" /> + <time-tracking-report :limit-to-hours="limitToHours" :issuable-id="issuableId" /> </gl-modal> </template> <transition name="help-state-toggle"> diff --git a/app/assets/javascripts/sidebar/mount_sidebar.js b/app/assets/javascripts/sidebar/mount_sidebar.js index f53760eab93..67c72b17f1f 100644 --- a/app/assets/javascripts/sidebar/mount_sidebar.js +++ b/app/assets/javascripts/sidebar/mount_sidebar.js @@ -391,7 +391,7 @@ function mountSubscriptionsComponent() { function mountTimeTrackingComponent() { const el = document.getElementById('issuable-time-tracker'); - const { iid, fullPath, issuableType, timeTrackingLimitToHours } = getSidebarOptions(); + const { id, iid, fullPath, issuableType, timeTrackingLimitToHours } = getSidebarOptions(); if (!el) return; @@ -404,6 +404,7 @@ function mountTimeTrackingComponent() { createElement(SidebarTimeTracking, { props: { fullPath, + issuableId: id.toString(), issuableIid: iid.toString(), limitToHours: timeTrackingLimitToHours, }, diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 25e3b9fe4f0..8f5a713af3f 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -3,6 +3,7 @@ class DeployKey < Key include FromUnion include IgnorableColumns + include PolicyActor has_many :deploy_keys_projects, inverse_of: :deploy_key, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :deploy_keys_projects diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 90e06e44165..5f41441058b 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -271,9 +271,12 @@ class Namespace < ApplicationRecord # Includes projects from this namespace and projects from all subgroups # that belongs to this namespace def all_projects - namespace = user? ? self : self_and_descendant_ids - - Project.where(namespace: namespace) + if Feature.enabled?(:recursive_approach_for_all_projects, default_enabled: :yaml) + namespace = user? ? self : self_and_descendants + Project.where(namespace: namespace) + else + Project.inside_path(full_path) + end end def has_parent? diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index e93c60c3710..3cb4644a60d 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -69,6 +69,16 @@ class ProjectPolicy < BasePolicy project.merge_requests_allowing_push_to_user(user).any? end + desc "Deploy key with read access" + condition(:download_code_deploy_key) do + user.is_a?(DeployKey) && user.has_access_to?(project) + end + + desc "Deploy key with write access" + condition(:push_code_deploy_key) do + user.is_a?(DeployKey) && user.can_push_to?(project) + end + desc "Deploy token with read_package_registry scope" condition(:read_package_registry_deploy_token) do user.is_a?(DeployToken) && user.has_access_to?(project) && user.read_package_registry @@ -616,6 +626,14 @@ class ProjectPolicy < BasePolicy prevent :move_design end + rule { download_code_deploy_key }.policy do + enable :download_code + end + + rule { push_code_deploy_key }.policy do + enable :push_code + end + rule { read_package_registry_deploy_token }.policy do enable :read_package enable :read_project diff --git a/app/views/shared/boards/components/sidebar/_time_tracker.html.haml b/app/views/shared/boards/components/sidebar/_time_tracker.html.haml index 9f230a4a09b..eea3ec35000 100644 --- a/app/views/shared/boards/components/sidebar/_time_tracker.html.haml +++ b/app/views/shared/boards/components/sidebar/_time_tracker.html.haml @@ -1,5 +1,6 @@ .block.time-tracking %time-tracker{ ":limit-to-hours" => "timeTrackingLimitToHours", + ":issuable-id" => "issue.id ? issue.id.toString() : ''", ":issuable-iid" => "issue.iid ? issue.iid.toString() : ''", ":full-path" => "issue.project ? issue.project.fullPath : ''", "root-path" => "#{root_url}" } |