forked from capability-boosters-dev/canvas-lms
-
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.
Create notification for dismissed announcements
Test plan: -create global announcement -dismiss announcement on dashboard -notification should show, click “view” button -should redirect to global announcements page closes KNO-500 flag=past_announcements Change-Id: I3ced1304fb7fb66699022fd93d46bd404e564b48 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/238062 Tested-by: Service Cloud Jenkins <[email protected]> Reviewed-by: Matthew Lemon <[email protected]> QA-Review: Matthew Lemon <[email protected]> Product-Review: Matthew Lemon <[email protected]>
- Loading branch information
1 parent
906a773
commit 240c9a1
Showing
7 changed files
with
146 additions
and
6 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
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,26 @@ | ||
/* | ||
* Copyright (C) 2020 - present Instructure, Inc. | ||
* | ||
* This file is part of Canvas. | ||
* | ||
* Canvas is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License as published by the Free | ||
* Software Foundation, version 3 of the License. | ||
* | ||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import $ from 'jquery' | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import PastGlobalAlert from '../past_global_announcements/PastGlobalAlert' | ||
|
||
$(() => { | ||
ReactDOM.render(<PastGlobalAlert />, $('<div/>').appendTo('#announcementWrapper')[0]) | ||
}) |
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,62 @@ | ||
/* | ||
* Copyright (C) 2020 - present Instructure, Inc. | ||
* | ||
* This file is part of Canvas. | ||
* | ||
* Canvas is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License as published by the Free | ||
* Software Foundation, version 3 of the License. | ||
* | ||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import React from 'react' | ||
import {Alert} from '@instructure/ui-alerts/lib/Alert' | ||
import {Button} from '@instructure/ui-buttons/lib/Button' | ||
import I18n from 'i18n!past_global_announcements' | ||
|
||
export default class PastGlobalAlert extends React.Component { | ||
state = { | ||
shouldRender: false | ||
} | ||
|
||
componentDidMount() { | ||
document.addEventListener('globalAlertShouldRender', this.handleAlertRender) | ||
} | ||
|
||
handleAlertRender = () => { | ||
this.setState({shouldRender: true}) | ||
} | ||
|
||
componentWillUnmount() { | ||
document.removeEventListener('globalAlertShouldRender', this.handleAlertRender) | ||
} | ||
|
||
render() { | ||
if (this.state.shouldRender && ENV.PAST_ANNOUNCEMENTS_ENABLED) { | ||
return ( | ||
<Alert> | ||
<div data-testid="globalAnnouncementsAlert"> | ||
{I18n.t(`You can view dismissed announcements by going to Account and selecting Global | ||
Announcements from the menu.`)} | ||
</div> | ||
<Button | ||
data-testid="globalAnnouncementsButton" | ||
href="/account_notifications" | ||
variant="primary" | ||
margin="small 0 0 0" | ||
> | ||
{I18n.t('View')} | ||
</Button> | ||
</Alert> | ||
) | ||
} | ||
return null | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
app/jsx/past_global_announcements/__tests__/pastGlobalAlert.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,41 @@ | ||
/* | ||
* Copyright (C) 2020 - present Instructure, Inc. | ||
* | ||
* This file is part of Canvas. | ||
* | ||
* Canvas is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License as published by the Free | ||
* Software Foundation, version 3 of the License. | ||
* | ||
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import PastGlobalAlert from '../PastGlobalAlert' | ||
import {render} from '@testing-library/react' | ||
import React from 'react' | ||
|
||
describe('render past global announcement alert', () => { | ||
beforeAll(() => { | ||
window.ENV.PAST_ANNOUNCEMENTS_ENABLED = true | ||
}) | ||
|
||
it('renders alert with message', async () => { | ||
const {findByTestId} = render(<PastGlobalAlert />) | ||
const event = new Event('globalAlertShouldRender') | ||
document.dispatchEvent(event) | ||
expect(await findByTestId('globalAnnouncementsAlert')).toBeVisible() | ||
}) | ||
|
||
it('renders button on alert', async () => { | ||
const {findByTestId} = render(<PastGlobalAlert />) | ||
const event = new Event('globalAlertShouldRender') | ||
document.dispatchEvent(event) | ||
expect(await findByTestId('globalAnnouncementsButton')).toBeVisible() | ||
}) | ||
}) |
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