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

added checkBox in place of Button #91

Merged
merged 3 commits into from
Sep 25, 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
4 changes: 2 additions & 2 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Check front code
run: yarn --cwd db-viewer-ui lint

- name: Build docker-compose environment
- name: Build docker compose environment
run: docker compose up -d --wait

- name: Run db-viewer api
Expand All @@ -69,7 +69,7 @@ jobs:

- name: Stop docker containers
if: always()
run: docker rm -f db-viewer-api && docker-compose down
run: docker rm -f db-viewer-api && docker compose down

- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
36 changes: 19 additions & 17 deletions db-viewer-ui/src/Components/FieldSelector/FieldSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FieldSelectorProps {
showSelectAllButton?: boolean;
}

function filterFieldDefintionsByText(fieldDefinitions: FieldDefinition[], text: string): FieldDefinition[] {
function filterFieldDefinitionsByText(fieldDefinitions: FieldDefinition[], text: string): FieldDefinition[] {
if (!text) {
return fieldDefinitions;
}
Expand Down Expand Up @@ -80,27 +80,29 @@ export function FieldSelector({
);
};

const fieldDefinitionsFiltered = filterFieldDefintionsByText(fieldDefinitions, searchText);
const fieldDefinitionsFiltered = filterFieldDefinitionsByText(fieldDefinitions, searchText);

const nothingToDisplay = <span className={jsStyles.nothingToDisplay(theme)}>Ничего не найдено</span>;
const allFieldsSelected = isAllFieldSelected(fieldDefinitionsFiltered);
return (
<div className={jsStyles.root()}>
<Input
data-tid="FilterInput"
leftIcon={<SearchLoupeIcon16Regular />}
value={searchText}
width={300}
onValueChange={setSearchText}
/>
{showSelectAllButton && (
<div
data-tid={"TypesSelectAll"}
onClick={() => handleSelectAll(fieldDefinitionsFiltered)}
className={jsStyles.selectAll(theme)}>
{allFieldsSelected ? "Снять выбор с найденных" : "Выбрать все найденные"}
</div>
)}
<RowStack gap={5} verticalAlign="baseline">
<Input
data-tid="FilterInput"
leftIcon={<SearchLoupeIcon16Regular />}
value={searchText}
width={300}
onValueChange={setSearchText}
/>
{showSelectAllButton && (
<Checkbox
data-tid="TypesSelectAll"
onValueChange={() => handleSelectAll(fieldDefinitionsFiltered)}
checked={allFieldsSelected}>
Все найденные
</Checkbox>
)}
</RowStack>
<RowStack data-tid="ColumnCheckboxes" className={jsStyles.fieldList()} block gap={4}>
{fieldDefinitionsFiltered.length === 0 ? <Fit>{nothingToDisplay}</Fit> : null}

Expand Down
13 changes: 13 additions & 0 deletions db-viewer-ui/stories/Commons/FieldSelector.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ export const Default = (): React.ReactElement => (
/>
);

export const WithSelectAll = (): React.ReactElement => (
<FieldSelector
hiddenFields={[]}
fieldDefinitions={[
{ name: "name1", caption: "Name 1" },
{ name: "name2", caption: "Name 2" },
]}
onShowField={action("onShowField")}
onHideField={action("onHideField")}
showSelectAllButton
/>
);

export const LongStrings = (): React.ReactElement => (
<FieldSelector
hiddenFields={[]}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8",
"version": "1.8-prerelease.4",
"assemblyVersion": {
"precision": "build"
},
Expand Down
Loading