forked from jaegertracing/jaeger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Which problem is this PR solving?
- Resolves jaegertracing#663 ## Short description of the changes - Add a button with download functionality Signed-off-by: katarzyna <katarzyna@smaato.com>
- Loading branch information
1 parent
543de7a
commit d166e60
Showing
8 changed files
with
153 additions
and
10 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/jaeger-ui/src/components/SearchTracePage/SearchResults/DownloadResults.test.js
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,46 @@ | ||
// Copyright (c) 2023 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// 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. | ||
|
||
|
||
import * as React from "react"; | ||
import {Button} from "antd"; | ||
import {shallow} from "enzyme"; | ||
import DownloadResults from "./DownloadResults"; | ||
|
||
describe('DownloadResults button', () => { | ||
|
||
let wrapper; | ||
const getBtn = (btnIndex = 0) => wrapper.find(Button).at(btnIndex); | ||
const getLabel = (btnIndex = 0) => getBtn(btnIndex).prop('children'); | ||
const props = { | ||
onDownloadResultsClicked: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
wrapper = shallow(<DownloadResults {...props} />); | ||
}); | ||
|
||
it('when renders then correct label is showing', () => { | ||
expect(getLabel()).toBe('Download Results'); | ||
}); | ||
|
||
it('when click then call download results function', () => { | ||
expect(props.onDownloadResultsClicked).toHaveBeenCalledTimes(0); | ||
|
||
getBtn(0).simulate('click', {}); | ||
expect(props.onDownloadResultsClicked).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
}); |
35 changes: 35 additions & 0 deletions
35
packages/jaeger-ui/src/components/SearchTracePage/SearchResults/DownloadResults.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,35 @@ | ||
// Copyright (c) 2023 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// 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. | ||
|
||
import * as React from 'react'; | ||
import {Button} from 'antd'; | ||
|
||
type Props = { | ||
onDownloadResultsClicked: () => void; | ||
}; | ||
|
||
|
||
export default function DownloadResults(props: Props) { | ||
const {onDownloadResultsClicked} = props; | ||
const downloadBtn = ( | ||
<Button className="ub-ml2" htmlType="button" onClick={onDownloadResultsClicked}> | ||
Download Results | ||
</Button> | ||
); | ||
return ( | ||
<> | ||
{downloadBtn} | ||
</> | ||
); | ||
} |
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
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
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
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
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
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