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

Update Get Resources web-view UI to Phase 1 UX design #1399

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
"localizedStrings": {
"en": {
"%resources_action%": "Action",
"%resources_any%": "Any",
"%resources_dialog_subtitle%": "Add resources to Home",
"%resources_dialog_title%": "Get Resources",
"%resources_filterBy%": "Filter by",
"%resources_filterInput%": "Search by name, language, type",
"%resources_fullName%": "Full Name",
"%resources_get%": "Get",
"%resources_installed%": "Installed",
"%resources_language%": "Language",
"%resources_languageFilter%": "Filter by language",
"%resources_languages%": "Languages",
"%resources_loadingResources%": "Loading resources...",
"%resources_noResults%": "No results found",
"%resources_open%": "Open",
"%resources_remove%": "Remove",
"%resources_results%": "results",
"%resources_showing%": "Showing",
"%resources_size%": "Size",
"%resources_type%": "Type",
"%resources_types%": "Types",
"%resources_type_DBL%": "DBL Resource",
"%resources_type_ER%": "Enhanced Resource",
"%resources_type_SLR%": "Source Language Text",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WebViewProps } from '@papi/core';
import papi from '@papi/frontend';
import { useData, useDataProvider, useLocalizedStrings } from '@papi/frontend/react';
import type { ResourceType } from 'platform-bible-utils';
import { FilterableResourceList, FILTERABLE_RESOURCE_LIST_STRING_KEYS } from 'platform-bible-react';

globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: WebViewProps) {
Expand All @@ -13,24 +12,24 @@ globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: W
'platformGetResources.dblResourcesProvider',
).DblResources(undefined, []);

