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

chore(toolbar): hide toolbar on errors #609

Merged
merged 2 commits into from
Nov 7, 2022
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
6 changes: 5 additions & 1 deletion src/app/Recordings/ActiveRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,11 @@ const ActiveRecordingsToolbar: React.FunctionComponent<ActiveRecordingsToolbarPr
}, [warningModalOpen, props.handleDeleteRecordings, handleWarningModalClose]);

return (
<Toolbar id="active-recordings-toolbar" clearAllFilters={props.handleClearFilters}>
<Toolbar
id="active-recordings-toolbar"
aria-label="active-recording-toolbar"
clearAllFilters={props.handleClearFilters}
>
<ToolbarContent>
<RecordingFilters
target={props.target}
Expand Down
13 changes: 9 additions & 4 deletions src/app/Recordings/ArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import * as React from 'react';
import { ArchivedRecording, RecordingDirectory, UPLOADS_SUBDIRECTORY } from '@app/Shared/Services/Api.service';
import { ServiceContext } from '@app/Shared/Services/Services';
Expand All @@ -52,7 +53,7 @@ import {
ToolbarItem,
} from '@patternfly/react-core';
import { Tbody, Tr, Td, ExpandableRowContent, TableComposable } from '@patternfly/react-table';
import { PlusIcon } from '@patternfly/react-icons';
import { UploadIcon } from '@patternfly/react-icons';
import { RecordingActions } from './RecordingActions';
import { RecordingsTable } from './RecordingsTable';
import { ReportFrame } from './ReportFrame';
Expand Down Expand Up @@ -655,7 +656,11 @@ const ArchivedRecordingsToolbar: React.FunctionComponent<ArchivedRecordingsToolb
}, [warningModalOpen, props.handleDeleteRecordings, handleWarningModalClose]);

return (
<Toolbar id="archived-recordings-toolbar" clearAllFilters={props.handleClearFilters}>
<Toolbar
id="archived-recordings-toolbar"
aria-label="archived-recording-toolbar"
clearAllFilters={props.handleClearFilters}
>
<ToolbarContent>
<RecordingFilters
target={props.target}
Expand Down Expand Up @@ -685,8 +690,8 @@ const ArchivedRecordingsToolbar: React.FunctionComponent<ArchivedRecordingsToolb
{props.isUploadsTable ? (
<ToolbarGroup variant="icon-button-group">
<ToolbarItem>
<Button variant="plain" aria-label="add" onClick={props.handleShowUploadModal}>
<PlusIcon />
<Button variant="secondary" aria-label="upload-recording" onClick={props.handleShowUploadModal}>
<UploadIcon />
</Button>
</ToolbarItem>
</ToolbarGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/app/Recordings/RecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export const RecordingsTable: React.FunctionComponent<RecordingsTableProps> = (p
context.target.setAuthRetry();
}, [context.target, context.target.setAuthRetry]);

if (props.errorMessage != '') {
const isError = React.useMemo(() => props.errorMessage != '', [props.errorMessage]);

if (isError) {
view = (
<>
<ErrorView
Expand Down Expand Up @@ -151,7 +153,7 @@ export const RecordingsTable: React.FunctionComponent<RecordingsTableProps> = (p
return (
<>
<OuterScrollContainer className="recording-table-container">
{props.toolbar}
{isError ? null : props.toolbar}
<InnerScrollContainer>{view}</InnerScrollContainer>
{props.tableFooter}
</OuterScrollContainer>
Expand Down
3 changes: 3 additions & 0 deletions src/test/Recordings/ActiveRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -484,5 +484,8 @@ describe('<ActiveRecordingsTable />', () => {
const retryButton = screen.getByText('Retry');
expect(retryButton).toBeInTheDocument();
expect(retryButton).toBeVisible();

const toolbar = screen.queryByLabelText('active-recording-toolbar');
expect(toolbar).not.toBeInTheDocument();
});
});
11 changes: 7 additions & 4 deletions src/test/Recordings/ArchivedRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ describe('<ArchivedRecordingsTable />', () => {

expect(screen.getByText('someRecording')).toBeInTheDocument();

const uploadButton = screen.getByLabelText('add');
const uploadButton = screen.getByLabelText('upload-recording');
expect(uploadButton).toHaveAttribute('type', 'button');

expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
Expand All @@ -450,7 +450,7 @@ describe('<ArchivedRecordingsTable />', () => {
}
);

userEvent.click(screen.getByLabelText('add'));
userEvent.click(screen.getByLabelText('upload-recording'));

const modal = await screen.findByRole('dialog');

Expand Down Expand Up @@ -506,7 +506,7 @@ describe('<ArchivedRecordingsTable />', () => {
}
);

userEvent.click(screen.getByLabelText('add'));
userEvent.click(screen.getByLabelText('upload-recording'));

const modal = await screen.findByRole('dialog');

Expand Down Expand Up @@ -583,7 +583,7 @@ describe('<ArchivedRecordingsTable />', () => {
}
);

userEvent.click(screen.getByLabelText('add'));
userEvent.click(screen.getByLabelText('upload-recording'));

const modal = await screen.findByRole('dialog');

Expand Down Expand Up @@ -668,5 +668,8 @@ describe('<ArchivedRecordingsTable />', () => {
const authFailText = screen.getByText('Something wrong');
expect(authFailText).toBeInTheDocument();
expect(authFailText).toBeVisible();

const toolbar = screen.queryByLabelText('archived-recording-toolbar');
expect(toolbar).not.toBeInTheDocument();
});
});