Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI bug fixes #205

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ install-cython: checkvenv
build: checkvenv down clean-mypyc-artifacts install-cython local-install-deps-dev local-install-deps-prod
export IMAGE_TAG=local && \
docker build --progress=plain -t wycliffeassociates/doc:$${IMAGE_TAG} . && \
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend && \
docker build --progress=plain -t wycliffeassociates/doc-ui-tests:$${IMAGE_TAG} -f ./frontend/testsDockerfile ./frontend

.PHONY: build-no-pip-update
build-no-pip-update: checkvenv down clean-mypyc-artifacts
export IMAGE_TAG=local && \
docker build --progress=plain -t wycliffeassociates/doc:$${IMAGE_TAG} . && \
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend && \
docker build --progress=plain -t wycliffeassociates/doc-ui-tests:$${IMAGE_TAG} -f ./frontend/testsDockerfile ./frontend

.PHONY: build-no-pip-update-run-tests
build-no-pip-update-run-tests: checkvenv down clean-mypyc-artifacts
export IMAGE_TAG=local && \
docker build --build-arg RUN_TESTS=true --progress=plain -t wycliffeassociates/doc:$${IMAGE_TAG} . && \
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend
docker build --progress=plain -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend && \
docker build --progress=plain -t wycliffeassociates/doc-ui-tests:$${IMAGE_TAG} -f ./frontend/testsDockerfile ./frontend

.PHONY: build-no-cache
build-no-cache: checkvenv down clean-mypyc-artifacts local-install-deps-prod
export IMAGE_TAG=local && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc:$${IMAGE_TAG} . && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui-tests:$${IMAGE_TAG} -f ./frontend/testsDockerfile ./frontend

.PHONY: build-no-cache-no-pip-update
build-no-cache-no-pip-update: checkvenv down clean-mypyc-artifacts
export IMAGE_TAG=local && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc:$${IMAGE_TAG} . && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui:$${IMAGE_TAG} ./frontend && \
docker build --progress=plain --no-cache --pull -t wycliffeassociates/doc-ui-tests:$${IMAGE_TAG} -f ./frontend/testsDockerfile ./frontend

.PHONY: up
Expand Down Expand Up @@ -225,18 +225,18 @@ local-gunicorn-server: checkvenv

.PHONY: local-update-deps-base
local-update-deps-base: pyupgrade
# pip-compile --resolver=backtracking -v ./backend/requirements.in
pip-compile --upgrade ./backend/requirements.in
pip-compile --resolver=backtracking -v ./backend/requirements.in
# pip-compile --upgrade ./backend/requirements.in

.PHONY: local-update-deps-prod
local-update-deps-prod: local-update-deps-base
# pip-compile --resolver=backtracking -v ./backend/requirements-prod.in
pip-compile --upgrade ./backend/requirements-prod.in
pip-compile --resolver=backtracking -v ./backend/requirements-prod.in
# pip-compile --upgrade ./backend/requirements-prod.in

.PHONY: local-update-deps-dev
local-update-deps-dev: local-update-deps-base
# pip-compile --resolver=backtracking -v ./backend/requirements-dev.in
pip-compile --upgrade ./backend/requirements-dev.in
pip-compile --resolver=backtracking -v ./backend/requirements-dev.in
# pip-compile --upgrade ./backend/requirements-dev.in

