From 1a392db5bf60f23f5560a757fa94044deb6cb049 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Mon, 3 Mar 2025 15:42:29 -0700 Subject: [PATCH] app selec tmultiple --- web/.cursor/rules/components_ui_stories.mdc | 2 +- web/package-lock.json | 1 - web/src/api/buster_rest/config.ts | 1 + web/src/api/buster_rest/instances.ts | 3 +- .../SelectDatasetInput.tsx | 39 ++++++++++--------- .../StatusBadgeButton.stories.tsx | 4 +- .../NewTermModal/NewTermModal.stories.tsx | 5 ++- .../modal/NewTermModal/NewTermModal.tsx | 2 +- .../popups/SaveResetFilePopup.stories.tsx | 9 +++-- .../components/ui/card/CodeCard.stories.tsx | 4 +- .../stories/LegendItem.stories.tsx | 6 +-- .../stories/OverflowButton.stories.tsx | 4 +- .../ui/inputs/InputTextAreaButton.tsx | 2 + web/src/components/ui/layouts/AppLayout.tsx | 3 +- web/src/components/ui/modal/Modal.stories.tsx | 19 ++++----- .../components/ui/select/Select.stories.tsx | 4 ++ web/src/components/ui/select/Select.tsx | 23 +++++++++-- web/src/components/ui/select/SelectBase.tsx | 2 +- .../ui/select/SelectMultiple.stories.tsx | 13 ++++--- .../components/ui/select/SelectMultiple.tsx | 8 ++-- .../AppCodeBlock/AppCodeBlock.stories.tsx | 4 +- .../AppMarkdown/AppMarkdown.stories.tsx | 2 +- .../ui/typography/EditableTitle.stories.tsx | 29 +++++++------- .../Chats/NewChatProvider/NewChatProvider.tsx | 1 - web/src/styles/styles.scss | 2 - 25 files changed, 106 insertions(+), 86 deletions(-) diff --git a/web/.cursor/rules/components_ui_stories.mdc b/web/.cursor/rules/components_ui_stories.mdc index b4c443c6d..3c34545e9 100644 --- a/web/.cursor/rules/components_ui_stories.mdc +++ b/web/.cursor/rules/components_ui_stories.mdc @@ -8,4 +8,4 @@ alwaysApply: false - If a new story is made in the controller directory, I would like it title "Controllers/{controller name or parent controller name}/{componentName}" - If a new story is found in the features directory, I would like it titled "Features/{featureName or parent feature name}/{componentName}" - onClick events (or similar) should be mocked with fn() from the storybook test package -- If I ever need to mock an endpoint you should use msw, All endpoints should be appended with the NEXT_PUBLIC_API_URL from env. For example: http.get(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/datasets`, () => { +- If I ever need to mock an endpoint you should use msw. Use MSW for mocking api calls. All endpoints should be appended with the BASE_URL For example: http.get(`BASE_URL`, () => {}). The BASE_URL is found in [config.ts](mdc:src/api/buster_rest/config.ts) diff --git a/web/package-lock.json b/web/package-lock.json index 7f2c10a3b..a8b3ef08d 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -2467,7 +2467,6 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { diff --git a/web/src/api/buster_rest/config.ts b/web/src/api/buster_rest/config.ts index 559d23c4d..7ceee57b3 100644 --- a/web/src/api/buster_rest/config.ts +++ b/web/src/api/buster_rest/config.ts @@ -1 +1,2 @@ export const NEXT_SB_ACCESS_TOKEN = 'next-sb-access-token'; +export const BASE_URL = `${process.env.NEXT_PUBLIC_API_URL}/api/v1`; diff --git a/web/src/api/buster_rest/instances.ts b/web/src/api/buster_rest/instances.ts index dbbd5abb9..e5277e391 100644 --- a/web/src/api/buster_rest/instances.ts +++ b/web/src/api/buster_rest/instances.ts @@ -1,6 +1,5 @@ import { createInstance } from '../createInstance'; - -export const BASE_URL = `${process.env.NEXT_PUBLIC_API_URL}/api/v1`; +import { BASE_URL } from './config'; const mainApi = createInstance(BASE_URL); export default mainApi; diff --git a/web/src/components/features/PermissionComponents/SelectDatasetInput.tsx b/web/src/components/features/PermissionComponents/SelectDatasetInput.tsx index edc4370c6..d61e9bbe8 100644 --- a/web/src/components/features/PermissionComponents/SelectDatasetInput.tsx +++ b/web/src/components/features/PermissionComponents/SelectDatasetInput.tsx @@ -1,6 +1,7 @@ import { useGetDatasets } from '@/api/buster_rest'; +import { SelectMultiple } from '@/components/ui/select/SelectMultiple'; +import { Select, SelectItem } from '@/components/ui/select/Select'; import { useMemoizedFn } from 'ahooks'; -import { Select } from 'antd'; import React, { useMemo, useState } from 'react'; export const SelectedDatasetInput: React.FC<{ @@ -15,7 +16,12 @@ export const SelectedDatasetInput: React.FC<{ onSetDatasetId(value); }); - const options = useMemo(() => { + const onChangeSinglePreflight = useMemoizedFn((value: string) => { + const newValue = [value]; + onChangePreflight(newValue); + }); + + const options: SelectItem[] = useMemo(() => { return datasets?.map((dataset) => ({ label: dataset.name, value: dataset.id @@ -25,28 +31,23 @@ export const SelectedDatasetInput: React.FC<{ if (mode === 'single') { return (