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>2023-10-27 21:12:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-27 21:12:28 +0300
commit7badd9fd55f9b877f2de8c8d0126c720a57e538d (patch)
treeec01cd7470f50ed39a72787811c0a9dc3b1f5a18 /app
parentf459f810d53dd453d3fc39df2dd62f01629d99e4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/ci/catalog/components/details/ci_resource_components.vue15
-rw-r--r--app/assets/javascripts/editor/schema/ci.json12
-rw-r--r--app/assets/javascripts/emoji/index.js11
-rw-r--r--app/assets/javascripts/environments/components/environment_form.vue1
-rw-r--r--app/assets/javascripts/environments/components/kubernetes_overview.vue1
-rw-r--r--app/assets/javascripts/environments/graphql/resolvers/kubernetes.js76
-rw-r--r--app/controllers/jwt_controller.rb2
-rw-r--r--app/controllers/projects/environments_controller.rb4
-rw-r--r--app/controllers/repositories/git_http_client_controller.rb2
-rw-r--r--app/models/ci/build.rb4
10 files changed, 104 insertions, 24 deletions
diff --git a/app/assets/javascripts/ci/catalog/components/details/ci_resource_components.vue b/app/assets/javascripts/ci/catalog/components/details/ci_resource_components.vue
index f494a3bd224..fbc7ddf5c91 100644
--- a/app/assets/javascripts/ci/catalog/components/details/ci_resource_components.vue
+++ b/app/assets/javascripts/ci/catalog/components/details/ci_resource_components.vue
@@ -1,5 +1,5 @@
<script>
-import { GlButton, GlLoadingIcon, GlTableLite } from '@gitlab/ui';
+import { GlButton, GlEmptyState, GlLoadingIcon, GlTableLite } from '@gitlab/ui';
import { createAlert } from '~/alert';
import { __, s__ } from '~/locale';
import getCiCatalogResourceComponents from '../../graphql/queries/get_ci_catalog_resource_components.query.graphql';
@@ -7,6 +7,7 @@ import getCiCatalogResourceComponents from '../../graphql/queries/get_ci_catalog
export default {
components: {
GlButton,
+ GlEmptyState,
GlLoadingIcon,
GlTableLite,
},
@@ -38,6 +39,9 @@ export default {
},
},
computed: {
+ isMetadataMissing() {
+ return !this.components || this.components?.length === 0;
+ },
isLoading() {
return this.$apollo.queries.components.loading;
},
@@ -73,6 +77,10 @@ export default {
i18n: {
copyText: __('Copy value'),
copyAriaText: __('Copy to clipboard'),
+ emptyStateTitle: s__('CiCatalogComponent|Component details not available'),
+ emptyStateDesc: s__(
+ 'CiCatalogComponent|This tab displays auto-collected information about the components in the repository, but no information was found.',
+ ),
inputTitle: s__('CiCatalogComponent|Inputs'),
fetchError: s__("CiCatalogComponent|There was an error fetching this resource's components"),
},
@@ -82,6 +90,11 @@ export default {
<template>
<div>
<gl-loading-icon v-if="isLoading" size="lg" />
+ <gl-empty-state
+ v-else-if="isMetadataMissing"
+ :title="$options.i18n.emptyStateTitle"
+ :description="$options.i18n.emptyStateDesc"
+ />
<template v-else>
<div
v-for="component in components"
diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json
index 0420ffb82f5..308a68544bc 100644
--- a/app/assets/javascripts/editor/schema/ci.json
+++ b/app/assets/javascripts/editor/schema/ci.json
@@ -2093,9 +2093,15 @@
"description": "A path to a directory that contains the files to be published with Pages",
"type": "string"
},
- "pages_path_prefix": {
- "description": "The path prefix identifier for this version of pages. Allows creation of multiple versions of the same site with different path prefixes",
- "type": "string"
+ "pages": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "path_prefix": {
+ "type": "string",
+ "markdownDescription": "The GitLab Pages URL path prefix used in this version of pages."
+ }
+ }
}
},
"oneOf": [
diff --git a/app/assets/javascripts/emoji/index.js b/app/assets/javascripts/emoji/index.js
index c9b74e74483..a78b901af48 100644
--- a/app/assets/javascripts/emoji/index.js
+++ b/app/assets/javascripts/emoji/index.js
@@ -39,8 +39,15 @@ async function loadEmoji() {
const { data } = await axios.get(
`${gon.relative_url_root || ''}/-/emojis/${EMOJI_VERSION}/emojis.json`,
);
- window.localStorage.setItem(CACHE_VERSION_KEY, EMOJI_VERSION);
- window.localStorage.setItem(CACHE_KEY, JSON.stringify(data));
+
+ try {
+ window.localStorage.setItem(CACHE_VERSION_KEY, EMOJI_VERSION);
+ window.localStorage.setItem(CACHE_KEY, JSON.stringify(data));
+ } catch {
+ // Setting data in localstorage may fail when storage quota is exceeded.
+ // We should continue even when this fails.
+ }
+
return data;
}
diff --git a/app/assets/javascripts/environments/components/environment_form.vue b/app/assets/javascripts/environments/components/environment_form.vue
index 8ebba0e27bb..c6cf6b7e24b 100644
--- a/app/assets/javascripts/environments/components/environment_form.vue
+++ b/app/assets/javascripts/environments/components/environment_form.vue
@@ -193,6 +193,7 @@ export default {
headers: {
'GitLab-Agent-Id': getIdFromGraphQLId(this.selectedAgentId),
'Content-Type': 'application/json',
+ Accept: 'application/json',
...csrf.headers,
},
credentials: 'include',
diff --git a/app/assets/javascripts/environments/components/kubernetes_overview.vue b/app/assets/javascripts/environments/components/kubernetes_overview.vue
index 252ced6391d..550568ffaaa 100644
--- a/app/assets/javascripts/environments/components/kubernetes_overview.vue
+++ b/app/assets/javascripts/environments/components/kubernetes_overview.vue
@@ -64,6 +64,7 @@ export default {
headers: {
'GitLab-Agent-Id': this.gitlabAgentId,
'Content-Type': 'application/json',
+ Accept: 'application/json',
...csrf.headers,
},
credentials: 'include',
diff --git a/app/assets/javascripts/environments/graphql/resolvers/kubernetes.js b/app/assets/javascripts/environments/graphql/resolvers/kubernetes.js
index 67a472dac93..d57f2498fcd 100644
--- a/app/assets/javascripts/environments/graphql/resolvers/kubernetes.js
+++ b/app/assets/javascripts/environments/graphql/resolvers/kubernetes.js
@@ -1,5 +1,15 @@
-import { CoreV1Api, Configuration, AppsV1Api, BatchV1Api } from '@gitlab/cluster-client';
+import {
+ CoreV1Api,
+ Configuration,
+ AppsV1Api,
+ BatchV1Api,
+ WatchApi,
+ EVENT_DATA,
+ EVENT_TIMEOUT,
+ EVENT_ERROR,
+} from '@gitlab/cluster-client';
import { humanizeClusterErrors } from '../../helpers/k8s_integration_helper';
+import k8sPodsQuery from '../queries/k8s_pods.query.graphql';
const mapWorkloadItems = (items, kind) => {
return items.map((item) => {
@@ -54,21 +64,59 @@ const handleClusterError = async (err) => {
};
export default {
- k8sPods(_, { configuration, namespace }) {
- const coreV1Api = new CoreV1Api(new Configuration(configuration));
- const podsApi = namespace
- ? coreV1Api.listCoreV1NamespacedPod({ namespace })
- : coreV1Api.listCoreV1PodForAllNamespaces();
+ k8sPods(_, { configuration, namespace }, { client }) {
+ const config = new Configuration(configuration);
- return podsApi
- .then((res) => res?.items || [])
- .catch(async (err) => {
- try {
- await handleClusterError(err);
- } catch (error) {
- throw new Error(error.message);
- }
+ if (!gon.features?.k8sWatchApi) {
+ const coreV1Api = new CoreV1Api(config);
+ const podsApi = namespace
+ ? coreV1Api.listCoreV1NamespacedPod({ namespace })
+ : coreV1Api.listCoreV1PodForAllNamespaces();
+
+ return podsApi
+ .then((res) => res?.items || [])
+ .catch(async (err) => {
+ try {
+ await handleClusterError(err);
+ } catch (error) {
+ throw new Error(error.message);
+ }
+ });
+ }
+
+ const path = namespace ? `/api/v1/namespaces/${namespace}/pods` : '/api/v1/pods';
+ const watcherApi = new WatchApi(config);
+
+ return watcherApi.subscribeToStream(path, { watch: true }).then((watcher) => {
+ let result = [];
+
+ return new Promise((resolve, reject) => {
+ watcher.on(EVENT_DATA, (data) => {
+ result = data.map((item) => {
+ return { status: { phase: item.status.phase } };
+ });
+
+ resolve(result);
+
+ setTimeout(() => {
+ client.writeQuery({
+ query: k8sPodsQuery,
+ variables: { configuration, namespace },
+ data: { k8sPods: result },
+ });
+ }, 0);
+ });
+
+ watcher.on(EVENT_TIMEOUT, () => {
+ resolve(result);
+ });
+
+ watcher.on(EVENT_ERROR, (errorData) => {
+ const error = errorData?.message ? new Error(errorData.message) : errorData;
+ reject(error);
+ });
});
+ });
},
k8sServices(_, { configuration, namespace }) {
const coreV1Api = new CoreV1Api(new Configuration(configuration));
diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb
index faa5967d64e..83409c7e096 100644
--- a/app/controllers/jwt_controller.rb
+++ b/app/controllers/jwt_controller.rb
@@ -33,7 +33,7 @@ class JwtController < ApplicationController
@authentication_result = Gitlab::Auth::Result.new(nil, nil, :none, Gitlab::Auth.read_only_authentication_abilities)
authenticate_with_http_basic do |login, password|
- @authentication_result = Gitlab::Auth.find_for_git_client(login, password, project: nil, ip: request.ip)
+ @authentication_result = Gitlab::Auth.find_for_git_client(login, password, project: nil, request: request)
if @authentication_result.failed?
log_authentication_failed(login, @authentication_result)
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index aabea122fb6..efb8c63252b 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -8,6 +8,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController
layout 'project'
+ before_action only: [:index] do
+ push_frontend_feature_flag(:k8s_watch_api, project)
+ end
+
before_action :authorize_read_environment!
before_action :authorize_create_environment!, only: [:new, :create]
before_action :authorize_stop_environment!, only: [:stop]
diff --git a/app/controllers/repositories/git_http_client_controller.rb b/app/controllers/repositories/git_http_client_controller.rb
index 71d8ad829f6..e8da6ee986a 100644
--- a/app/controllers/repositories/git_http_client_controller.rb
+++ b/app/controllers/repositories/git_http_client_controller.rb
@@ -129,7 +129,7 @@ module Repositories
def handle_basic_authentication(login, password)
@authentication_result = Gitlab::Auth.find_for_git_client(
- login, password, project: project, ip: request.ip)
+ login, password, project: project, request: request)
@authentication_result.success?
end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index a4724fd7c02..05122c96948 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -392,8 +392,8 @@ module Ci
name == 'pages'
end
- # overridden on EE
- def pages_path_prefix; end
+ # Overriden on EE
+ def pages; end
def runnable?
true