forked from onecx/onecx-portal-ui-libs
-
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.
Merge branch 'main' into fix/horizontal-menu-icons
- Loading branch information
Showing
44 changed files
with
440 additions
and
179 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
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
40 changes: 40 additions & 0 deletions
40
libs/angular-accelerator/src/lib/utils/string-and-array-helper-functions.utils.spec.ts
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,40 @@ | ||
import { | ||
findEntryWithKeyword, | ||
removeKeyword, | ||
searchPrefixWithSpecialChars, | ||
} from './string-and-array-helper-functions.utils' | ||
|
||
describe('findEntryWithKeyword', () => { | ||
it('should find the entry containing the keyword', () => { | ||
expect(findEntryWithKeyword(['entry1', 'entry2', 'keywordEntry'], 'keyword')).toBe('keywordEntry') | ||
expect(findEntryWithKeyword(['entry1', 'entry2', 'entry3'], 'keyword')).toBe(null) | ||
expect(findEntryWithKeyword(undefined, 'keyword')).toBe(null) | ||
}) | ||
}) | ||
|
||
describe('removeKeyword', () => { | ||
it('should remove the keyword and trailing details from the input string', () => { | ||
expect(removeKeyword('/onecx-mgmt-page/keyword/123', 'keyword')).toBe('/onecx-mgmt-page') | ||
expect(removeKeyword('/onecx-mgmt-page/keyword/123/', 'keyword')).toBe('/onecx-mgmt-page') | ||
expect(removeKeyword('/onecx-mgmt-page/search/123', 'keyword')).toBe('/onecx-mgmt-page/search/123') | ||
}) | ||
|
||
describe('searchPrefixWithSpecialChars', () => { | ||
it('should return the latest string starting with the prefix followed by ? or #', () => { | ||
const exampleUrls1 = ['onecx-mgmt-page?id', 'onecx-mgmt-page#id', 'ibt-order-mgmt-page#id'] | ||
const exampleUrls2 = ['onecx-mgmt-page#id', 'onecx-mgmt-page#id', 'onecx-mgmt-page?id'] | ||
const prefix = 'onecx-mgmt-page' | ||
const expected1 = 'onecx-mgmt-page#id' | ||
const expected2 = 'onecx-mgmt-page?id' | ||
expect(searchPrefixWithSpecialChars(exampleUrls1, prefix)).toEqual(expected1) | ||
expect(searchPrefixWithSpecialChars(exampleUrls2, prefix)).toEqual(expected2) | ||
}) | ||
|
||
it('should return the latest string of an array starting with the prefix followed by ? or #', () => { | ||
const strings = ['test?case', 'test#case', 'test case', 'example?test', 'example#test'] | ||
const prefix = 'test' | ||
const expected = 'test#case' | ||
expect(searchPrefixWithSpecialChars(strings, prefix)).toEqual(expected) | ||
}) | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
libs/angular-accelerator/src/lib/utils/string-and-array-helper-functions.utils.ts
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,31 @@ | ||
export function findEntryWithKeyword( | ||
array: string[] | undefined, | ||
keyword: string, | ||
): string | null { | ||
const entry = array?.find((entry) => entry.includes(keyword)); | ||
return entry || null; | ||
} | ||
|
||
export function removeKeyword(input: string, keyword: string): string { | ||
let result = input.replace(new RegExp(`/${keyword}.*`), ''); | ||
if (result.endsWith('/')) { | ||
result = result.slice(0, -1); | ||
} | ||
return result; | ||
} | ||
|
||
export function searchPrefixWithSpecialChars( | ||
strings: string[], | ||
prefix: string, | ||
): string | null { | ||
for (let i = strings.length - 1; i >= 0; i--) { | ||
const str = strings[i]; | ||
if ( | ||
str.startsWith(prefix) && | ||
(str[prefix.length] === '?' || str[prefix.length] === '#') | ||
) { | ||
return str; | ||
} | ||
} | ||
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
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
5 changes: 5 additions & 0 deletions
5
libs/integration-interface/src/lib/topics/events/v1/navigated-event-payload.ts
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,5 @@ | ||
export type NavigatedEventPayload = { | ||
url: string | undefined | ||
isFirst: boolean | ||
history: string[] | ||
} |
Oops, something went wrong.