-
Notifications
You must be signed in to change notification settings - Fork 23
MMI-3381 CHES outage #2531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
MMI-3381 CHES outage #2531
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import React from 'react'; | ||
| import { FaPaperPlane } from 'react-icons/fa6'; | ||
| import { useParams } from 'react-router-dom'; | ||
| import { useApp, useReportInstances, useReports } from 'store/hooks'; | ||
| import { useApp, useReportInstances, useReports, useSettings } from 'store/hooks'; | ||
| import { useUsers } from 'store/hooks/admin'; | ||
| import { | ||
| Button, | ||
|
|
@@ -24,11 +24,14 @@ const ReportInstancePreview: React.FC = () => { | |
| const { id } = useParams(); | ||
| const instanceId = parseInt(id ?? ''); | ||
| const [{ userInfo }] = useApp(); | ||
| const { editorUrl, subscriberUrl } = useSettings(); | ||
|
|
||
| const [isLoading, setIsLoading] = React.useState(true); | ||
| const [view, setView] = React.useState<IReportResultModel | undefined>(); | ||
| const [report, setReport] = React.useState<IReportModel>(); | ||
|
|
||
| console.error('ReportInstancePreview '); | ||
|
|
||
| const handlePreviewReport = React.useCallback( | ||
| async (instanceId: number) => { | ||
| try { | ||
|
|
@@ -67,14 +70,21 @@ const ReportInstancePreview: React.FC = () => { | |
| (v) => v, | ||
| ); | ||
|
|
||
| const htmlBlob = new Blob([email.body], { type: 'text/html' }); | ||
| const textBlob = new Blob([email.body], { type: 'text/plain' }); | ||
| // Replace the URL so that it points to the external site. | ||
| let fixed_body = email.body; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the email to only use the external URL. Because we are generating it in the Editor application it can result in the wrong one. |
||
| if (editorUrl && subscriberUrl) { | ||
| const urlReplaceRegex = new RegExp(editorUrl, 'gi'); | ||
| fixed_body = email.body.replace(urlReplaceRegex, subscriberUrl); | ||
| } | ||
|
|
||
| const htmlBlob = new Blob([fixed_body], { type: 'text/html' }); | ||
| const textBlob = new Blob([fixed_body], { type: 'text/plain' }); | ||
| const clip = new ClipboardItem({ 'text/html': htmlBlob, 'text/plain': textBlob }); | ||
| navigator.clipboard.write([clip]); | ||
| const bcc = subscribers.length ? `bcc=${emails.join('; ')}` : ''; | ||
| window.location.href = `mailto:${to}?${bcc}&subject=${email.subject}&body=Click Paste - Keep Source Formatting`; | ||
| }, | ||
| [getDistributionListById], | ||
| [editorUrl, getDistributionListById, subscriberUrl], | ||
| ); | ||
|
|
||
| React.useEffect(() => { | ||
|
|
||
32 changes: 32 additions & 0 deletions
32
app/editor/src/features/reports/ReportInstancesRedirect.tsx
This file contains hidden or 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,32 @@ | ||
| import { useKeycloak } from '@react-keycloak/web'; | ||
| import React from 'react'; | ||
| import { useNavigate, useParams } from 'react-router-dom'; | ||
|
|
||
| import ReportInstancePreview from './ReportInstancePreview'; | ||
|
|
||
| /** | ||
| * Temporary redirect component for report/instances view | ||
| * Redirects unauthenticated users to external URL | ||
| * Authenticated users are redirected to the normal view | ||
| */ | ||
| export const ReportInstancesRedirect: React.FC = () => { | ||
| const { keycloak } = useKeycloak(); | ||
| const { id } = useParams<{ id: string }>(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| React.useEffect(() => { | ||
| if (!keycloak?.authenticated) { | ||
| // Redirect unauthenticated users to external URL | ||
| // TODO: Replace EXTERNAL_URL_HERE with your actual external URL | ||
| const externalUrl = `https://mmi.gov.bc.ca/report/instances/${id}/view`; | ||
| window.location.href = externalUrl; | ||
| } else { | ||
| // Redirect authenticated users to the normal view | ||
| navigate(`/report/instances/${id}/view`, { replace: true }); | ||
| } | ||
| }, [keycloak?.authenticated, id, navigate]); | ||
|
|
||
| return <ReportInstancePreview />; // This component just handles the redirect | ||
| }; | ||
|
|
||
| export default ReportInstancesRedirect; |
Empty file.
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's an unauthenticated attempt to view the reports then redirect to subscriber site. This is part of a temporary work around.