Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/code export fixes #190

Merged
merged 2 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/src/modules/files/components/files-table/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
border-bottom: none !important;
}

.container th {
font-size: 13px !important;
}

.startCell {
padding-left: 10px;
}
Expand All @@ -23,7 +27,6 @@
margin-right: 10px;
}


.removeButton {
display: flex;
align-items: center;
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/modules/output-checker/components/request/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import startCase from 'lodash/startCase';
import SelectClearIcon from '@atlaskit/icon/glyph/select-clear';
import { RequestSchema } from '@src/modules/requests/types';
import { _e } from '@src/utils';
import { uid } from 'react-uid';

import * as styles from './styles.css';

Expand Down Expand Up @@ -59,6 +60,15 @@ function Sidebar({
{startCase(get(data, 'exportType', 'data'))}
</span>
</div>
<h6>Projects</h6>
<div id="request-projects">
{data.projects &&
data.projects.map(p => (
<p key={uid(p)} className="request-project-text">
{p}
</p>
))}
</div>
<h6>Reviewers</h6>
{data.reviewers.length > 0 && (
<p id="request-assigned-oc">{assignedUser}</p>
Expand Down
20 changes: 8 additions & 12 deletions frontend/src/modules/reports/components/main/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ function ReportsMain({
<header className={styles.header}>
<h2>
Dashboard
<small>{`Filtering from ${format(
startDate,
titleDateFormat
)} to ${format(endDate, titleDateFormat)}`}</small>
<small>
{`Filtering from ${format(
startDate,
titleDateFormat,
)} to ${format(endDate, titleDateFormat)}`}
</small>
</h2>
</header>
<Filters
Expand Down Expand Up @@ -83,7 +85,7 @@ function ReportsMain({
</Grid>
<Grid layout="fluid">
<GridColumn medium={12}>
<div id="reports-list-table">
<div id="reports-list-table" className={styles.table}>
<DynamicTableStateless
emptyView={<Empty />}
head={head}
Expand All @@ -95,12 +97,6 @@ function ReportsMain({
onSort={sortProps => onSort(sortProps)}
/>
</div>
<footer>
<small>
* Date an output checker either approved or requested revisions
for a request.
</small>
</footer>
</GridColumn>
</Grid>
</Page>
Expand All @@ -121,7 +117,7 @@ ReportsMain.propTypes = {
id: PropTypes.string,
name: PropTypes.string,
totalRequests: PropTypes.number,
})
}),
).isRequired,
onRequestStateChange: PropTypes.func.isRequired,
onSort: PropTypes.func.isRequired,
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/modules/reports/components/main/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.header {
margin-top: 20px;
padding-bottom: 20px;
border-bottom: 2px solid #DFE1E6;
border-bottom: 2px solid #dfe1e6;
}

.header > * {
Expand All @@ -26,13 +26,18 @@
margin: 20px 0 50px;
}

.projectsTable th,
.table th {
font-size: 13px !important;
}

.filters {
padding: 10px 0;
margin: 0 0 10px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 2px solid #DFE1E6;
border-bottom: 2px solid #dfe1e6;
}

.dateRange {
Expand All @@ -41,7 +46,7 @@
align-items: center;
}

.dateRange div[role="presentation"] {
.dateRange div[role='presentation'] {
width: calc(50% - 15px);
}

Expand Down
15 changes: 6 additions & 9 deletions frontend/src/modules/requests/components/request-form/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,12 @@ function NewRequestForm({
</Field>
))}
</FormSection>
{helpURL && (
<FormSection title="Additional help">
For guidance, please review the{' '}
<a href={helpURL} target="_blank" rel="noopener noreferrer">
available documentation
</a>
.
</FormSection>
)}
<FormSection title="Additional help">
<p>
For guidance, please review the documentation in your project
folder.
</p>
</FormSection>
<FormSection>
<SectionMessage
appearance="warning"
Expand Down
21 changes: 18 additions & 3 deletions frontend/src/modules/requests/components/request/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import CheckCircleIcon from '@atlaskit/icon/glyph/check-circle';
import SectionMessage from '@atlaskit/section-message';
import ExportTypeIcon from '@src/components/export-type-icon';
import Page, { Grid, GridColumn } from '@atlaskit/page';
Expand All @@ -24,6 +25,7 @@ import RequestType from './request-type';
import StateLabel from '../state-label';
import Sidebar from '../../containers/sidebar';
import { RequestSchema } from '../../types';
import { validCode, failedCode } from '../../utils';
import * as styles from './styles.css';

class Request extends React.Component {
Expand Down Expand Up @@ -84,9 +86,11 @@ class Request extends React.Component {
const isCodeExport = data.exportType === 'code';
const mergeRequestStatusCode = get(data, 'mergeRequestStatus.code');
const showMergeRequestError =
isCodeExport && mergeRequestStatusCode === 400;
isCodeExport && mergeRequestStatusCode === failedCode;
const showMergeRequestLoading =
isCodeExport && mergeRequestStatusCode < 200;
isCodeExport && mergeRequestStatusCode < validCode;
const showMergeRequestComplete =
isCodeExport && mergeRequestStatusCode === validCode;

return (
<div id="requests-page">
Expand Down Expand Up @@ -154,7 +158,9 @@ class Request extends React.Component {
<div id="request-details" className={styles.main}>
<Grid>
<GridColumn medium={9}>
{(showMergeRequestLoading || showMergeRequestError) &&
{(showMergeRequestComplete ||
showMergeRequestLoading ||
showMergeRequestError) &&
!isEditing && (
<div className={styles.mergeRequestStatus}>
{showMergeRequestLoading && (
Expand All @@ -163,6 +169,15 @@ class Request extends React.Component {
wait before submitting.
</SectionMessage>
)}
{showMergeRequestComplete && data.state < 2 && (
<SectionMessage
appearance="confirmation"
icon={CheckCircleIcon}
>
<strong>Merge Request Complete</strong>. Please submit
your request.
</SectionMessage>
)}
{showMergeRequestError && (
<SectionMessage appearance="error">
{get(
Expand Down
64 changes: 44 additions & 20 deletions frontend/src/modules/requests/components/request/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import SignInIcon from '@atlaskit/icon/glyph/sign-in';
import SignOutIcon from '@atlaskit/icon/glyph/sign-out';
import TrashIcon from '@atlaskit/icon/glyph/trash';

import { duplicateRequest } from '../../utils';
import {
duplicateRequest,
validCode,
invalidCode,
failedCode,
} from '../../utils';
import { RequestSchema } from '../../types';
import * as styles from './styles.css';

Expand Down Expand Up @@ -50,18 +55,26 @@ function RequestSidebar({
onWithdraw(data._id);
}
};
const mergeRequestStatusCode = get(
data,
'mergeRequestStatus.code',
invalidCode,
);
const validateEditButton = () => {
if (!isEditing && data.exportType === 'code') {
if (data.state > 1 || mergeRequestStatusCode <= validCode) {
return true;
}
}

return isSaving;
};

const validate = () => {
let isInvalid = isEditing || isSaving || data.state < 1;
if (data.exportType === 'data') {
isInvalid = data.files.length <= 0;
} else if (data.exportType === 'code') {
const invalidCode = 100;
const failedCode = 400;
const mergeRequestStatusCode = get(
data,
'mergeRequestStatus.code',
invalidCode,
);
isInvalid = !inRange(mergeRequestStatusCode, invalidCode, failedCode);
}

Expand All @@ -80,6 +93,15 @@ function RequestSidebar({
{startCase(get(data, 'exportType', 'data'))}
</span>
</div>
<h6>Projects</h6>
<div id="request-projects">
{data.projects &&
data.projects.map(p => (
<p key={uid(p)} className="request-project-text">
{p}
</p>
))}
</div>
<h6>Output Checker</h6>
<div id="request-reviewers">
{data.reviewers.map(d => (
Expand All @@ -92,17 +114,19 @@ function RequestSidebar({
<h6>Actions</h6>
{data.state >= 2 && data.state < 4 && (
<React.Fragment>
<div>
<Button
appearance="link"
id="request-sidebar-withdraw-button"
isDisabled={isSaving}
iconBefore={<SignOutIcon />}
onClick={withdrawHandler}
>
Edit Request
</Button>
</div>
{data.exportType !== 'code' && (
<div>
<Button
appearance="link"
id="request-sidebar-withdraw-button"
isDisabled={isSaving}
iconBefore={<SignOutIcon />}
onClick={withdrawHandler}
>
Edit Request
</Button>
</div>
)}
<div>
<Button
appearance="link"
Expand Down Expand Up @@ -134,7 +158,7 @@ function RequestSidebar({
appearance="link"
id="request-sidebar-edit-button"
iconBefore={<EditFilledIcon />}
isDisabled={isSaving}
isDisabled={validateEditButton()}
onClick={() => onEdit(data._id)}
>
{isEditing ? 'Done Editing' : 'Edit Request'}
Expand Down
18 changes: 11 additions & 7 deletions frontend/src/modules/requests/components/requests-list/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import AttachmentIcon from '@atlaskit/icon/glyph/attachment';
import Button, { ButtonGroup } from '@atlaskit/button';
import CodeIcon from '@atlaskit/icon/glyph/code';
import { Link } from 'react-router-dom';
import Date from '@src/components/date';
import { DynamicTableStateless } from '@atlaskit/dynamic-table';
Expand Down Expand Up @@ -116,10 +117,13 @@ function RequestsList({
{
content: (
<div className={styles.actionsColumn}>
<div>
<AttachmentIcon size="small" />
{` ${get(d, 'files.length', 0)}`}
</div>
{d.exportType === 'code' && <CodeIcon />}
{d.exportType !== 'code' && (
<div>
<AttachmentIcon size="small" />
{` ${get(d, 'files.length', 0)}`}
</div>
)}
<RequestMenu data={d} />
</div>
),
Expand Down Expand Up @@ -207,7 +211,7 @@ function RequestsList({
</header>
<Grid>
<GridColumn medium={12}>
<div id="requests-list-table">
<div id="requests-list-table" className={styles.table}>
<DynamicTableStateless
emptyView={renderEmpty()}
head={header}
Expand All @@ -219,7 +223,7 @@ function RequestsList({
/>
{isPaginationVisible && (
<Pagination
fetch={fetchRequests}
onClick={fetchRequests}
isLastPage={data.length < limit * page}
page={page}
/>
Expand All @@ -237,7 +241,7 @@ RequestsList.propTypes = {
_id: PropTypes.string,
name: PropTypes.string,
state: PropTypes.number,
})
}),
),
fetchRequests: PropTypes.func.isRequired,
filter: PropTypes.oneOfType([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
align-items: center;
justify-content: space-between;
padding: 0 0 15px;
border-bottom: 2px solid #DFE1E6;
border-bottom: 2px solid #dfe1e6;
}

.filters > div:last-child {
Expand All @@ -26,6 +26,10 @@
text-decoration: underline;
}

.table th {
font-size: 13px !important;
}

.actionsColumn {
display: flex;
justify-content: space-between;
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/modules/requests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import mapValues from 'lodash/mapValues';
import { repositoryHost } from '@src/services/config';
import { _e, getZoneString } from '@src/utils';

export const validCode = 200;
export const invalidCode = 100;
export const failedCode = 400;
// Form content
export const formText = {
data: {
Expand Down