-
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.
Merge branch 'develop' into advanced-routing
- Loading branch information
Showing
18 changed files
with
1,024 additions
and
835 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'zulu' | ||
|
||
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew build | ||
|
||
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). | ||
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. | ||
# | ||
# - name: Setup Gradle | ||
# uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
# with: | ||
# gradle-version: '8.5' | ||
# | ||
# - name: Build with Gradle 8.5 | ||
# run: gradle build | ||
|
||
dependency-submission: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'zulu' | ||
|
||
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md | ||
- name: Generate and submit dependency graph | ||
uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.xh-app .tb-chart-widget__buttons .xh-button.bp4-button.xh-button--enabled:focus, | ||
.xh-app.xh-dark .tb-chart-widget__buttons .xh-button.bp4-button.xh-button--enabled:focus, | ||
.xh-app.xh-dark.bp4-dark .tb-chart-widget__buttons .xh-button.bp4-button.xh-button--enabled:focus { | ||
.xh-app .tb-chart-widget__buttons .xh-button.bp5-button.xh-button--enabled:focus, | ||
.xh-app.xh-dark .tb-chart-widget__buttons .xh-button.bp5-button.xh-button--enabled:focus, | ||
.xh-app.xh-dark.bp5-dark .tb-chart-widget__buttons .xh-button.bp5-button.xh-button--enabled:focus { | ||
outline: none !important; | ||
} |
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
110 changes: 110 additions & 0 deletions
110
client-app/src/desktop/tabs/other/routing/SimpleRoutingPanel.tsx
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,110 @@ | ||
import {grid, GridModel} from '@xh/hoist/cmp/grid'; | ||
import {creates, hoistCmp, HoistModel, LoadSpec, managed, XH} from '@xh/hoist/core'; | ||
import {panel} from '@xh/hoist/desktop/cmp/panel'; | ||
import {Icon} from '@xh/hoist/icon'; | ||
import React from 'react'; | ||
import {wrapper} from '../../../common'; | ||
|
||
export const simpleRoutingPanel = hoistCmp.factory({ | ||
displayName: 'SimpleRoutingPanel', | ||
model: creates(() => new SimpleRoutingPanelModel()), | ||
|
||
render({model}) { | ||
const routedUrl = `${window.location.origin}/app/other/simpleRouting/123`; | ||
return wrapper({ | ||
description: [ | ||
<p> | ||
Hoist provides functionality for route parameters to interact with UI | ||
components. The grid below has its selected record synced with a routable URL. | ||
</p>, | ||
<p> | ||
Given a URL such as <a href={routedUrl}>{routedUrl}</a>, where <code>123</code>{' '} | ||
is a record ID, we can auto-select the matching record in the grid. Updates to | ||
application state can be pushed back to the URL - try selecting a different | ||
record in the grid and observe the URL change. | ||
</p>, | ||
<p> | ||
Note that this routing relies on an appropriate route path being defined in the | ||
config returned by <code>AppModel.getRoutes()</code>. | ||
</p> | ||
], | ||
item: panel({ | ||
title: 'Simple Routing', | ||
icon: Icon.gridPanel(), | ||
item: grid(), | ||
height: 500, | ||
width: 700 | ||
}) | ||
}); | ||
} | ||
}); | ||
|
||
@managed | ||
class SimpleRoutingPanelModel extends HoistModel { | ||
private readonly BASE_ROUTE = 'default.other.simpleRouting'; | ||
|
||
@managed gridModel = new GridModel({ | ||
columns: [{field: 'id'}, {field: 'company', flex: 1}] | ||
}); | ||
|
||
constructor() { | ||
super(); | ||
this.addReaction( | ||
{ | ||
// Track lastLoadCompleted to sync route -> grid after initial load. | ||
track: () => [XH.routerState.params, this.lastLoadCompleted], | ||
run: () => this.updateGridFromRoute() | ||
}, | ||
{ | ||
track: () => this.gridModel.selectedId, | ||
run: () => this.updateRouteFromGrid() | ||
} | ||
); | ||
} | ||
|
||
async updateGridFromRoute() { | ||
const {gridModel, BASE_ROUTE} = this, | ||
{name: currRouteName, params} = XH.routerState, | ||
{recordId} = params; | ||
|
||
// No-op if not on the current base route. | ||
if (!currRouteName.startsWith(BASE_ROUTE)) return; | ||
|
||
if (recordId) { | ||
await gridModel.selectAsync(Number(recordId)); | ||
|
||
// Check and alert if requested record not found, and clean up route to match. | ||
if (!gridModel.selectedRecord) { | ||
XH.dangerToast(`Record ${recordId} not found.`); | ||
XH.navigate(BASE_ROUTE, {replace: true}); | ||
} | ||
} else { | ||
gridModel.clearSelection(); | ||
} | ||
} | ||
|
||
updateRouteFromGrid() { | ||
const {gridModel, BASE_ROUTE} = this, | ||
{name: currRouteName, params} = XH.routerState, | ||
{selectedId} = gridModel, | ||
{recordId} = params; | ||
|
||
// No-op if not on the current base route, or if route and selection already match. | ||
if (!currRouteName.startsWith(BASE_ROUTE) || recordId === selectedId) return; | ||
|
||
if (selectedId) { | ||
XH.navigate( | ||
'default.other.simpleRouting.recordId', | ||
{recordId: selectedId}, | ||
{replace: true} // avoids adding steps to browser history | ||
); | ||
} else { | ||
XH.navigate('default.other.simpleRouting', {replace: true}); | ||
} | ||
} | ||
|
||
override async doLoadAsync(loadSpec: LoadSpec) { | ||
const {trades} = await XH.fetchJson({url: 'trade', loadSpec}); | ||
this.gridModel.loadData(trades); | ||
} | ||
} |
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
Oops, something went wrong.