-
Notifications
You must be signed in to change notification settings - Fork 11
Open in new tab #856
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
Open in new tab #856
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
85adc37
feature: adding open in new tab icon on security overlay
20087d1
feat: changes for open in new tab component
6dfa494
fix: file rename and unti tests
aa34791
fix: lint fixes
b9e31b7
fix: lint fixes
4266e8b
fix: pr suggested changes
6169311
fix: pr suggested changes
101e0ce
fix: lint fixes
532fe1f
fix: pr suggested changes
65f9181
feat: pr suggested changes
98f65cd
feat: pr suggested changes
f7107cc
fix: merging main
f59b14f
fix: merging main
8ff748c
fix: imporving code coverage
b5d74ba
fix: removing unused utilities
b856073
Merge branch 'main' into open_in_new_tab
alok-traceable 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
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
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,9 +1,11 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { Dictionary } from 'lodash'; | ||
| import { isEmpty } from 'lodash-es'; | ||
| import { EMPTY, ReplaySubject } from 'rxjs'; | ||
| import { catchError, defaultIfEmpty, filter, map, switchMap, take } from 'rxjs/operators'; | ||
| import { NavigationService } from '../navigation/navigation.service'; | ||
| import { ReplayObservable } from '../utilities/rxjs/rxjs-utils'; | ||
| import { getQueryParamStringFromObject } from '../utilities/url/url-utilities'; | ||
| import { FixedTimeRange } from './fixed-time-range'; | ||
| import { RelativeTimeRange } from './relative-time-range'; | ||
| import { TimeDuration } from './time-duration'; | ||
|
|
@@ -30,15 +32,21 @@ export class TimeRangeService { | |
| } | ||
|
|
||
| public getShareableCurrentUrl(): string { | ||
| const timeRangeParamValue = this.navigationService.getQueryParameter(TimeRangeService.TIME_RANGE_QUERY_PARAM, ''); | ||
| const timeRangeParam = `${TimeRangeService.TIME_RANGE_QUERY_PARAM}=${timeRangeParamValue}`; | ||
| const timeRangeParam = getQueryParamStringFromObject(this.getTimeRangeParams()); | ||
| const timeRange = this.getCurrentTimeRange(); | ||
| const fixedTimeRange: FixedTimeRange = TimeRangeService.toFixedTimeRange(timeRange.startTime, timeRange.endTime); | ||
| const newTimeRangeParam = `${TimeRangeService.TIME_RANGE_QUERY_PARAM}=${fixedTimeRange.toUrlString()}`; | ||
|
|
||
| return this.navigationService.getAbsoluteCurrentUrl().replace(timeRangeParam, newTimeRangeParam); | ||
| } | ||
|
|
||
| public getTimeRangeParams(): Dictionary<string> { | ||
|
||
| const timeRangeParamValue = this.navigationService.getQueryParameter(TimeRangeService.TIME_RANGE_QUERY_PARAM, ''); | ||
| return { | ||
| [TimeRangeService.TIME_RANGE_QUERY_PARAM]: timeRangeParamValue | ||
| }; | ||
| } | ||
|
|
||
| public getTimeRangeAndChanges(): ReplayObservable<TimeRange> { | ||
| return this.timeRangeSubject$.asObservable(); | ||
| } | ||
|
|
||
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,47 @@ | ||
| import { Params } from '@angular/router'; | ||
| import { | ||
| getQueryParamStringFromObject, | ||
| getQueryParamObjectFromString | ||
| } from './url-utilities'; | ||
|
|
||
| describe('getQueryParamStringFromObject', () => { | ||
aaron-steinfeld marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| it('should return string from a string dictionary', () => { | ||
| const params: Params = {}; | ||
| expect(getQueryParamStringFromObject(params)).toBe(''); | ||
| params.a = undefined; | ||
| expect(getQueryParamStringFromObject(params)).toBe(''); | ||
| params.a = null; | ||
| expect(getQueryParamStringFromObject(params)).toBe(`a=null`); | ||
| params.a = true; | ||
| expect(getQueryParamStringFromObject(params)).toBe(`a=true`); | ||
| params.a = false; | ||
| expect(getQueryParamStringFromObject(params)).toBe(`a=false`); | ||
| params.b = false; | ||
| expect(getQueryParamStringFromObject(params)).toBe(`a=false&b=false`); | ||
| params.a = 'value_1'; | ||
| params.b = 'value_2'; | ||
| expect(getQueryParamStringFromObject(params)).toBe(`a=value_1&b=value_2`); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getQueryParamObjectFromString', () => { | ||
| it('should return object from a string', () => { | ||
| let queryParam = '?queryparam1=value'; | ||
| expect(getQueryParamObjectFromString(queryParam)).toHaveProperty('queryparam1'); | ||
| expect(getQueryParamObjectFromString(queryParam).queryparam1).toBe('value'); | ||
|
|
||
| queryParam = '?queryparam1='; | ||
| expect(getQueryParamObjectFromString(queryParam)).toHaveProperty('queryparam1'); | ||
| expect(getQueryParamObjectFromString(queryParam).queryparam1).toBe(''); | ||
|
|
||
| queryParam = 'queryparam1=value'; | ||
| expect(getQueryParamObjectFromString(queryParam)).toHaveProperty('queryparam1'); | ||
| expect(getQueryParamObjectFromString(queryParam).queryparam1).toBe('value'); | ||
|
|
||
| queryParam = '?queryparam1=value1&queryparam2=value2'; | ||
| expect(getQueryParamObjectFromString(queryParam)).toHaveProperty('queryparam1'); | ||
| expect(getQueryParamObjectFromString(queryParam).queryparam1).toBe('value1'); | ||
| expect(getQueryParamObjectFromString(queryParam)).toHaveProperty('queryparam2'); | ||
| expect(getQueryParamObjectFromString(queryParam).queryparam2).toBe('value2'); | ||
| }); | ||
| }); | ||
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,26 @@ | ||
| import { Dictionary, isEmpty } from "lodash" | ||
|
|
||
| export const getQueryParamStringFromObject = (params: Dictionary<string | number>): string => { | ||
aaron-steinfeld marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try { | ||
| const paramString: string = Object.entries(params) | ||
| .map(([key, value]) => value !== undefined ? `${key}=${value}` : '') | ||
alok-traceable marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .filter(item => item) | ||
| .join('&'); | ||
| return isEmpty(paramString) ? '' : paramString; | ||
| } catch (error) { | ||
alok-traceable marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return ``; | ||
| } | ||
| }; | ||
|
|
||
| export const getQueryParamObjectFromString = (string: string): Dictionary<string> => { | ||
aaron-steinfeld marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try { | ||
| string = string[0] === '?' ? string.substring(1) : string; | ||
| return string.split('&').reduce((acc: Dictionary<string>, item: string): Dictionary<string> => { | ||
| const [key, value] = item.split('='); | ||
| acc[key] = value; | ||
| return acc; | ||
| }, {}); | ||
| } catch (error) { | ||
| return {}; | ||
| } | ||
| }; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.