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