.PHONY: local-install-deps-base
local-install-deps-base: install-cython local-update-deps-base
Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setuptools
termcolor
toolz
trio
usfm_tools @ https://github.com/linearcombination/USFM-Tools/archive/refs/tags/0.0.9.zip
usfm_tools @ https://github.com/linearcombination/USFM-Tools/archive/refs/tags/0.1.3.zip
uvicorn
weasyprint

Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ urllib3==2.2.1
# botocore
# requests
# types-requests
usfm-tools @ https://github.com/linearcombination/USFM-Tools/archive/refs/tags/0.0.9.zip
usfm-tools @ https://github.com/linearcombination/USFM-Tools/archive/refs/tags/0.1.3.zip
# via -r ./backend/requirements.in
uvicorn[standard]==0.28.0
# via
Expand Down
24 changes: 4 additions & 20 deletions frontend/src/lib/WizardBreadcrumb.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { resourceTypesStore, resourceTypesCountStore } from '$lib/stores/ResourceTypesStore'
import {
getResourceTypeLangCode,
// resetStores,
resetStores,
langRegExp,
bookRegExp,
resourceTypeRegExp,
Expand All @@ -17,33 +17,17 @@
import DesktopBreadcrumb from '$lib/DesktopBreadcrumb.svelte'

function submitLanguages() {
// If books store or resource types store are not empty, then we
// should reset them when we change the languages.
if ($bookCountStore > 0 || $resourceTypesCountStore > 0) {
$resetValuesStore = true
}
// resetStores('books')
// resetStores('resource_types')
// resetStores('settings')
// resetStores('notifications')
resetStores('notifications')
goto('/books')
}

function submitBooks() {
// If resource types store is not empty, then we
// should reset it when we change books.
if ($resourceTypesCountStore > 0) {
$resetValuesStore = true
}
// resetStores('resource_types')
// resetStores('settings')
// resetStores('notifications')
resetStores('notifications')
goto('/resource_types')
}

function submitResourceTypes() {
// resetStores('settings')
// resetStores('notifications')
resetStores('notifications')
goto('/settings')
}

Expand Down
13 changes: 6 additions & 7 deletions frontend/src/lib/stores/ResourceTypesStore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import { writable } from 'svelte/store'
import type { Writable } from 'svelte/store'

export let resourceTypesStore: Writable<Array<string>> = writable<Array<string>>([]);
export let lang0ResourceTypesStore: Writable<Array<string>> = writable<Array<string>>([]);
export let lang1ResourceTypesStore: Writable<Array<string>> = writable<Array<string>>([]);
export let resourceTypesCountStore: Writable<number> = writable<number>(0);
export let twResourceRequestedStore: Writable<boolean> = writable<boolean>(false);
export let resourceTypesStore: Writable<Array<string>> = writable<Array<string>>([])
export let lang0ResourceTypesStore: Writable<Array<string>> = writable<Array<string>>([])
export let lang1ResourceTypesStore: Writable<Array<string>> = writable<Array<string>>([])
export let resourceTypesCountStore: Writable<number> = writable<number>(0)
2 changes: 2 additions & 0 deletions frontend/src/lib/stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ export let generateDocxStore: Writable<boolean> = writable<boolean>(false)
export let emailStore: Writable<string | null> = writable<string | null>(null)
export let documentRequestKeyStore: Writable<string> = writable<string>('')
export let settingsUpdated: Writable<boolean> = writable<boolean>(false)
export let twResourceRequestedStore: Writable<boolean> = writable<boolean>(false)
export let usfmResourceRequestedStore: Writable<boolean> = writable<boolean>(false)
23 changes: 3 additions & 20 deletions frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
// TODO should we include resourceTypesStore and reset it also?
lang0ResourceTypesStore,
lang1ResourceTypesStore,
resourceTypesCountStore,
twResourceRequestedStore
resourceTypesCountStore
} from '$lib/stores/ResourceTypesStore'
import { documentReadyStore, errorStore } from '$lib/stores/NotificationStore'
import {
Expand All @@ -26,7 +25,8 @@ import {
generatePdfStore,
generateEpubStore,
generateDocxStore,
documentRequestKeyStore
documentRequestKeyStore,
twResourceRequestedStore
} from '$lib/stores/SettingsStore'

const languageBookOrder: string = <string>PUBLIC_LANGUAGE_BOOK_ORDER
Expand Down Expand Up @@ -77,23 +77,6 @@ export function resetStores(storeGroup: StoreGroup) {
}
}

// FIXME: These are too inconsequential to be here, just use them from $env/dynamic/private where needed
// export function getApiRootUrl(): string {
// return <string>PUBLIC_BACKEND_API_URL
// }

// export function getFileServerUrl(): string {
// return <string>env.PUBLIC_FILE_SERVER_URL
// }

// export function getLogRocketId(): string {
// return <string>env.PUBLIC_LOGROCKET_ID
// }

/**
* Indicate whether to show Mast, Tabs, and Sidebar
**/

