forked from acaldas/document-model-electron
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from powerhouse-inc/76-implement-switchboard-…
…link-into-rwa-editor feat: enabled switchboard link in RWA editor
- Loading branch information
Showing
6 changed files
with
67 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { FileNode } from 'document-model-libs/document-drive'; | ||
import { getSwitchboardUrl } from 'src/utils/getSwitchboardUrl'; | ||
import { openUrl } from 'src/utils/openUrl'; | ||
import { useDocumentDriveById } from './useDocumentDriveById'; | ||
|
||
export const useOpenSwitchboardLink = (driveId: string) => { | ||
const { isRemoteDrive, remoteUrl } = useDocumentDriveById(driveId); | ||
|
||
return async (document?: FileNode) => { | ||
if (!remoteUrl) return; | ||
if (!isRemoteDrive) return; | ||
|
||
const url = new URL(remoteUrl); | ||
const baseUrl = url.origin; | ||
|
||
if (document) { | ||
const url = getSwitchboardUrl( | ||
baseUrl, | ||
driveId, | ||
document.documentType, | ||
document.id, | ||
); | ||
|
||
await openUrl(url); | ||
} | ||
}; | ||
}; |
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