const [typeFilter, setTypeFilter] = useWebViewState<ResourceType[]>('typeFilter', [
const [selectedTypes, setSelectedTypes] = useWebViewState<string[]>('typeFilter', [
'DBLResource',
]);

const [languageFilter, setLanguageFilter] = useWebViewState<string[]>('languageFilter', []);
const [selectedLanguages, setSelectedLanguages] = useWebViewState<string[]>('languageFilter', []);

const openResource = (projectId: string) =>
papi.commands.sendCommand('platformScriptureEditor.openResourceViewer', projectId);

return (
<FilterableResourceList
localizedStrings={localizedStrings}
dblResources={dblResources}
isLoadingDblResources={isLoadingDblResources}
typeFilter={typeFilter}
setTypeFilter={setTypeFilter}
languageFilter={languageFilter}
setLanguageFilter={setLanguageFilter}
resources={dblResources}
isLoadingResources={isLoadingDblResources}
selectedTypes={selectedTypes}
setSelectedTypes={setSelectedTypes}
selectedLanguages={selectedLanguages}
setSelectedLanguages={setSelectedLanguages}
openResource={openResource}
installResource={dblResourcesProvider?.installDblResource}
uninstallResource={dblResourcesProvider?.uninstallDblResource}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
"localizedStrings": {
"en": {
"%resources_action%": "Action",
"%resources_any%": "Any",
"%resources_dialog_subtitle%": "",
"%resources_dialog_title%": "Home",
"%resources_filterBy%": "Filter by",
"%resources_filterInput%": "Search by name, language, type",
"%resources_fullName%": "Full Name",
"%resources_get%": "Get",
"%resources_installed%": "Installed",
"%resources_language%": "Language",
"%resources_languageFilter%": "Filter by language",
"%resources_languages%": "Languages",
"%resources_loadingResources%": "Loading Projects and Resource",
"%resources_noResults%": "No results found",
"%resources_open%": "Open",
"%resources_remove%": "Remove",
"%resources_results%": "results",
"%resources_showing%": "Showing",
"%resources_size%": "Size",
"%resources_type%": "Type",
"%resources_types%": "Types",
"%resources_type_DBL%": "DBL Resource",
"%resources_type_ER%": "Enhanced Resource",
"%resources_type_SLR%": "Source Language Text",
Expand Down
17 changes: 8 additions & 9 deletions extensions/src/platform-home/src/home.web-view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WebViewProps } from '@papi/core';
import papi from '@papi/frontend';
import { useData, useDataProvider, useLocalizedStrings } from '@papi/frontend/react';
import type { ResourceType } from 'platform-bible-utils';
import { FilterableResourceList, FILTERABLE_RESOURCE_LIST_STRING_KEYS } from 'platform-bible-react';

globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: WebViewProps) {
Expand All @@ -13,24 +12,24 @@ globalThis.webViewComponent = function GetResourcesDialog({ useWebViewState }: W
'platformGetResources.dblResourcesProvider',
).DblResources(undefined, []);

const [typeFilter, setTypeFilter] = useWebViewState<ResourceType[]>('typeFilter', [
const [selectedTypes, setSelectedTypes] = useWebViewState<string[]>('typeFilter', [
'DBLResource',
]);

const [languageFilter, setLanguageFilter] = useWebViewState<string[]>('languageFilter', []);
const [selectedLanguages, setSelectedLanguages] = useWebViewState<string[]>('languageFilter', []);

const openResource = (projectId: string) =>
papi.commands.sendCommand('platformScriptureEditor.openResourceViewer', projectId);

return (
<FilterableResourceList
localizedStrings={localizedStrings}
dblResources={dblResources}
isLoadingDblResources={isLoadingDblResources}
typeFilter={typeFilter}
setTypeFilter={setTypeFilter}
languageFilter={languageFilter}
setLanguageFilter={setLanguageFilter}
resources={dblResources}
isLoadingResources={isLoadingDblResources}
selectedTypes={selectedTypes}
setSelectedTypes={setSelectedTypes}
selectedLanguages={selectedLanguages}
setSelectedLanguages={setSelectedLanguages}
openResource={openResource}
installResource={dblResourcesProvider?.installDblResource}
uninstallResource={dblResourcesProvider?.uninstallDblResource}
Expand Down
210 changes: 84 additions & 126 deletions lib/platform-bible-react/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.cjs.map

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions lib/platform-bible-react/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ export interface MultiSelectComboBoxProps {
customSelectedText?: string;
sortSelected?: boolean;
icon?: React$1.ReactNode;
className?: string;
}
export declare function MultiSelectComboBox({ entries, getEntriesCount, selected, onChange, placeholder, commandEmptyMessage, customSelectedText, sortSelected, icon, }: MultiSelectComboBoxProps): import("react/jsx-runtime").JSX.Element;
export declare function MultiSelectComboBox({ entries, getEntriesCount, selected, onChange, placeholder, commandEmptyMessage, customSelectedText, sortSelected, icon, className, }: MultiSelectComboBoxProps): import("react/jsx-runtime").JSX.Element;
export type TabKeyValueContent = {
key: string;
value: string;
Expand Down Expand Up @@ -1420,20 +1421,25 @@ export interface FooterProps {
* @returns The rendered Footer component
*/
export function Footer({ id, publisherDisplayName, fileSize, locales, versionHistory, }: FooterProps): import("react/jsx-runtime").JSX.Element;
export interface FilterProps extends MultiSelectComboBoxProps {
badgesPlaceholder: string;
}
export declare function Filter({ entries, getEntriesCount, selected, onChange, placeholder, commandEmptyMessage, customSelectedText, sortSelected, icon, className, badgesPlaceholder, }: FilterProps): import("react/jsx-runtime").JSX.Element;
export declare const FILTERABLE_RESOURCE_LIST_STRING_KEYS: LocalizeKey[];
export type FilterableResourceListProps = {
localizedStrings: LanguageStrings;
dblResources: DblResourceData[];
isLoadingDblResources: boolean;
typeFilter: ResourceType[];
setTypeFilter: (stateValue: ResourceType[]) => void;
languageFilter: string[];
setLanguageFilter: (stateValue: string[]) => void;
resources: DblResourceData[];
isLoadingResources: boolean;
selectedTypes: string[];
setSelectedTypes: (stateValue: string[]) => void;
selectedLanguages: string[];
setSelectedLanguages: (stateValue: string[]) => void;
openResource: (projectId: string) => void;
installResource: ((uid: string) => Promise<void>) | undefined;
uninstallResource: ((uid: string) => Promise<void>) | undefined;
className?: string;
};
export declare function FilterableResourceList({ localizedStrings, dblResources, isLoadingDblResources, typeFilter, setTypeFilter, languageFilter, setLanguageFilter, openResource, installResource, uninstallResource, }: FilterableResourceListProps): import("react/jsx-runtime").JSX.Element;
export declare function FilterableResourceList({ localizedStrings, resources, isLoadingResources, selectedTypes, setSelectedTypes, selectedLanguages, setSelectedLanguages, openResource, installResource, uninstallResource, className, }: FilterableResourceListProps): import("react/jsx-runtime").JSX.Element;
declare const UI_LANGUAGE_SELECTOR_STRING_KEYS: readonly [
"%settings_uiLanguageSelector_selectFallbackLanguages%"
];
Expand Down
Loading
Loading