Unverified Commit 603144d4 authored by Tamika Tannis's avatar Tamika Tannis Committed by GitHub

Update JIRA Issue query + TableIssue UI (#415)

* Update search query stub

* Update search query stub

* Further specify query

* Move 'isLoading' to TableIssues

* Fix python test
parent 2b67c4c4
......@@ -11,7 +11,7 @@ from amundsen_application.models.issue_results import IssueResults
import urllib.parse
import logging
SEARCH_STUB_ALL_ISSUES = 'text ~ "{table_key}" order by createdDate DESC'
SEARCH_STUB_ALL_ISSUES = 'text ~ "\\"Table Key: {table_key} [PLEASE DO NOT REMOVE]\\"" order by createdDate DESC'
# this is provided by jira as the type of a bug
ISSUE_TYPE_ID = 1
ISSUE_TYPE_NAME = 'Bug'
......
......@@ -3,7 +3,6 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { GlobalState } from 'ducks/rootReducer';
import LoadingSpinner from 'components/common/LoadingSpinner';
import { createIssue } from 'ducks/issue/reducer';
import { CreateIssueRequest } from 'ducks/issue/types';
import './styles.scss';
......@@ -24,7 +23,6 @@ export interface DispatchFromProps {
}
export interface StateFromProps {
isLoading: boolean;
tableOwners: string[];
userEmail: string;
tableMetadata: TableMetadata;
......@@ -91,9 +89,6 @@ export class ReportTableIssue extends React.Component<ReportTableIssueProps, Rep
};
render() {
if (this.props.isLoading) {
return <LoadingSpinner />;
}
return (
<>
<a href="javascript:void(0)"
......@@ -135,7 +130,6 @@ export const mapStateToProps = (state: GlobalState) => {
const userEmail = state.user.loggedInUser.email;
return {
userEmail,
isLoading: state.issue.isLoading,
tableOwners: tableOwnersEmails,
tableMetadata: state.tableMetadata.tableData
};
......
......@@ -48,7 +48,6 @@ describe('ReportTableIssue', () => {
const setStateSpy = jest.spyOn(ReportTableIssue.prototype, 'setState');
const setup = (propOverrides?: Partial<ReportTableIssueProps>) => {
const props: ReportTableIssueProps = {
isLoading: false,
createIssue: jest.fn(),
tableKey: 'key',
tableName: 'name',
......@@ -72,7 +71,7 @@ describe('ReportTableIssue', () => {
});
it('Renders modal if open', () => {
const { props, wrapper } = setup({isLoading: false});
const { props, wrapper } = setup();
wrapper.setState({isOpen: true});
expect(wrapper.find('.report-table-issue-modal')).toBeTruthy();
});
......@@ -128,10 +127,6 @@ describe('ReportTableIssue', () => {
beforeAll(() => {
result = mapStateToProps(globalState);
});
it('sets isLoading on the props', () => {
expect(result.isLoading).toEqual(globalState.issue.isLoading);
});
});
});
});
......@@ -7,6 +7,7 @@ import { Issue } from 'interfaces';
import { getIssues } from 'ducks/issue/reducer';
import { logClick } from 'ducks/utilMethods';
import { GetIssuesRequest } from 'ducks/issue/types';
import LoadingSpinner from 'components/common/LoadingSpinner';
import ReportTableIssue from 'components/TableDetail/ReportTableIssue';
import { NO_DATA_ISSUES_TEXT } from './constants';
import './styles.scss';
......@@ -15,6 +16,7 @@ export interface StateFromProps {
issues: Issue[];
total: number;
allIssuesUrl: string;
isLoading: boolean;
}
export interface DispatchFromProps {
......@@ -89,6 +91,17 @@ export class TableIssues extends React.Component<TableIssueProps> {
}
render() {
if (this.props.isLoading) {
return (
<div>
{this.renderIssueTitle()}
<div className="table-issues">
<LoadingSpinner />
</div>
</div>
)
}
if (this.props.issues.length === 0) {
return (
<div>
......@@ -119,7 +132,8 @@ export const mapStateToProps = (state: GlobalState) => {
return {
issues: state.issue.issues,
total: state.issue.total,
allIssuesUrl: state.issue.allIssuesUrl
allIssuesUrl: state.issue.allIssuesUrl,
isLoading: state.issue.isLoading,
};
};
......
......@@ -53,6 +53,9 @@
.minor {
background-color: rgba($priority-bg-color, .1);
}
.loading-spinner {
margin-top: auto;
}
}
.table-issue-more-issues {
margin-bottom: $spacer-1;
......
......@@ -21,6 +21,7 @@ describe ('TableIssues', ()=> {
const setup = (propOverrides?: Partial<TableIssueProps>) => {
const props: TableIssueProps = {
isLoading: false,
issues: [],
tableKey: 'key',
tableName: 'tableName',
......@@ -38,6 +39,11 @@ describe ('TableIssues', ()=> {
AppConfig.issueTracking.enabled = true;
});
it('renders LoadingSpinner if loading', () => {
const { props, wrapper } = setup({ isLoading: true });
expect(wrapper.find('LoadingSpinner').exists()).toBe(true);
});
it('renders text if no issues', () => {
const { props, wrapper } = setup({ issues: [] });
expect(wrapper.find('.issue-banner').text()).toEqual(NO_DATA_ISSUES_TEXT);
......@@ -106,5 +112,9 @@ describe ('TableIssues', ()=> {
it('sets issues on the props', () => {
expect(result.issues).toEqual(globalState.issue.issues);
});
it('sets isLoading on the props', () => {
expect(result.isLoading).toEqual(globalState.issue.isLoading);
});
});
});
......@@ -3,7 +3,7 @@ from unittest.mock import Mock
import flask
import unittest
from amundsen_application.proxy.issue_tracker_clients.issue_exceptions import IssueConfigurationException
from amundsen_application.proxy.issue_tracker_clients.jira_client import JiraClient
from amundsen_application.proxy.issue_tracker_clients.jira_client import JiraClient, SEARCH_STUB_ALL_ISSUES
from amundsen_application.models.data_issue import DataIssue
from jira import JIRAError
from typing import Dict, List
......@@ -101,7 +101,7 @@ class JiraClientTest(unittest.TestCase):
self.assertEqual(results.issues[0], self.mock_issue)
self.assertEqual(results.total, self.mock_jira_issues.total)
mock_JIRA_client.return_value.search_issues.assert_called_with(
'text ~ "key" order by createdDate DESC',
SEARCH_STUB_ALL_ISSUES.format(table_key="key"),
maxResults=3)
@unittest.mock.patch('amundsen_application.proxy.issue_tracker_clients.jira_client.JIRA')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment