-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BED-5110 added NoDataDialog component (#1046)
* 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
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/javascript/bh-shared-ui/src/components/NoDataDialog/NoDataDialog.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
packages/javascript/bh-shared-ui/src/components/NoDataDialog/NoDataDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages/javascript/bh-shared-ui/src/components/NoDataDialog/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters