diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-23 21:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-23 21:08:27 +0300 |
commit | 3ca896b640def57a58485def308748b2fccbd0bb (patch) | |
tree | 7aead6484759d2a473bf9776aa7d87632f1e105f /app/assets/javascripts/grafana_integration | |
parent | abdb550f6937ce69ec38954f24ef221d07637438 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/grafana_integration')
7 files changed, 0 insertions, 232 deletions
diff --git a/app/assets/javascripts/grafana_integration/components/grafana_integration.vue b/app/assets/javascripts/grafana_integration/components/grafana_integration.vue deleted file mode 100644 index 3911201457f..00000000000 --- a/app/assets/javascripts/grafana_integration/components/grafana_integration.vue +++ /dev/null @@ -1,131 +0,0 @@ -<script> -import { - GlButton, - GlFormGroup, - GlFormInput, - GlFormCheckbox, - GlIcon, - GlLink, - GlSprintf, -} from '@gitlab/ui'; -import { mapState, mapActions } from 'vuex'; -import { helpPagePath } from '~/helpers/help_page_helper'; - -export default { - components: { - GlButton, - GlFormCheckbox, - GlFormGroup, - GlFormInput, - GlIcon, - GlLink, - GlSprintf, - }, - data() { - return { - helpUrl: helpPagePath('operations/metrics/embed_grafana', { - anchor: 'use-integration-with-grafana-api', - }), - placeholderUrl: 'https://my-grafana.example.com/', - }; - }, - computed: { - ...mapState(['operationsSettingsEndpoint', 'grafanaToken', 'grafanaUrl', 'grafanaEnabled']), - integrationEnabled: { - get() { - return this.grafanaEnabled; - }, - set(grafanaEnabled) { - this.setGrafanaEnabled(grafanaEnabled); - }, - }, - localGrafanaToken: { - get() { - return this.grafanaToken; - }, - set(token) { - this.setGrafanaToken(token); - }, - }, - localGrafanaUrl: { - get() { - return this.grafanaUrl; - }, - set(url) { - this.setGrafanaUrl(url); - }, - }, - }, - methods: { - ...mapActions([ - 'setGrafanaUrl', - 'setGrafanaToken', - 'setGrafanaEnabled', - 'updateGrafanaIntegration', - ]), - }, -}; -</script> - -<template> - <section id="grafana" class="settings no-animate js-grafana-integration"> - <div class="settings-header"> - <h4 - class="js-section-header settings-title js-settings-toggle js-settings-toggle-trigger-only" - > - {{ s__('GrafanaIntegration|Grafana authentication') }} - </h4> - <gl-button class="js-settings-toggle">{{ __('Expand') }}</gl-button> - <p class="js-section-sub-header"> - {{ - s__( - 'GrafanaIntegration|Set up Grafana authentication to embed Grafana panels in GitLab Flavored Markdown.', - ) - }} - <gl-link :href="helpUrl">{{ __('Learn more.') }}</gl-link> - </p> - </div> - <div class="settings-content"> - <form> - <gl-form-group :label="__('Enable authentication')" label-for="grafana-integration-enabled"> - <gl-form-checkbox id="grafana-integration-enabled" v-model="integrationEnabled"> - {{ s__('GrafanaIntegration|Active') }} - </gl-form-checkbox> - </gl-form-group> - <gl-form-group - :label="s__('GrafanaIntegration|Grafana URL')" - label-for="grafana-url" - :description="s__('GrafanaIntegration|Enter the base URL of the Grafana instance.')" - > - <gl-form-input id="grafana-url" v-model="localGrafanaUrl" :placeholder="placeholderUrl" /> - </gl-form-group> - <gl-form-group :label="s__('GrafanaIntegration|API token')" label-for="grafana-token"> - <gl-form-input id="grafana-token" v-model="localGrafanaToken" /> - <p class="form-text text-muted"> - <gl-sprintf - :message=" - s__('GrafanaIntegration|Enter the %{docLinkStart}Grafana API token%{docLinkEnd}.') - " - > - <template #docLink="{ content }"> - <gl-link - href="https://grafana.com/docs/http_api/auth/#create-api-token" - target="_blank" - >{{ content }} <gl-icon name="external-link" class="gl-vertical-align-middle" - /></gl-link> - </template> - </gl-sprintf> - </p> - </gl-form-group> - <gl-button - variant="confirm" - category="primary" - data-testid="save-grafana-settings-button" - @click="updateGrafanaIntegration" - > - {{ __('Save changes') }} - </gl-button> - </form> - </div> - </section> -</template> diff --git a/app/assets/javascripts/grafana_integration/index.js b/app/assets/javascripts/grafana_integration/index.js deleted file mode 100644 index 9ade29dae69..00000000000 --- a/app/assets/javascripts/grafana_integration/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import Vue from 'vue'; -import GrafanaIntegration from './components/grafana_integration.vue'; -import store from './store'; - -export default () => { - const el = document.querySelector('.js-grafana-integration'); - - if (!el) return false; - - return new Vue({ - el, - store: store(el.dataset), - render(createElement) { - return createElement(GrafanaIntegration); - }, - }); -}; diff --git a/app/assets/javascripts/grafana_integration/store/actions.js b/app/assets/javascripts/grafana_integration/store/actions.js deleted file mode 100644 index 76e21f09719..00000000000 --- a/app/assets/javascripts/grafana_integration/store/actions.js +++ /dev/null @@ -1,44 +0,0 @@ -import { createAlert } from '~/alert'; -import axios from '~/lib/utils/axios_utils'; -import { refreshCurrentPage } from '~/lib/utils/url_utility'; -import { __ } from '~/locale'; -import * as mutationTypes from './mutation_types'; - -export const setGrafanaUrl = ({ commit }, url) => commit(mutationTypes.SET_GRAFANA_URL, url); - -export const setGrafanaToken = ({ commit }, token) => - commit(mutationTypes.SET_GRAFANA_TOKEN, token); - -export const setGrafanaEnabled = ({ commit }, enabled) => - commit(mutationTypes.SET_GRAFANA_ENABLED, enabled); - -export const updateGrafanaIntegration = ({ state, dispatch }) => - axios - .patch(state.operationsSettingsEndpoint, { - project: { - grafana_integration_attributes: { - grafana_url: state.grafanaUrl, - token: state.grafanaToken, - enabled: state.grafanaEnabled, - }, - }, - }) - .then(() => dispatch('receiveGrafanaIntegrationUpdateSuccess')) - .catch((error) => dispatch('receiveGrafanaIntegrationUpdateError', error)); - -export const receiveGrafanaIntegrationUpdateSuccess = () => { - /** - * The operations_controller currently handles successful requests - * by creating an alert banner message to notify the user. - */ - refreshCurrentPage(); -}; - -export const receiveGrafanaIntegrationUpdateError = (_, error) => { - const { response } = error; - const message = response.data && response.data.message ? response.data.message : ''; - - createAlert({ - message: `${__('There was an error saving your changes.')} ${message}`, - }); -}; diff --git a/app/assets/javascripts/grafana_integration/store/index.js b/app/assets/javascripts/grafana_integration/store/index.js deleted file mode 100644 index a11bd8089fd..00000000000 --- a/app/assets/javascripts/grafana_integration/store/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; -import * as actions from './actions'; -import mutations from './mutations'; -import createState from './state'; - -Vue.use(Vuex); - -export const createStore = (initialState) => - new Vuex.Store({ - state: createState(initialState), - actions, - mutations, - }); - -export default createStore; diff --git a/app/assets/javascripts/grafana_integration/store/mutation_types.js b/app/assets/javascripts/grafana_integration/store/mutation_types.js deleted file mode 100644 index 314c3a4039a..00000000000 --- a/app/assets/javascripts/grafana_integration/store/mutation_types.js +++ /dev/null @@ -1,3 +0,0 @@ -export const SET_GRAFANA_URL = 'SET_GRAFANA_URL'; -export const SET_GRAFANA_TOKEN = 'SET_GRAFANA_TOKEN'; -export const SET_GRAFANA_ENABLED = 'SET_GRAFANA_ENABLED'; diff --git a/app/assets/javascripts/grafana_integration/store/mutations.js b/app/assets/javascripts/grafana_integration/store/mutations.js deleted file mode 100644 index 0992030d404..00000000000 --- a/app/assets/javascripts/grafana_integration/store/mutations.js +++ /dev/null @@ -1,13 +0,0 @@ -import * as types from './mutation_types'; - -export default { - [types.SET_GRAFANA_URL](state, url) { - state.grafanaUrl = url; - }, - [types.SET_GRAFANA_TOKEN](state, token) { - state.grafanaToken = token; - }, - [types.SET_GRAFANA_ENABLED](state, enabled) { - state.grafanaEnabled = enabled; - }, -}; diff --git a/app/assets/javascripts/grafana_integration/store/state.js b/app/assets/javascripts/grafana_integration/store/state.js deleted file mode 100644 index a912eb58327..00000000000 --- a/app/assets/javascripts/grafana_integration/store/state.js +++ /dev/null @@ -1,8 +0,0 @@ -import { parseBoolean } from '~/lib/utils/common_utils'; - -export default (initialState = {}) => ({ - operationsSettingsEndpoint: initialState.operationsSettingsEndpoint, - grafanaToken: initialState.grafanaIntegrationToken || '', - grafanaUrl: initialState.grafanaIntegrationUrl || '', - grafanaEnabled: parseBoolean(initialState.grafanaIntegrationEnabled) || false, -}); |