-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed
disabling
the requests, improved notification links (#8197)
<!-- Raise an issue to propose your change (https://github.com/cvat-ai/cvat/issues). It helps to avoid duplication of efforts from multiple independent contributors. Discuss your ideas with maintainers to be sure that changes will be approved and merged. Read the [Contribution guide](https://docs.cvat.ai/docs/contributing/). --> <!-- Provide a general summary of your changes in the Title above --> ### Motivation and context <!-- Why is this change required? What problem does it solve? If it fixes an open issue, please link to the issue here. Describe your changes in detail, add screenshots. --> The pr adresses two problems: 1. If we download something from requests page, the card will be disabled. But if we go to another page after it, it will be enabled again. The pr adds storing of disabled requests to global store 2. Improved links that are shown by requests notifications. We render them as buttons that operate with react router instead of plain `<a>` tags, using which reloads the page. ### How has this been tested? <!-- Please describe in detail how you tested your changes. Include details of your testing environment, and the tests you ran to see how your change affects other areas of the code, etc. --> Manual ### Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. If an item isn't applicable for some reason, then ~~explicitly strikethrough~~ the whole line. If you don't do that, GitHub will show incorrect progress for the pull request. If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I submit my changes into the `develop` branch - [ ] I have created a changelog fragment <!-- see top comment in CHANGELOG.md --> - ~~[ ] I have updated the documentation accordingly~~ - ~~[ ] I have added tests to cover my changes~~ - ~~[ ] I have linked related issues (see [GitHub docs]( https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))~~ - [x] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning), [cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning)) ### License - [x] I submit _my code changes_ under the same [MIT License]( https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new action to disable requests, expanding request management functionality. - Added a new `CVATMarkdown` component for improved rendering of markdown content in error notifications. - **Enhancements** - Replaced `ReactMarkdown` with `CVATMarkdown` across various components for consistent error message formatting. - Added a `disabled` prop to `RequestCard` component to manage interactive states. - **Bug Fixes** - Improved notification message formatting by adding punctuation to the end of sentences. - **Styles** - Added a new CSS class for better styling of notification links. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Boris Sekachev <boris.sekachev@yandex.ru>
- Loading branch information
Showing
15 changed files
with
136 additions
and
41 deletions.
There are no files selected for viewing
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,8 @@ | ||
### Fixed | ||
|
||
- Request card was not disabed properly after downloading | ||
(<https://github.com/cvat-ai/cvat/pull/8197>) | ||
|
||
### Changed | ||
- Following the link in notification no longer reloads the page | ||
(<https://github.com/cvat-ai/cvat/pull/8197>) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (C) 2024 CVAT.ai Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import Button from 'antd/lib/button'; | ||
import React from 'react'; | ||
import ReactMarkdown from 'react-markdown'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
|
||
export type UseHistoryType = RouteComponentProps['history']; | ||
|
||
const RouterLinkHOC = (history?: UseHistoryType) => ( | ||
function (props: { children: React.ReactNode, href?: string }): JSX.Element { | ||
const { href, children } = props; | ||
|
||
if (href?.match(/^\//) && history) { | ||
return ( | ||
<Button | ||
type='link' | ||
className='cvat-notification-link' | ||
onClick={() => { | ||
history.push(href); | ||
}} | ||
> | ||
{children} | ||
</Button> | ||
); | ||
} | ||
|
||
return (<a href={href}>{children}</a>); | ||
}); | ||
|
||
export default function CVATMarkdown(props: { history?: UseHistoryType, children: string }): JSX.Element { | ||
const { children, history } = props; | ||
|
||
return ( | ||
<ReactMarkdown | ||
components={{ | ||
a: RouterLinkHOC(history), | ||
}} | ||
> | ||
{children} | ||
</ReactMarkdown> | ||
); | ||
} |
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
Oops, something went wrong.