-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1537 export a serviceUrl function
- Loading branch information
Showing
6 changed files
with
74 additions
and
110 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import type { AssetUrlParams } from '@enonic-types/lib-portal'; // Might be deprecated in XP8. | ||
|
||
import { getUrlType } from '/lib/enonic/react4xp/React4xp/utils/getUrlType'; | ||
import { serviceUrl } from '/lib/enonic/react4xp/serviceUrl'; | ||
|
||
|
||
export interface R4xAssetUrlParams extends AssetUrlParams { | ||
service?: string; | ||
} | ||
|
||
|
||
export function assetUrl({ | ||
application = app.name, | ||
params, | ||
path = '/', | ||
service = 'asset', | ||
type = getUrlType() | ||
}: R4xAssetUrlParams): string { | ||
return serviceUrl({ | ||
application, | ||
params, | ||
path, | ||
service, | ||
type | ||
}); | ||
} |
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,37 @@ | ||
import type { ServiceUrlParams } from '@enonic-types/lib-portal'; // Might be deprecated in XP8. | ||
|
||
import { getUrlType } from '/lib/enonic/react4xp/React4xp/utils/getUrlType'; | ||
|
||
|
||
interface ServiceUrlBuilder { | ||
setApplication(value: string): void; | ||
setParams(value: object): void; | ||
setPath(value: string): void; | ||
setType(value: string): void; | ||
setServiceName(value: string): void; | ||
createUrl(): string; | ||
} | ||
|
||
|
||
export interface R4xServiceUrlParams extends ServiceUrlParams { | ||
path?: string; | ||
} | ||
|
||
|
||
export function serviceUrl({ | ||
application = app.name, | ||
params, | ||
path = '/', | ||
service, | ||
type = getUrlType() | ||
}: R4xServiceUrlParams): string { | ||
const bean: ServiceUrlBuilder = __.newBean('com.enonic.lib.react4xp.url.ServiceUrlBuilder'); | ||
|
||
bean.setApplication(application); | ||
bean.setParams(params); | ||
bean.setPath(path); | ||
bean.setType(type); | ||
bean.setServiceName(service); | ||
|
||
return bean.createUrl(); | ||
} |
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