export function getName(codeAndName: string): string {
return codeAndName?.split(/, (.*)/s)[1]
}
Expand Down
89 changes: 58 additions & 31 deletions frontend/src/routes/books/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,67 @@
if ($langCountStore > 1) {
getSharedBookCodesAndNames($langCodesStore[0], $langCodesStore[1])
.then((bookCodesAndNames) => {
// Filter set of all resource codes into old testament
// book codes.
otBookCodes = bookCodesAndNames
.filter((element: [string, string]) => {
return otBooks.some((item) => item === element[0])
})
.map((tuple) => `${tuple[0]}, ${tuple[1]}`)
if (bookCodesAndNames) {
// Filter set of all resource codes into old testament
// book codes.
otBookCodes = bookCodesAndNames
.filter((element: [string, string]) => {
return otBooks.some((item) => item === element[0])
})
.map((tuple) => `${tuple[0]}, ${tuple[1]}`)

// If otBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any otBookStore elements that are not in otBookCodes.
if ($otBookStore.length > 0) {
$otBookStore = $otBookStore.filter((item) => {
return otBookCodes.some((element) => element === item)
})
}
// If otBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any otBookStore elements that are not in otBookCodes.
if ($otBookStore.length > 0) {
$otBookStore = $otBookStore.filter((item) => {
return otBookCodes.some((element) => element === item)
})
}

// Filter set of all book codes into new testament
// book codes.
ntBookCodes = bookCodesAndNames
.filter((element: [string, string]) => {
return !otBooks.some((item) => item === element[0])
})
.map((tuple) => `${tuple[0]}, ${tuple[1]}`)
// Filter set of all book codes into new testament
// book codes.
ntBookCodes = bookCodesAndNames
.filter((element: [string, string]) => {
return !otBooks.some((item) => item === element[0])
})
.map((tuple) => `${tuple[0]}, ${tuple[1]}`)

// If ntBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any ntBookStore elements that are not in ntBookCodes.
if ($ntBookStore.length > 0) {
$ntBookStore = $ntBookStore.filter((item) => {
return ntBookCodes.some((element) => element === item)
})
// If ntBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any ntBookStore elements that are not in ntBookCodes.
if ($ntBookStore.length > 0) {
$ntBookStore = $ntBookStore.filter((item) => {
return ntBookCodes.some((element) => element === item)
})
}
} else {
// Filter set of all resource codes into old testament
// book codes.
otBookCodes = []
// If otBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any otBookStore elements that are not in otBookCodes.
if ($otBookStore.length > 0) {
$otBookStore = $otBookStore.filter((item) => {
return otBookCodes.some((element) => element === item)
})
}
// Filter set of all book codes into new testament
// book codes.
ntBookCodes = []
// If ntBookStore has contents, then assume we are coming
// back here from the user clicking to edit their book
// selections in the wizard basket, so we want to eliminate
// any ntBookStore elements that are not in ntBookCodes.
if ($ntBookStore.length > 0) {
$ntBookStore = $ntBookStore.filter((item) => {
return ntBookCodes.some((element) => element === item)
})
}
}
})
.catch((err) => console.error(err))
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/routes/languages/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@
.then((langCodeNameAndTypes_) => {
// Save result for later use
langCodeNameAndTypes = langCodeNameAndTypes_

gatewayCodesAndNames = langCodeNameAndTypes_
.filter((element: [string, string, boolean]) => {
return element[2]
})
.map((tuple) => `${tuple[0]}, ${tuple[1]}`)

heartCodesAndNames = langCodeNameAndTypes_
.filter((element: [string, string, boolean]) => {
return !element[2]
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/resource_types/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
): Promise<Array<[string, string, string]>> {
// Form the URL to ultimately invoke
// resource_lookup.shared_resource_types.
const url_ = `${apiRootUrl}${sharedResourceTypesUrl}${langCode}/`
const url_ = `${apiRootUrl}${sharedResourceTypesUrl}${langCode}`
const url = new URL(url_)
bookCodeAndNames.map((bookCodeAndName) =>
url.searchParams.append('book_codes', bookCodeAndName[0])
Expand Down Expand Up @@ -209,7 +209,7 @@
</ul>
</div>
{/if}
{#if $langCountStore > 1 && lang1ResourceTypesAndNames}
{#if $langCountStore > 1}
<div>
<h3 class="text-2xl text-[#33445C]">{$langNamesStore[1]}</h3>
</div>
Expand Down
Loading
Loading