-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add boolean property to config (#1521)
This pull request resolves the issue #1211 This property is later used to prevent the popup of a new page. When set to true, it will alter all _blank targets for links to empty. A utils function is provided. --------- Signed-off-by: Benjamin Klein <benjamin.klein.bk1@roche.com> Signed-off-by: Benjamin Klein <45211351+Binrix@users.noreply.github.com> Co-authored-by: Benjamin Klein <benjamin.klein.bk1@roche.com> Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
- Loading branch information
1 parent
1cad58c
commit 3abc200
Showing
10 changed files
with
91 additions
and
7 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
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
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) 2023 The Jaeger Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import * as getConfig from './get-config'; | ||
import { getTargetBlankOrTop, getTargetEmptyOrBlank } from './get-target'; | ||
|
||
let getConfigValueSpy; | ||
|
||
beforeAll(() => { | ||
getConfigValueSpy = jest.spyOn(getConfig, 'getConfigValue'); | ||
}); | ||
|
||
describe('getTarget', () => { | ||
it('getTargetEmptyOrBlank returns empty because forbidNewPage is true', () => { | ||
getConfigValueSpy.mockReturnValue(true); | ||
const target = getTargetEmptyOrBlank(); | ||
expect(target).toBe(''); | ||
}); | ||
it('getTargetEmptyOrBlank returns _blank because forbidNewPage is true', () => { | ||
getConfigValueSpy.mockReturnValue(false); | ||
const target = getTargetEmptyOrBlank(); | ||
expect(target).toBe('_blank'); | ||
}); | ||
it('getTargetBlankOrTop returns _top because forbidNewPage is true', () => { | ||
getConfigValueSpy.mockReturnValue(true); | ||
const target = getTargetBlankOrTop(); | ||
expect(target).toBe('_top'); | ||
}); | ||
it('getTargetBlankOrTop returns _blank because forbidNewPage is true', () => { | ||
getConfigValueSpy.mockReturnValue(false); | ||
const target = getTargetBlankOrTop(); | ||
expect(target).toBe('_blank'); | ||
}); | ||
}); |
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,23 @@ | ||
// Copyright (c) 2023 The Jaeger Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { getConfigValue } from './get-config'; | ||
|
||
export function getTargetEmptyOrBlank() { | ||
return getConfigValue('forbidNewPage') ? '' : '_blank'; | ||
} | ||
|
||
export function getTargetBlankOrTop() { | ||
return getConfigValue('forbidNewPage') ? '_top' : '_blank'; | ||
} |