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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-15 18:09:53 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-15 18:09:53 +0300
commit977720d7565377672df302ecb82b1e7a221cfba6 (patch)
treef258b65ed376a3075e0a76971a9360083ee6a059 /app/assets/javascripts/vue_shared/components/web_ide
parent717436a767395d0ed850a16d07f19cd51c3d4551 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/web_ide')
-rw-r--r--app/assets/javascripts/vue_shared/components/web_ide/confirm_fork_modal.vue114
-rw-r--r--app/assets/javascripts/vue_shared/components/web_ide/get_writable_forks.query.graphql12
2 files changed, 126 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/web_ide/confirm_fork_modal.vue b/app/assets/javascripts/vue_shared/components/web_ide/confirm_fork_modal.vue
new file mode 100644
index 00000000000..b4afb27c497
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/web_ide/confirm_fork_modal.vue
@@ -0,0 +1,114 @@
+<script>
+import { GlModal, GlLoadingIcon, GlLink } from '@gitlab/ui';
+import { __ } from '~/locale';
+import getWritableForksQuery from './get_writable_forks.query.graphql';
+
+export const i18n = {
+ btnText: __('Create a new fork'),
+ title: __('Fork project?'),
+ message: __('You can’t edit files directly in this project.'),
+ existingForksMessage: __(
+ 'To submit your changes in a merge request, switch to one of these forks or create a new fork.',
+ ),
+ newForkMessage: __('To submit your changes in a merge request, create a new fork.'),
+};
+
+export default {
+ name: 'ConfirmForkModal',
+ components: {
+ GlModal,
+ GlLoadingIcon,
+ GlLink,
+ },
+ inject: {
+ projectPath: {
+ default: '',
+ },
+ },
+ model: {
+ prop: 'visible',
+ event: 'change',
+ },
+ props: {
+ visible: {
+ type: Boolean,
+ required: false,
+ default: false,
+ },
+ modalId: {
+ type: String,
+ required: true,
+ },
+ forkPath: {
+ type: String,
+ required: true,
+ },
+ },
+ data() {
+ return {
+ forks: [],
+ };
+ },
+ apollo: {
+ forks: {
+ query: getWritableForksQuery,
+ variables() {
+ return {
+ projectPath: this.projectPath,
+ };
+ },
+ update({ project } = {}) {
+ return project?.visibleForks?.nodes.map((node) => {
+ return {
+ text: node.fullPath,
+ href: node.webUrl,
+ };
+ });
+ },
+ },
+ },
+ computed: {
+ isLoading() {
+ return this.$apollo.queries.forks.loading;
+ },
+ hasWritableForks() {
+ return this.forks.length;
+ },
+ btnActions() {
+ return {
+ cancel: { text: __('Cancel') },
+ primary: {
+ text: this.$options.i18n.btnText,
+ attributes: {
+ href: this.forkPath,
+ variant: 'confirm',
+ 'data-qa-selector': 'fork_project_button',
+ },
+ },
+ };
+ },
+ },
+ i18n,
+};
+</script>
+<template>
+ <gl-modal
+ :visible="visible"
+ data-qa-selector="confirm_fork_modal"
+ :modal-id="modalId"
+ :title="$options.i18n.title"
+ :action-primary="btnActions.primary"
+ :action-cancel="btnActions.cancel"
+ @change="$emit('change', $event)"
+ >
+ <p>{{ $options.i18n.message }}</p>
+ <gl-loading-icon v-if="isLoading" />
+ <template v-else-if="hasWritableForks">
+ <p>{{ $options.i18n.existingForksMessage }}</p>
+ <div v-for="fork in forks" :key="fork.text">
+ <gl-link :href="fork.href">{{ fork.text }}</gl-link>
+ </div>
+ </template>
+ <p v-else>{{ $options.i18n.newForkMessage }}</p>
+ </gl-modal>
+</template>
diff --git a/app/assets/javascripts/vue_shared/components/web_ide/get_writable_forks.query.graphql b/app/assets/javascripts/vue_shared/components/web_ide/get_writable_forks.query.graphql
new file mode 100644
index 00000000000..044b79e64f3
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/web_ide/get_writable_forks.query.graphql
@@ -0,0 +1,12 @@
+query getWritableForks($projectPath: ID!) {
+ project(fullPath: $projectPath) {
+ id
+ visibleForks(minimumAccessLevel: DEVELOPER) {
+ nodes {
+ id
+ fullPath
+ webUrl
+ }
+ }
+ }
+}