generated from graasp/graasp-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Graasp platforms perfix helper function (graasp/graasp#672)
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Graasp view (builder, player, library) constants | ||
export const BUILDER_ITEMS_PREFIX = '/items'; | ||
export const PLAYER_ITEMS_PREFIX = ''; | ||
export const LIBRARY_ITEMS_PREFIX = '/collections'; | ||
export const CLIENT_PREFIX = [BUILDER_ITEMS_PREFIX, PLAYER_ITEMS_PREFIX, LIBRARY_ITEMS_PREFIX]; |
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,16 @@ | ||
import { CLIENT_PREFIX, Context } from '@/constants'; | ||
|
||
export function getPlatformPrefix(shortLinkView: Context) { | ||
const [BUILDER_PREFIX, PLAYER_PREFIX, LIBRARY_PREFIX] = CLIENT_PREFIX; | ||
|
||
switch (shortLinkView) { | ||
case Context.Builder: | ||
return BUILDER_PREFIX; | ||
case Context.Library: | ||
return LIBRARY_PREFIX; | ||
case Context.Player: | ||
return PLAYER_PREFIX; | ||
default: | ||
throw new Error(`The given context '${shortLinkView}' is not valid`); | ||
} | ||
} |