Skip to content

Commit

Permalink
Add latest changes from gitlab-org/gitlab@master
Browse files Browse the repository at this point in the history
  • Loading branch information
GitLab Bot committed May 19, 2020
1 parent 553a224 commit f2151c6
Show file tree
Hide file tree
Showing 55 changed files with 700 additions and 915 deletions.
10 changes: 0 additions & 10 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,30 372,20 @@ RSpec/LeakyConstantDeclaration:
- 'spec/lib/gitlab/sidekiq_middleware/server_metrics_spec.rb'
- 'spec/lib/gitlab/view/presenter/factory_spec.rb'
- 'spec/lib/marginalia_spec.rb'
- 'spec/lib/omni_auth/strategies/jwt_spec.rb'
- 'spec/lib/system_check/simple_executor_spec.rb'
- 'spec/lib/system_check_spec.rb'
- 'spec/mailers/notify_spec.rb'
- 'spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb'
- 'spec/migrations/encrypt_plaintext_attributes_on_application_settings_spec.rb'
- 'spec/models/clusters/cluster_spec.rb'
- 'spec/models/concerns/batch_destroy_dependent_associations_spec.rb'
- 'spec/models/concerns/blocks_json_serialization_spec.rb'
- 'spec/models/concerns/bulk_insert_safe_spec.rb'
- 'spec/models/concerns/bulk_insertable_associations_spec.rb'
- 'spec/models/concerns/mentionable_spec.rb'
- 'spec/models/concerns/reactive_caching_spec.rb'
- 'spec/models/concerns/triggerable_hooks_spec.rb'
- 'spec/models/repository_spec.rb'
- 'spec/models/tree_spec.rb'
- 'spec/policies/merge_request_policy_spec.rb'
- 'spec/requests/api/graphql/tasks/task_completion_status_spec.rb'
- 'spec/requests/api/statistics_spec.rb'
- 'spec/rubocop/cop/rspec/env_assignment_spec.rb'
- 'spec/serializers/commit_entity_spec.rb'
- 'spec/services/clusters/applications/check_installation_progress_service_spec.rb'
- 'spec/services/clusters/applications/check_uninstall_progress_service_spec.rb'
- 'spec/services/issues/resolve_discussions_spec.rb'
- 'spec/support/shared_contexts/spam_constants.rb'
- 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb'
- 'spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 1,13 @@
<script>
import { GlAlert } from '@gitlab/ui';
import getJiraImportDetailsQuery from '~/jira_import/queries/get_jira_import_details.query.graphql';
import { isInProgress } from '~/jira_import/utils';
import { GlAlert, GlLabel } from '@gitlab/ui';
import getIssuesListDetailsQuery from '../queries/get_issues_list_details.query.graphql';
import { calculateJiraImportLabel, isFinished, isInProgress } from '~/jira_import/utils';
export default {
name: 'IssuableListRoot',
components: {
GlAlert,
GlLabel,
},
props: {
canEdit: {
Expand All @@ -17,47 18,79 @@ export default {
type: Boolean,
required: true,
},
issuesPath: {
type: String,
required: true,
},
projectPath: {
type: String,
required: true,
},
},
data() {
return {
isAlertShowing: true,
isFinishedAlertShowing: true,
isInProgressAlertShowing: true,
jiraImport: {},
};
},
apollo: {
jiraImport: {
query: getJiraImportDetailsQuery,
query: getIssuesListDetailsQuery,
variables() {
return {
fullPath: this.projectPath,
};
},
update: ({ project }) => ({
isInProgress: isInProgress(project.jiraImportStatus),
isFinished: isFinished(project.jiraImportStatus),
label: calculateJiraImportLabel(
project.jiraImports.nodes,
project.issues.nodes.flatMap(({ labels }) => labels.nodes),
),
}),
skip() {
return !this.isJiraConfigured || !this.canEdit;
},
},
},
computed: {
shouldShowAlert() {
return this.isAlertShowing && this.jiraImport?.isInProgress;
labelTarget() {
return `${this.issuesPath}?label_name[]=${encodeURIComponent(this.jiraImport.label.title)}`;
},
shouldShowFinishedAlert() {
return this.isFinishedAlertShowing && this.jiraImport.isFinished;
},
shouldShowInProgressAlert() {
return this.isInProgressAlertShowing && this.jiraImport.isInProgress;
},
},
methods: {
hideAlert() {
this.isAlertShowing = false;
hideFinishedAlert() {
this.isFinishedAlertShowing = false;
},
hideInProgressAlert() {
this.isInProgressAlertShowing = false;
},
},
};
</script>

<template>
<gl-alert v-if="shouldShowAlert" @dismiss="hideAlert">
{{ __('Import in progress. Refresh page to see newly added issues.') }}
</gl-alert>
<div class="issuable-list-root">
<gl-alert v-if="shouldShowInProgressAlert" @dismiss="hideInProgressAlert">
{{ __('Import in progress. Refresh page to see newly added issues.') }}
</gl-alert>
<gl-alert v-if="shouldShowFinishedAlert" variant="success" @dismiss="hideFinishedAlert">
{{ __('Issues successfully imported with the label') }}
<gl-label
:background-color="jiraImport.label.color"
scoped
size="sm"
:target="labelTarget"
:title="jiraImport.label.title"
/>
</gl-alert>
</div>
</template>
1 change: 1 addition & 0 deletions app/assets/javascripts/issuables_list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 27,7 @@ function mountIssuableListRootApp() {
props: {
canEdit: parseBoolean(el.dataset.canEdit),
isJiraConfigured: parseBoolean(el.dataset.isJiraConfigured),
issuesPath: el.dataset.issuesPath,
projectPath: el.dataset.projectPath,
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,22 @@
#import "~/jira_import/queries/jira_import.fragment.graphql"

query($fullPath: ID!) {
project(fullPath: $fullPath) {
issues {
nodes {
labels {
nodes {
title
color
}
}
}
}
jiraImportStatus
jiraImports {
nodes {
...JiraImport
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
<script>
import { GlAlert, GlLoadingIcon, GlSprintf } from '@gitlab/ui';
import last from 'lodash/last';
import { last } from 'lodash';
import { __ } from '~/locale';
import getJiraImportDetailsQuery from '../queries/get_jira_import_details.query.graphql';
import initiateJiraImportMutation from '../queries/initiate_jira_import.mutation.graphql';
Expand Down
49 changes: 49 additions & 0 deletions app/assets/javascripts/jira_import/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 1,5 @@
import { last } from 'lodash';

export const IMPORT_STATE = {
FAILED: 'failed',
FINISHED: 'finished',
Expand All @@ -8,3 10,50 @@ export const IMPORT_STATE = {

export const isInProgress = state =>
state === IMPORT_STATE.SCHEDULED || state === IMPORT_STATE.STARTED;

export const isFinished = state => state === IMPORT_STATE.FINISHED;

/**
* Calculates the label title for the most recent Jira import.
*
* @param {Object[]} jiraImports - List of Jira imports
* @param {string} jiraImports[].jiraProjectKey - Jira project key
* @returns {string} - A label title
*/
const calculateJiraImportLabelTitle = jiraImports => {
const mostRecentJiraProjectKey = last(jiraImports)?.jiraProjectKey;
const jiraProjectImportCount = jiraImports.filter(
jiraImport => jiraImport.jiraProjectKey === mostRecentJiraProjectKey,
).length;
return `jira-import::${mostRecentJiraProjectKey}-${jiraProjectImportCount}`;
};

/**
* Finds the label color from a list of labels.
*
* @param {string} labelTitle - Label title
* @param {Object[]} labels - List of labels
* @param {string} labels[].title - Label title
* @param {string} labels[].color - Label color
* @returns {string} - The label color associated with the given labelTitle
*/
const calculateJiraImportLabelColor = (labelTitle, labels) =>
labels.find(label => label.title === labelTitle)?.color;

/**
* Calculates the label for the most recent Jira import.
*
* @param {Object[]} jiraImports - List of Jira imports
* @param {string} jiraImports[].jiraProjectKey - Jira project key
* @param {Object[]} labels - List of labels
* @param {string} labels[].title - Label title
* @param {string} labels[].color - Label color
* @returns {{color: string, title: string}} - A label object containing a label color and title
*/
export const calculateJiraImportLabel = (jiraImports, labels) => {
const title = calculateJiraImportLabelTitle(jiraImports);
return {
color: calculateJiraImportLabelColor(title, labels),
title,
};
};
20 changes: 1 addition & 19 deletions app/assets/javascripts/static_site_editor/index.js
Original file line number Diff line number Diff line change
@@ -1,31 1,14 @@
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import App from './components/app.vue';
import createStore from './store';
import createRouter from './router';
import createApolloProvider from './graphql';

const initStaticSiteEditor = el => {
const {
isSupportedContent,
projectId,
path: sourcePath,
baseUrl,
namespace,
project,
} = el.dataset;
const { isSupportedContent, path: sourcePath, baseUrl, namespace, project } = el.dataset;
const { current_username: username } = window.gon;
const returnUrl = el.dataset.returnUrl || null;

const store = createStore({
initialState: {
isSupportedContent: parseBoolean(isSupportedContent),
projectId,
returnUrl,
sourcePath,
username,
},
});
const router = createRouter(baseUrl);
const apolloProvider = createApolloProvider({
isSupportedContent: parseBoolean(isSupportedContent),
Expand All @@ -37,7 20,6 @@ const initStaticSiteEditor = el => {

return new Vue({
el,
store,
router,
apolloProvider,
components: {
Expand Down
38 changes: 0 additions & 38 deletions app/assets/javascripts/static_site_editor/store/actions.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/assets/javascripts/static_site_editor/store/getters.js

This file was deleted.

19 changes: 0 additions & 19 deletions app/assets/javascripts/static_site_editor/store/index.js

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions app/assets/javascripts/static_site_editor/store/mutations.js

This file was deleted.

Loading

0 comments on commit f2151c6

Please sign in to comment.