-
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.
Merge branch 'main' of github.com:paranext/paranext-core into rtl-nav…
…igation-content-search
- Loading branch information
Showing
94 changed files
with
6,272 additions
and
4,087 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
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
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
7 changes: 7 additions & 0 deletions
7
extensions/src/platform-scripture/src/checking-results-list.web-view.scss
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,7 @@ | ||
.checking-results-list { | ||
height: 500px; | ||
} | ||
|
||
.checking-results-list-label { | ||
padding-inline-start: 10px; | ||
} |
68 changes: 68 additions & 0 deletions
68
extensions/src/platform-scripture/src/checking-results-list.web-view.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,68 @@ | ||
import { WebViewProps } from '@papi/core'; | ||
import { Button, Label, ResultsSet, ScriptureResultsViewer } from 'platform-bible-react'; | ||
import { useState, useCallback, useEffect, useMemo } from 'react'; | ||
import { badLeftoversCheck, engineProblemsCheck } from './testing/test-scripture-checks'; | ||
|
||
const getLabel = ( | ||
projectName: string | undefined, | ||
datetime: string | undefined, | ||
sources: ResultsSet[], | ||
): string => { | ||
let result = ''; | ||
if (projectName) { | ||
result = projectName; | ||
} | ||
if (datetime) result += `; ${datetime}`; | ||
if (sources.length > 0) { | ||
result += '; '; | ||
result += sources | ||
.map((s) => s.source.displayName) | ||
.filter(Boolean) | ||
.join(', '); | ||
} | ||
return result; | ||
}; | ||
|
||
global.webViewComponent = function CheckingResultsListWebView({ useWebViewState }: WebViewProps) { | ||
const [projectName] = useWebViewState('projectName', 'Dummy project'); | ||
|
||
// This is stub code to get some dummy checking results. | ||
// TODO (#994): Replace this with calls to get actual check results and subscribe to updates. | ||
const onRerun = useCallback(() => { | ||
badLeftoversCheck.reRun(); | ||
engineProblemsCheck.reRun(); | ||
}, []); | ||
|
||
const sources = useMemo(() => [badLeftoversCheck, engineProblemsCheck], []); | ||
|
||
const [lastUpdateTimestamp, setLastUpdateTimestamp] = useState<string | undefined>(undefined); | ||
const [currentSources, setCurrentSources] = useState(sources); | ||
|
||
useEffect(() => { | ||
setCurrentSources(sources); | ||
}, [sources]); | ||
|
||
const handleResultsUpdated = useCallback(() => { | ||
const currentTimestamp = new Date().toLocaleString(); | ||
setLastUpdateTimestamp(currentTimestamp); | ||
}, []); | ||
|
||
const reRunChecks = useCallback(() => { | ||
if (onRerun) { | ||
onRerun(); | ||
// Since onRerun modifies the sources directly, we need to trigger a state update | ||
setCurrentSources([...sources]); | ||
handleResultsUpdated(); | ||
} | ||
}, [onRerun, sources, handleResultsUpdated]); | ||
|
||
const label = getLabel(projectName, lastUpdateTimestamp, sources); | ||
|
||
return ( | ||
<div className="checking-results-list"> | ||
<Button onClick={reRunChecks}>Rerun</Button> | ||
{label && <Label className="checking-results-list-label">{label}</Label>} | ||
<ScriptureResultsViewer sources={currentSources} /> | ||
</div> | ||
); | ||
}; |
77 changes: 77 additions & 0 deletions
77
extensions/src/platform-scripture/src/checking-results.web-view-provider.ts
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,77 @@ | ||
import papi, { logger, projectLookup } from '@papi/backend'; | ||
import { | ||
GetWebViewOptions, | ||
IWebViewProvider, | ||
SavedWebViewDefinition, | ||
WebViewDefinition, | ||
} from '@papi/core'; | ||
import checkingResultsListWebView from './checking-results-list.web-view?inline'; | ||
import checkingResultsListStyles from './checking-results-list.web-view.scss?inline'; | ||
|
||
export const checkResultsListWebViewType = 'platformScripture.checkingResults'; | ||
|
||
export interface CheckResultsWebViewOptions extends GetWebViewOptions { | ||
projectId: string | undefined; | ||
} | ||
|
||
export default class CheckResultsWebViewProvider implements IWebViewProvider { | ||
constructor(public webViewType: string = checkResultsListWebViewType) {} | ||
|
||
async getWebView( | ||
savedWebView: SavedWebViewDefinition, | ||
getWebViewOptions: CheckResultsWebViewOptions, | ||
): Promise<WebViewDefinition | undefined> { | ||
if (savedWebView.webViewType !== this.webViewType) | ||
throw new Error( | ||
`${checkResultsListWebViewType} provider received request to provide a ${savedWebView.webViewType} web view`, | ||
); | ||
|
||
// We know that the projectId (if present in the state) will be a string. | ||
let projectId = | ||
getWebViewOptions.projectId || | ||
// eslint-disable-next-line no-type-assertion/no-type-assertion | ||
(savedWebView.state?.projectId as string) || | ||
undefined; | ||
|
||
let title = await papi.localization.getLocalizedString({ | ||
localizeKey: '%webView_checkResultsList_title%', | ||
}); | ||
|
||
let projectName: string | undefined; | ||
|
||
if (projectId) { | ||
projectName = | ||
(await ( | ||
await papi.projectDataProviders.get('platform.base', projectId) | ||
).getSetting('platform.name')) ?? projectId; | ||
|
||
title += ` - ${projectName}`; | ||
} | ||
|
||
if (!projectId && globalThis.isNoisyDevModeEnabled) { | ||
logger.debug(`${title} web view did not get a project passed in. Choosing a random one...`); | ||
|
||
const projectMetadata = await projectLookup.getMetadataForAllProjects(); | ||
if (projectMetadata.length === 0) { | ||
logger.debug('Testing out checks: No projects available'); | ||
return undefined; | ||
} | ||
projectId = projectMetadata[0].id; | ||
} | ||
|
||
logger.info(`${title} web view opening with ${projectId}`); | ||
|
||
return { | ||
title, | ||
...savedWebView, | ||
content: checkingResultsListWebView, | ||
styles: checkingResultsListStyles, | ||
state: { | ||
projectName, | ||
projectId, | ||
...savedWebView.state, | ||
webViewType: this.webViewType, | ||
}, | ||
}; | ||
} | ||
} |
Oops, something went wrong.