Unverified Commit 15d9c3ca authored by Tamika Tannis's avatar Tamika Tannis Committed by GitHub

Add source for notification email links (#312)

* Add source for notification email links

* Update TableDetail logic
parent 97678d63
...@@ -86,8 +86,8 @@ def get_notification_html(*, notification_type: str, options: Dict, sender: str) ...@@ -86,8 +86,8 @@ def get_notification_html(*, notification_type: str, options: Dict, sender: str)
validate_options(options=options) validate_options(options=options)
url_base = app.config['FRONTEND_BASE'] url_base = app.config['FRONTEND_BASE']
resource_url = '{url_base}{resource_path}'.format(resource_path=options.get('resource_path'), resource_url = '{url_base}{resource_path}?source=notification'.format(resource_path=options.get('resource_path'),
url_base=url_base) url_base=url_base)
joined_chars = resource_url[len(url_base) - 1:len(url_base) + 1] joined_chars = resource_url[len(url_base) - 1:len(url_base) + 1]
if joined_chars.count('/') != 1: if joined_chars.count('/') != 1:
raise Exception('Configured "FRONTEND_BASE" and "resource_path" do not form a valid url') raise Exception('Configured "FRONTEND_BASE" and "resource_path" do not form a valid url')
......
...@@ -123,7 +123,7 @@ export class TableDetail extends React.Component<TableDetailProps & RouteCompone ...@@ -123,7 +123,7 @@ export class TableDetail extends React.Component<TableDetailProps & RouteCompone
const searchIndex = params['index']; const searchIndex = params['index'];
const source = params['source']; const source = params['source'];
/* update the url stored in the browser history to remove params used for logging purposes */ /* update the url stored in the browser history to remove params used for logging purposes */
if (searchIndex !== undefined) { if (searchIndex !== undefined || source !== undefined) {
window.history.replaceState({}, '', `${window.location.origin}${window.location.pathname}`); window.history.replaceState({}, '', `${window.location.origin}${window.location.pathname}`);
} }
......
...@@ -110,7 +110,7 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -110,7 +110,7 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>You have been added to the owners list of the ' expectedHTML = ('Hello,<br/><br/>You have been added to the owners list of the '
'<a href="http://0.0.0.0:5000/testpath">testtable</a>' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a>'
' dataset by test@test.com.<br/><br/>What is expected of you?<br/>As an owner, you take an ' ' dataset by test@test.com.<br/><br/>What is expected of you?<br/>As an owner, you take an '
'important part in making sure that the datasets you own can be used as swiftly as possible ' 'important part in making sure that the datasets you own can be used as swiftly as possible '
'across the company.<br/>Make sure the metadata is correct and up to date.<br/><br/>If you ' 'across the company.<br/>Make sure the metadata is correct and up to date.<br/><br/>If you '
...@@ -132,9 +132,9 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -132,9 +132,9 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>You have been removed from the owners list of the ' expectedHTML = ('Hello,<br/><br/>You have been removed from the owners list of the '
'<a href="http://0.0.0.0:5000/testpath">testtable</a> dataset by test@test.com.<br/><br/>If you' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a> dataset by'
' think you have been incorrectly removed as an owner, add yourself back to the owners list.' ' test@test.com.<br/><br/>If you think you have been incorrectly removed as an owner,'
'<br/><br/>Thanks,<br/>Amundsen Team') ' add yourself back to the owners list.<br/><br/>Thanks,<br/>Amundsen Team')
self.assertEqual(html, expectedHTML) self.assertEqual(html, expectedHTML)
def test_get_notification_html_requested_success_all_fields(self) -> None: def test_get_notification_html_requested_success_all_fields(self) -> None:
...@@ -156,7 +156,7 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -156,7 +156,7 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use ' expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use '
'<a href="http://0.0.0.0:5000/testpath">testtable</a>, ' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a>, '
'and requests improved table and column descriptions.<br/><br/>test@test.com has included the ' 'and requests improved table and column descriptions.<br/><br/>test@test.com has included the '
'following information with their request:<br/>Test Comment<br/><br/>Please visit the provided ' 'following information with their request:<br/>Test Comment<br/><br/>Please visit the provided '
'link and improve descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team') 'link and improve descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team')
...@@ -180,7 +180,7 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -180,7 +180,7 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use ' expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use '
'<a href="http://0.0.0.0:5000/testpath">testtable</a>, and requests ' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a>, and requests '
'an improved table description.<br/><br/>Please visit the provided link and improve ' 'an improved table description.<br/><br/>Please visit the provided link and improve '
'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team') 'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team')
self.assertEqual(html, expectedHTML) self.assertEqual(html, expectedHTML)
...@@ -203,7 +203,7 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -203,7 +203,7 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use ' expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use '
'<a href="http://0.0.0.0:5000/testpath">testtable</a>, and requests ' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a>, and requests '
'improved column descriptions.<br/><br/>Please visit the provided link and improve ' 'improved column descriptions.<br/><br/>Please visit the provided link and improve '
'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team') 'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team')
self.assertEqual(html, expectedHTML) self.assertEqual(html, expectedHTML)
...@@ -225,7 +225,7 @@ class NotificationUtilsTest(unittest.TestCase): ...@@ -225,7 +225,7 @@ class NotificationUtilsTest(unittest.TestCase):
options=test_options, options=test_options,
sender=test_sender) sender=test_sender)
expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use ' expectedHTML = ('Hello,<br/><br/>test@test.com is trying to use '
'<a href="http://0.0.0.0:5000/testpath">testtable</a>, and requests ' '<a href="http://0.0.0.0:5000/testpath?source=notification">testtable</a>, and requests '
'more information about that resource.<br/><br/>Please visit the provided link and improve ' 'more information about that resource.<br/><br/>Please visit the provided link and improve '
'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team') 'descriptions on that resource.<br/><br/>Thanks,<br/>Amundsen Team')
self.assertEqual(html, expectedHTML) self.assertEqual(html, expectedHTML)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment