Skip to content

Commit

Permalink
BED-5110 added NoDataDialog component (#1046)
Browse files Browse the repository at this point in the history
* BED-5110 added NoDataDialog component

* fixed test

* added check for domains back in

* passing query as props and fixing tests

* addressed PR comments
  • Loading branch information
Holocraft authored Jan 3, 2025
1 parent ec2580a commit 2d7bf4b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2023 Specter Ops, Inc.
//
// Licensed under the Apache License, Version 2.0
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

import { render, screen } from '../../test-utils';
import NoDataDialog from '.';

const gettingStartedLinkText = 'Getting Started guide';
const fileIngestLinkText = 'start by uploading your data';

describe('NoDataDialog', () => {
it('should render', () => {
render(
<NoDataDialog
gettingStartedLink={<>{gettingStartedLinkText}</>}
fileIngestLink={<>{fileIngestLinkText}</>}
open={true}
/>
);

expect(screen.getByText('No Data Available')).toBeInTheDocument();
expect(screen.getByText(/Getting Started guide/)).toBeInTheDocument();
expect(screen.getByText(/start by uploading your data/)).toBeInTheDocument();
});
it('should not render when data is present', () => {
render(
<NoDataDialog
gettingStartedLink={<>{gettingStartedLinkText}</>}
fileIngestLink={<>{fileIngestLinkText}</>}
open={false}
/>
);

expect(screen.queryByText('No Data Available')).not.toBeInTheDocument();
expect(screen.queryByText(/Getting Started guide/)).not.toBeInTheDocument();
expect(screen.queryByText(/start by uploading your data/)).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 Specter Ops, Inc.
//
// Licensed under the Apache License, Version 2.0
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

import { Dialog, DialogContent, DialogDescription, DialogPortal, DialogTitle } from '@bloodhoundenterprise/doodleui';

type NoDataDialogProps = {
fileIngestLink: JSX.Element;
gettingStartedLink: JSX.Element;
open: boolean;
};

export const NoDataDialog: React.FC<NoDataDialogProps> = ({ fileIngestLink, gettingStartedLink, open }) => {
return (
<Dialog
open={open}
onOpenChange={() => {
// unblocks the body from being clickable so the user can go to another tab
document.body.style.pointerEvents = '';
}}>
<DialogPortal>
<DialogContent className='focus:outline-none' DialogOverlayProps={{ className: 'top-12' }}>
<DialogTitle>No Data Available</DialogTitle>
<DialogDescription>
To explore your environment, {fileIngestLink}, on the file ingest page. Need help? Check out the{' '}
{gettingStartedLink} for instructions.
</DialogDescription>
</DialogContent>
</DialogPortal>
</Dialog>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023 Specter Ops, Inc.
//
// Licensed under the Apache License, Version 2.0
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

import { NoDataDialog } from './NoDataDialog';

export default NoDataDialog;
2 changes: 2 additions & 0 deletions packages/javascript/bh-shared-ui/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export { default as MenuItem } from './MenuItem';

export { default as NoDataAlert } from './NoDataAlert';

export { default as NoDataDialog } from './NoDataDialog';

export * from './NodeIcon';
export { default as NodeIcon } from './NodeIcon';

Expand Down

0 comments on commit 2d7bf4b

Please sign in to comment.