Skip to content

Commit

Permalink
Merge pull request #286 from helxplatform/feat-landingspace
Browse files Browse the repository at this point in the history
FEAT: Adding a setting to configure the landing space for the website
  • Loading branch information
hina-shah authored Nov 15, 2023
2 parents 48e3479 + efc4e65 commit 21ed4c9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
REACT_APP_WORKSPACES_ENABLED=false
# Enable when working with Dug
REACT_APP_SEMANTIC_SEARCH_ENABLED='true'
# Identify landing spacein the UI:
REACT_APP_DEFAULT_SPACE='workspaces'
# Points the app to the Dug API
REACT_APP_HELX_SEARCH_URL='https:\/\/heal-dev.apps.renci.org\/search-api'
# Only necessary if working with analytics specifically.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ directly rather than regenerating it.
See `.env.example` for the most up to date variables and appropriate default values.
- `REACT_APP_REACT_APP_WORKSPACES_ENABLED`: enables workspaces functionality (requires Appstore)
- `REACT_APP_SEMANTIC_SEARCH_ENABLED`: enables semantic search functionality
- `REACT_APP_DEFAULT_SPACE`: identify default landing space: workspaces | search | support
- `REACT_APP_HELX_SEARCH_URL`: points the UI to the Dug semantic search API
- `REACT_APP_UI_BRAND_NAME`: heal | braini | catalyst | scidas | eduhelx | helx
- `REACT_APP_TRANQL_ENABLED`: enables the TranQL visualization pane in search results
Expand Down
2 changes: 1 addition & 1 deletion bin/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "brand": "", "color_scheme": { "primary": "#8a5a91", "secondary": "#505057" }, "search_url": "", "search_enabled": "true", "workspaces_enabled": "true" }
{ "brand": "", "color_scheme": { "primary": "#8a5a91", "secondary": "#505057" }, "search_url": "", "search_enabled": "true", "workspaces_enabled": "true", "default_space": "workspaces" }
3 changes: 3 additions & 0 deletions bin/populate_env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fi

workspaces_enabled="${REACT_APP_WORKSPACES_ENABLED:-true}"
search_enabled="${REACT_APP_SEMANTIC_SEARCH_ENABLED:-true}"
default_space="${REACT_APP_DEFAULT_SPACE:-search}"
search_url="${REACT_APP_HELX_SEARCH_URL}"
brand_name="${REACT_APP_UI_BRAND_NAME}"
tranql_url="${REACT_APP_TRANQL_URL:-\/tranql}"
Expand All @@ -28,6 +29,7 @@ template='{
"search_url": "%SEARCH_URL%",
"search_enabled": "%SEARCH_ENABLED%",
"workspaces_enabled": "%WORKSPACES_ENABLED%",
"default_space": "%DEFAULT_SPACE%",
"tranql_url": "%TRANQL_URL%",
"analytics": {
"enabled": %ANALYTICS_ENABLED%,
Expand All @@ -47,6 +49,7 @@ template='{
echo "$template" | sed \
-e "s/%WORKSPACES_ENABLED%/$workspaces_enabled/" \
-e "s/%SEARCH_ENABLED%/$search_enabled/" \
-e "s/%DEFAULT_SPACE%/$default_space/" \
-e "s/%SEARCH_URL%/$search_url/" \
-e "s/%BRAND%/$brand_name/" \
-e "s/%HIDDEN_SUPPORT_SECTIONS%/$hidden_support_sections/" \
Expand Down
27 changes: 15 additions & 12 deletions src/contexts/environment-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,25 @@ export const EnvironmentProvider = ({ children }) => {
// If workspace module is enabled, all relevant paths will be added. (/workspaces/active, workspace/available, ...)
// Note: `parent` property refers to another equivalent or encapsulating route that occupies an entry in the site's header.
// It's important to include this if applicable so that the header entry stays active, e.g. on subroutes of workspaces.
const generateRoutes = (searchEnabled, workspaceEnabled) => {
const generateRoutes = (searchEnabled, workspaceEnabled, defaultSpace) => {
const baseRoutes = [];
if (searchEnabled === 'true') {
// route homepage to search if search is enabled

// First push path for the landing space depending on what is defined in defaultSpace and enabled.
if (defaultSpace=='workspaces' && workspaceEnabled=='true') {
baseRoutes.push({ path: '/', parent: '/workspaces', text: '', Component: AvailableView })
}
else if(defaultSpace=='search' && searchEnabled=='true') {
baseRoutes.push({ path: '/', parent: '/search', text: '', Component: SearchView })
}
else{
baseRoutes.push({ path: '/', parent: '/support', text: '', Component: SupportView })
}

// Push space related paths
if (searchEnabled == 'true') {
baseRoutes.push({ path: '/search', text: 'Search', Component: SearchView })
}
if (workspaceEnabled === 'true') {
// route homepage to apps page if search is disabled
if (searchEnabled === 'false') {
baseRoutes.push({ path: '/', parent: '/workspaces', text: '', Component: AvailableView })
}
baseRoutes.push({ path: '/workspaces', text: 'Workspaces', Component: AvailableView })
baseRoutes.push({ path: '/workspaces/login', parent: '/workspaces', text: '', Component: WorkspaceLoginView })
baseRoutes.push({ path: '/workspaces/login/success', parent: '/workspaces', text: '', Component: LoginSuccessRedirectView })
Expand All @@ -63,10 +70,6 @@ export const EnvironmentProvider = ({ children }) => {
baseRoutes.push({ path: '/workspaces/active', parent: '/workspaces', text: '', Component: ActiveView })
baseRoutes.push({ path: '/connect/:app_name/:app_url', parent: '/workspaces', text: '', Component: SplashScreenView })
}
if (searchEnabled === 'false' && workspaceEnabled === 'false') {
// route homepage to support page if both search and workspaces are disabled
baseRoutes.push({ path: '/', parent: '/support', text: '', Component: SupportView })
}
baseRoutes.push({ path: '/support', text: 'Support', Component: SupportView })
return baseRoutes;
}
Expand Down Expand Up @@ -106,7 +109,7 @@ export const EnvironmentProvider = ({ children }) => {
// If workspace is enabled, all routes should have a '/helx' basePath as the ui is embedded in the appstore
useEffect(() => {
if (Object.keys(context).length !== 0) {
const routes = generateRoutes(context.search_enabled, context.workspaces_enabled);
const routes = generateRoutes(context.search_enabled, context.workspaces_enabled, context.default_space);
setAvailableRoutes(routes);
if (context.workspaces_enabled === 'true') {
setBasePath('/helx/');
Expand Down

0 comments on commit 21ed4c9

Please sign in to comment.