From 58551de6205f3696ecd15bd01b3d4914502967c4 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Fri, 31 Jan 2025 11:04:49 -0700 Subject: [PATCH] start moving api interfaces to folder --- .../chat}/chatInterfaces.ts | 0 .../chat}/chatMessageInterfaces.ts | 0 .../chat}/chatProgressInterfaces.ts | 0 .../chats => asset_interfaces/chat}/config.ts | 0 web/src/api/asset_interfaces/chat/index.ts | 4 + .../collection}/index.ts | 0 .../collection/interfaces.ts} | 8 +- .../dashboard}/dashboardConfigInterfaces.ts | 2 +- .../api/asset_interfaces/dashboard/index.ts | 2 + .../dashboard}/interfaces.ts | 23 ++- web/src/api/asset_interfaces/index.ts | 7 +- .../api/asset_interfaces/metric/defaults.ts | 137 ++++++++++++++++++ web/src/api/asset_interfaces/metric/index.ts | 1 + .../api/asset_interfaces/metric/interfaces.ts | 25 ++-- .../metric/requireInterfaces.ts | 12 ++ .../search/index.ts | 4 +- web/src/api/asset_interfaces/share/index.ts | 2 + .../share/shareInterfaces.ts | 6 + .../share/verificationInterfaces.ts | 8 + web/src/api/buster_rest/index.ts | 2 - web/src/api/buster_rest/threads/interfaces.ts | 12 +- web/src/api/buster_rest/users/interfaces.ts | 11 +- .../chatAssetCollectionInterfaces.ts | 6 - .../chatAssetDashboardInterfaces.ts | 17 --- .../chatAssetDatasetInterfaces.ts | 6 - .../chatAssetTermInterfaces.ts | 6 - .../chatAssetValueInterfaces.ts | 6 - .../chats/chatAssetInterfaces/index.ts | 23 --- .../api/buster_socket/chats/chatRequests.ts | 1 - .../api/buster_socket/chats/chatResponses.ts | 2 +- web/src/api/buster_socket/chats/index.ts | 5 - .../collections/collectionRequests.ts | 4 +- .../collections/collectionResponses.ts | 2 +- .../dashboards/dashboardRequests.ts | 8 +- .../dashboards/dashboardResponses.ts | 4 +- web/src/api/buster_socket/dashboards/index.ts | 1 - .../buster_socket/search/searchRequests.ts | 2 +- .../buster_socket/search/searchResponses.ts | 2 +- web/src/api/buster_socket/share/index.ts | 1 - .../buster_socket/threads/threadsRequests.ts | 6 +- .../buster_socket/threads/threadsResponses.ts | 2 +- .../api/buster_socket/user/teamRequests.ts | 2 +- .../api/buster_socket/user/teamResponses.ts | 2 +- .../api/buster_socket/user/userRequests.ts | 8 +- web/src/app/_helpers/listHelpers.tsx | 22 +-- web/src/app/app/_components/AddTypeModal.tsx | 16 +- .../Dropdowns/SaveToCollectionsDropdown.tsx | 2 +- .../Dropdowns/SaveToDashboardDropdown.tsx | 2 +- .../app/_components/Lists/FavoriteStar.tsx | 6 +- .../Lists/StatusBadgeIndicator.tsx | 76 +++++----- .../NewThreadModal/NewThreadModal.tsx | 2 +- .../SuggestedPromptsContainer.tsx | 6 +- .../app/_components/ShareMenu/ShareMenu.tsx | 7 +- .../ShareMenu/ShareMenuContent.tsx | 13 +- .../ShareMenu/ShareMenuContentBody.tsx | 8 +- .../ShareMenu/ShareMenuContentEmbed.tsx | 12 +- .../ShareMenu/ShareMenuContentPublish.tsx | 14 +- .../_components/ShareMenu/ShareMenuTopBar.tsx | 8 +- .../ShareMenu/ShareWithTeamAndGroup.tsx | 9 +- .../_components/ShareMenu_old/ShareMenu.tsx | 18 ++- .../ShareMenu_old/ShareMenuContentEmbed.tsx | 12 +- .../ShareMenu_old/ShareMenuContentPublish.tsx | 14 +- .../ShareMenu_old/ShareMenuTopBar.tsx | 8 +- .../app/app/_controllers/AppNoPageAccess.tsx | 4 +- .../app/_controllers/AppPasswordAccess.tsx | 4 +- .../AppSidebar/FavoritesDropdown.tsx | 5 +- .../SaveToDashboardButton.tsx | 4 +- .../ThreadControllerHeaderPrimary.tsx | 6 +- .../app/app/_layouts/AppAssetCheckLayout.tsx | 6 +- .../ChatResponseMessageHidden.tsx | 2 +- .../ChatResponseMessageSelector.tsx | 2 +- .../ChatResponseMessage_File.tsx | 2 +- .../ChatResponseMessage_Text.tsx | 2 +- .../ChatResponseMessage_Thought.tsx | 2 +- .../ChatResponseMessage_ThoughtPills.tsx | 2 +- .../ChatResponseMessages.tsx | 2 +- .../ChatContent/ChatUserMessage.tsx | 2 +- .../ChatHeader/ChatHeaderOptions/config.tsx | 2 +- .../ChatLayout/ChatContext/useChatAsset.ts | 2 +- .../ChatLayout/ChatLayoutContext/helpers.ts | 2 +- .../useChatFileLayout/useChatFileLayout.ts | 2 +- .../FileContainerHeader.tsx | 2 +- .../app/app/_layouts/ChatLayout/interfaces.ts | 2 +- .../[collectionId]/_CollectionContent.tsx | 6 +- .../_CollectionIndividualHeader.tsx | 7 +- .../_CollectionsIndividualPopup.tsx | 2 - .../collections/_CollectionsListContent.tsx | 2 +- .../DashboardInvidualHeaderPrimary.tsx | 8 +- .../_DashboardIndividualContent.tsx | 2 +- .../_DashboardIndividualDashboard.tsx | 9 +- .../_DashboardIndividualHeader.tsx | 2 +- .../_DashboardInvididualContext.tsx | 2 +- .../_DashboardMetricItem/MetricTitle.tsx | 2 +- .../app/dashboards/[dashboardId]/_helpers.ts | 12 +- .../_ThreadItemsContainer.tsx | 12 +- .../_ThreadItemsSelectedPopup.tsx | 4 +- .../_ThreadListContainer.tsx | 6 +- .../_ThreadSidebarHeader.tsx | 27 ++-- .../interfaces/columnLabelInterfaces.ts | 2 +- web/src/context/BusterWebSocket/helpers.ts | 8 +- .../BusterWebSocket/useBusterWebSocket.tsx | 2 +- .../BusterWebSocket/useWebSocketCustom.tsx | 2 +- web/src/context/Chats/ChatProvider.tsx | 3 +- web/src/context/Chats/MOCK_CHAT.ts | 2 +- web/src/context/Chats/helpers/chatUpgrader.ts | 2 +- web/src/context/Chats/interfaces.ts | 2 +- .../Collections/CollectionsProvider.tsx | 2 +- web/src/context/Collections/helper.ts | 2 +- web/src/context/Dashboards/config.ts | 5 +- .../Dashboards/dashboardContextHelper.ts | 2 +- .../Dashboards/useDashboardIndividual.ts | 8 +- .../context/Dashboards/useDashboardLists.ts | 4 +- .../context/Dashboards/useDashboardMetrics.ts | 2 +- .../Metrics/BusterMetricsListProvider.tsx | 11 +- .../context/Metrics/BusterMetricsProvider.tsx | 5 +- web/src/context/Metrics/config.ts | 5 +- web/src/context/Search/SearchProvider.tsx | 2 +- .../Threads/BusterThreadsListProvider.tsx | 11 +- .../context/Threads/BusterThreadsProvider.tsx | 7 +- web/src/context/Threads/config.ts | 5 +- web/src/context/Users/useFavoriteProvider.tsx | 9 +- 121 files changed, 485 insertions(+), 415 deletions(-) rename web/src/api/{buster_socket/chats => asset_interfaces/chat}/chatInterfaces.ts (100%) rename web/src/api/{buster_socket/chats => asset_interfaces/chat}/chatMessageInterfaces.ts (100%) rename web/src/api/{buster_socket/chats => asset_interfaces/chat}/chatProgressInterfaces.ts (100%) rename web/src/api/{buster_socket/chats => asset_interfaces/chat}/config.ts (100%) create mode 100644 web/src/api/asset_interfaces/chat/index.ts rename web/src/api/{buster_rest/dashboards => asset_interfaces/collection}/index.ts (100%) rename web/src/api/{buster_rest/collection/index.ts => asset_interfaces/collection/interfaces.ts} (82%) rename web/src/api/{buster_socket/dashboards => asset_interfaces/dashboard}/dashboardConfigInterfaces.ts (62%) create mode 100644 web/src/api/asset_interfaces/dashboard/index.ts rename web/src/api/{buster_rest/dashboards => asset_interfaces/dashboard}/interfaces.ts (76%) create mode 100644 web/src/api/asset_interfaces/metric/defaults.ts create mode 100644 web/src/api/asset_interfaces/metric/requireInterfaces.ts rename web/src/api/{buster_rest => asset_interfaces}/search/index.ts (60%) create mode 100644 web/src/api/asset_interfaces/share/index.ts rename web/src/api/{buster_socket => asset_interfaces}/share/shareInterfaces.ts (87%) create mode 100644 web/src/api/asset_interfaces/share/verificationInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetCollectionInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDashboardInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDatasetInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetTermInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetValueInterfaces.ts delete mode 100644 web/src/api/buster_socket/chats/chatAssetInterfaces/index.ts delete mode 100644 web/src/api/buster_socket/share/index.ts diff --git a/web/src/api/buster_socket/chats/chatInterfaces.ts b/web/src/api/asset_interfaces/chat/chatInterfaces.ts similarity index 100% rename from web/src/api/buster_socket/chats/chatInterfaces.ts rename to web/src/api/asset_interfaces/chat/chatInterfaces.ts diff --git a/web/src/api/buster_socket/chats/chatMessageInterfaces.ts b/web/src/api/asset_interfaces/chat/chatMessageInterfaces.ts similarity index 100% rename from web/src/api/buster_socket/chats/chatMessageInterfaces.ts rename to web/src/api/asset_interfaces/chat/chatMessageInterfaces.ts diff --git a/web/src/api/buster_socket/chats/chatProgressInterfaces.ts b/web/src/api/asset_interfaces/chat/chatProgressInterfaces.ts similarity index 100% rename from web/src/api/buster_socket/chats/chatProgressInterfaces.ts rename to web/src/api/asset_interfaces/chat/chatProgressInterfaces.ts diff --git a/web/src/api/buster_socket/chats/config.ts b/web/src/api/asset_interfaces/chat/config.ts similarity index 100% rename from web/src/api/buster_socket/chats/config.ts rename to web/src/api/asset_interfaces/chat/config.ts diff --git a/web/src/api/asset_interfaces/chat/index.ts b/web/src/api/asset_interfaces/chat/index.ts new file mode 100644 index 000000000..ec8fd92b2 --- /dev/null +++ b/web/src/api/asset_interfaces/chat/index.ts @@ -0,0 +1,4 @@ +export * from './chatInterfaces'; +export * from './config'; +export * from './chatMessageInterfaces'; +export * from './chatProgressInterfaces'; diff --git a/web/src/api/buster_rest/dashboards/index.ts b/web/src/api/asset_interfaces/collection/index.ts similarity index 100% rename from web/src/api/buster_rest/dashboards/index.ts rename to web/src/api/asset_interfaces/collection/index.ts diff --git a/web/src/api/buster_rest/collection/index.ts b/web/src/api/asset_interfaces/collection/interfaces.ts similarity index 82% rename from web/src/api/buster_rest/collection/index.ts rename to web/src/api/asset_interfaces/collection/interfaces.ts index dab445e6d..19baf0e86 100644 --- a/web/src/api/buster_rest/collection/index.ts +++ b/web/src/api/asset_interfaces/collection/interfaces.ts @@ -1,6 +1,4 @@ -import { ShareRole } from '@/api/buster_socket/threads'; -import { BusterShareAssetType } from '../users'; -import { BusterShare } from '../threads'; +import { BusterShare, ShareAssetType, ShareRole } from '../share'; export interface BusterCollectionListItem { id: string; @@ -14,7 +12,7 @@ export interface BusterCollectionListItem { id: string; name: string; }; - member: any[]; + member: []; } export interface BusterCollection extends BusterShare { @@ -38,7 +36,7 @@ export interface BusterCollection extends BusterShare { } export interface BusterCollectionItemAsset { - asset_type: BusterShareAssetType; + asset_type: ShareAssetType; id: string; created_at: string; updated_at: string; diff --git a/web/src/api/buster_socket/dashboards/dashboardConfigInterfaces.ts b/web/src/api/asset_interfaces/dashboard/dashboardConfigInterfaces.ts similarity index 62% rename from web/src/api/buster_socket/dashboards/dashboardConfigInterfaces.ts rename to web/src/api/asset_interfaces/dashboard/dashboardConfigInterfaces.ts index 5c44cd733..51b4ff428 100644 --- a/web/src/api/buster_socket/dashboards/dashboardConfigInterfaces.ts +++ b/web/src/api/asset_interfaces/dashboard/dashboardConfigInterfaces.ts @@ -1,4 +1,4 @@ -import { BusterResizeableGridRow } from '@/components/grid'; +import type { BusterResizeableGridRow } from '@/components/grid/interfaces'; export interface DashboardConfig { rows?: (Omit & { diff --git a/web/src/api/asset_interfaces/dashboard/index.ts b/web/src/api/asset_interfaces/dashboard/index.ts new file mode 100644 index 000000000..cbfb6299b --- /dev/null +++ b/web/src/api/asset_interfaces/dashboard/index.ts @@ -0,0 +1,2 @@ +export * from './dashboardConfigInterfaces'; +export * from './interfaces'; diff --git a/web/src/api/buster_rest/dashboards/interfaces.ts b/web/src/api/asset_interfaces/dashboard/interfaces.ts similarity index 76% rename from web/src/api/buster_rest/dashboards/interfaces.ts rename to web/src/api/asset_interfaces/dashboard/interfaces.ts index cde229082..c231f1863 100644 --- a/web/src/api/buster_rest/dashboards/interfaces.ts +++ b/web/src/api/asset_interfaces/dashboard/interfaces.ts @@ -1,14 +1,9 @@ -import type { DashboardConfig } from '@/api/buster_socket/dashboards'; -import type { IBusterThreadMessageChartConfig } from '../threads/threadConfigInterfaces'; -import type { - BusterShare, - BusterThreadListItem, - BusterThreadMessage, - BusterVerificationStatus -} from '../threads'; -import type { ShareRole } from '@/api/buster_socket/threads'; import type { BusterCollectionListItem } from '../collection'; -import type { BusterChartConfigProps } from '@/components/charts'; +import type { BusterChartConfigProps } from '@/components/charts/interfaces'; +import type { BusterShare, ShareRole, VerificationStatus } from '../share'; +import type { DataMetadata, IBusterMetricChartConfig } from '../metric'; +import type { DashboardConfig } from './dashboardConfigInterfaces'; + export interface BusterDashboardListItem { created_at: string; id: string; @@ -24,7 +19,7 @@ export interface BusterDashboardListItem { id: string; name: string; }; - status: BusterVerificationStatus; + status: VerificationStatus; is_shared: boolean; } @@ -54,7 +49,7 @@ export interface BusterDashboard name: string; updated_at: string | null; updated_by: string; - status: BusterThreadListItem['status']; + status: VerificationStatus; } export interface BusterDashboardMetric { @@ -63,7 +58,7 @@ export interface BusterDashboardMetric { name: string; id: string; description: string | null; - data_metadata: BusterThreadMessage['data_metadata']; + data_metadata: DataMetadata; error: string | null; code: string | null; } @@ -76,5 +71,5 @@ export interface BusterMetricDataResponse { } export interface IBusterDashboardMetric extends Omit { - chart_config: IBusterThreadMessageChartConfig; + chart_config: IBusterMetricChartConfig; } diff --git a/web/src/api/asset_interfaces/index.ts b/web/src/api/asset_interfaces/index.ts index c40852a3f..cd89cb04b 100644 --- a/web/src/api/asset_interfaces/index.ts +++ b/web/src/api/asset_interfaces/index.ts @@ -1 +1,6 @@ -export type * from './metric'; +export * from './metric'; +export * from './share'; +export type * from './collection'; +export type * from './dashboard'; +export type * from './chat'; +export type * from './search'; diff --git a/web/src/api/asset_interfaces/metric/defaults.ts b/web/src/api/asset_interfaces/metric/defaults.ts new file mode 100644 index 000000000..43e4071f4 --- /dev/null +++ b/web/src/api/asset_interfaces/metric/defaults.ts @@ -0,0 +1,137 @@ +import type { IBusterMetricChartConfig } from './requireInterfaces'; +import type { ColumnSettings } from '../../../components/charts/interfaces/columnInterfaces'; +import { ChartType, ViewType } from '../../../components/charts/interfaces/enum'; +import { DEFAULT_CHART_THEME } from '../../../components/charts/configColors'; +import type { ColumnLabelFormat } from '../../../components/charts/interfaces/columnLabelInterfaces'; +import type { ColumnMetaData } from './interfaces'; + +export const DEFAULT_CHART_CONFIG: IBusterMetricChartConfig = { + colors: DEFAULT_CHART_THEME, + selectedChartType: ChartType.Table, + selectedView: ViewType.Table, + yAxisShowAxisLabel: true, + yAxisShowAxisTitle: true, + yAxisAxisTitle: null, + yAxisStartAxisAtZero: null, + yAxisScaleType: 'linear', + y2AxisShowAxisLabel: true, + y2AxisAxisTitle: null, + y2AxisShowAxisTitle: true, + y2AxisStartAxisAtZero: true, + y2AxisScaleType: 'linear', + xAxisShowAxisLabel: true, + xAxisShowAxisTitle: true, + xAxisAxisTitle: null, + xAxisLabelRotation: 'auto', + xAxisDataZoom: false, + categoryAxisTitle: null, + showLegend: null, + gridLines: true, + goalLines: [], + trendlines: [], + showLegendHeadline: false, + disableTooltip: false, + barAndLineAxis: { + x: [], + y: [], + category: [], + tooltip: null + }, + scatterAxis: { + x: [], + y: [], + size: [], + tooltip: null + }, + comboChartAxis: { + x: [], + y: [], + y2: [], + tooltip: null + }, + pieChartAxis: { + x: [], + y: [], + tooltip: null + }, + //LINE + lineGroupType: null, + //SCATTER + scatterDotSize: [3, 15], + //BAR + barSortBy: [], + barLayout: 'vertical', + barGroupType: 'group', + barShowTotalAtTop: false, + //PIE + pieShowInnerLabel: true, + pieInnerLabelAggregate: 'sum', + pieInnerLabelTitle: 'Total', + pieLabelPosition: null, + pieDonutWidth: 40, + pieMinimumSlicePercentage: 0, + pieDisplayLabelAs: 'number', + //METRIC + metricColumnId: '', + metricValueAggregate: 'sum', + metricHeader: null, + metricSubHeader: null, + metricValueLabel: null, + //TABLE + tableColumnOrder: null, + tableColumnWidths: null, + tableHeaderBackgroundColor: null, + tableHeaderFontColor: null, + tableColumnFontColor: null, + //MUST LOOP THROUGH ALL COLUMNS + columnSettings: {}, + columnLabelFormats: {} +}; + +export const DEFAULT_COLUMN_SETTINGS: Required = { + showDataLabels: false, + columnVisualization: 'bar', + lineWidth: 2, + lineStyle: 'line', + lineType: 'normal', + lineSymbolSize: 0, + barRoundness: 8, + showDataLabelsAsPercentage: false +}; + +export const DEFAULT_COLUMN_LABEL_FORMAT: Required = { + style: 'string', + compactNumbers: false, + columnType: 'string', + displayName: '', + numberSeparatorStyle: ',', + minimumFractionDigits: 0, + maximumFractionDigits: 2, + currency: 'USD', + convertNumberTo: null, + dateFormat: 'auto', + useRelativeTime: false, + isUTC: false, + multiplier: 1, + prefix: '', + suffix: '', + replaceMissingDataWith: 0, + makeLabelHumanReadable: true +}; + +export const ENABLED_DOTS_ON_LINE = 3.5; + +export const DEFAULT_CHART_CONFIG_ENTRIES = Object.entries(DEFAULT_CHART_CONFIG); + +export const DEFAULT_BAR_ROUNDNESS = DEFAULT_COLUMN_SETTINGS.barRoundness; + +export const MIN_DONUT_WIDTH = 15; + +export const DEFAULT_DAY_OF_WEEK_FORMAT = 'ddd'; +export const DEFAULT_DATE_FORMAT_DAY_OF_WEEK = 'dddd'; +export const DEFAULT_DATE_FORMAT_MONTH_OF_YEAR = 'MMMM'; +export const DEFAULT_DATE_FORMAT_QUARTER = 'YYYY [Q]Q'; + +export const ENABLED_DOTS_ON_LINE_SIZE = 8; + +export const DEFAULT_COLUMN_METADATA: ColumnMetaData[] = []; diff --git a/web/src/api/asset_interfaces/metric/index.ts b/web/src/api/asset_interfaces/metric/index.ts index 957860982..da3b93a2c 100644 --- a/web/src/api/asset_interfaces/metric/index.ts +++ b/web/src/api/asset_interfaces/metric/index.ts @@ -1 +1,2 @@ export * from './interfaces'; +export * from './requireInterfaces'; diff --git a/web/src/api/asset_interfaces/metric/interfaces.ts b/web/src/api/asset_interfaces/metric/interfaces.ts index 91df72c09..bf735706c 100644 --- a/web/src/api/asset_interfaces/metric/interfaces.ts +++ b/web/src/api/asset_interfaces/metric/interfaces.ts @@ -1,5 +1,5 @@ import type { BusterChartConfigProps } from '@/components/charts'; -import { BusterShare } from '../../buster_socket/share/shareInterfaces'; +import { BusterShare, VerificationStatus } from '../share'; export type BusterMetricAsset = { id: string; @@ -11,12 +11,8 @@ export type BusterMetricAsset = { dataset_name: string | null; error: string | null; chart_config?: BusterChartConfigProps; - data_metadata: { - column_count: number; - column_metadata: ColumnMetaData[]; - row_count: number; - } | null; - status: BusterVerificationStatus; + data_metadata: DataMetadata; + status: VerificationStatus; evaluation_score: 'Moderate' | 'High' | 'Low'; evaluation_summary: string; file: string; //yaml file @@ -36,16 +32,13 @@ export type BusterMetricAsset = { }[]; } & BusterShare; -enum BusterVerificationStatus { - notRequested = 'notRequested', - requested = 'requested', - inReview = 'inReview', - verified = 'verified', - backlogged = 'backlogged', - notVerified = 'notVerified' -} +export type DataMetadata = { + column_count: number; + column_metadata: ColumnMetaData[]; + row_count: number; +} | null; -type ColumnMetaData = { +export type ColumnMetaData = { name: string; min_value: number | string; max_value: number | string; diff --git a/web/src/api/asset_interfaces/metric/requireInterfaces.ts b/web/src/api/asset_interfaces/metric/requireInterfaces.ts new file mode 100644 index 000000000..c8b2495bd --- /dev/null +++ b/web/src/api/asset_interfaces/metric/requireInterfaces.ts @@ -0,0 +1,12 @@ +import type { + BusterChartConfigProps, + ColumnSettings, + IColumnLabelFormat +} from '@/components/charts/interfaces'; + +export type IBusterMetricChartConfig = Required< + Omit +> & { + columnLabelFormats: Record>; + columnSettings: Required>>; +}; diff --git a/web/src/api/buster_rest/search/index.ts b/web/src/api/asset_interfaces/search/index.ts similarity index 60% rename from web/src/api/buster_rest/search/index.ts rename to web/src/api/asset_interfaces/search/index.ts index 9b32b4d13..ba4912f6f 100644 --- a/web/src/api/buster_rest/search/index.ts +++ b/web/src/api/asset_interfaces/search/index.ts @@ -1,10 +1,10 @@ -import { BusterShareAssetType } from '../users'; +import type { ShareAssetType } from '@/api/asset_interfaces'; export interface BusterSearchResult { id: string; highlights: string[]; name: string; updated_at: string; - type: BusterShareAssetType; + type: ShareAssetType; score: number; } diff --git a/web/src/api/asset_interfaces/share/index.ts b/web/src/api/asset_interfaces/share/index.ts new file mode 100644 index 000000000..7446d0ba5 --- /dev/null +++ b/web/src/api/asset_interfaces/share/index.ts @@ -0,0 +1,2 @@ +export * from './shareInterfaces'; +export * from './verificationInterfaces'; diff --git a/web/src/api/buster_socket/share/shareInterfaces.ts b/web/src/api/asset_interfaces/share/shareInterfaces.ts similarity index 87% rename from web/src/api/buster_socket/share/shareInterfaces.ts rename to web/src/api/asset_interfaces/share/shareInterfaces.ts index f7812d08e..6f1aae25f 100644 --- a/web/src/api/buster_socket/share/shareInterfaces.ts +++ b/web/src/api/asset_interfaces/share/shareInterfaces.ts @@ -4,6 +4,12 @@ export enum ShareRole { VIEWER = 'viewer' } +export enum ShareAssetType { + METRIC = 'metric', + DASHBOARD = 'dashboard', + COLLECTION = 'collection' +} + export interface BusterShare { sharingKey: string; individual_permissions: null | BusterShareIndividual[]; diff --git a/web/src/api/asset_interfaces/share/verificationInterfaces.ts b/web/src/api/asset_interfaces/share/verificationInterfaces.ts new file mode 100644 index 000000000..f7f1aeea7 --- /dev/null +++ b/web/src/api/asset_interfaces/share/verificationInterfaces.ts @@ -0,0 +1,8 @@ +export enum VerificationStatus { + notRequested = 'notRequested', + requested = 'requested', + inReview = 'inReview', + verified = 'verified', + backlogged = 'backlogged', + notVerified = 'notVerified' +} diff --git a/web/src/api/buster_rest/index.ts b/web/src/api/buster_rest/index.ts index 8aec811cd..f4a311e27 100644 --- a/web/src/api/buster_rest/index.ts +++ b/web/src/api/buster_rest/index.ts @@ -1,9 +1,7 @@ export * from './threads'; -export * from './dashboards'; export * from './users'; export * from './datasources'; export * from './terms'; -export * from './search'; export * from './assets'; export * from './api_keys'; export * from './sql'; diff --git a/web/src/api/buster_rest/threads/interfaces.ts b/web/src/api/buster_rest/threads/interfaces.ts index ebe8fbb5b..4bb3a119d 100644 --- a/web/src/api/buster_rest/threads/interfaces.ts +++ b/web/src/api/buster_rest/threads/interfaces.ts @@ -1,3 +1,4 @@ +import { VerificationStatus } from '@/api/asset_interfaces'; import type { ShareRole } from '@/api/buster_socket/threads'; import type { BusterChartConfigProps } from '@/components/charts'; @@ -11,19 +12,10 @@ export type BusterThreadListItem = { created_by_name: string; created_by_email: string; created_by_avatar: string; - status: BusterVerificationStatus; + status: VerificationStatus; is_shared: boolean; }; -export enum BusterVerificationStatus { - notRequested = 'notRequested', - requested = 'requested', - inReview = 'inReview', - verified = 'verified', - backlogged = 'backlogged', - notVerified = 'notVerified' -} - export type BusterThread = { created_at: string; created_by: string; diff --git a/web/src/api/buster_rest/users/interfaces.ts b/web/src/api/buster_rest/users/interfaces.ts index bc2ead3d1..2f57901ea 100644 --- a/web/src/api/buster_rest/users/interfaces.ts +++ b/web/src/api/buster_rest/users/interfaces.ts @@ -1,4 +1,5 @@ import { BusterPermissionUser } from '../permissions'; +import type { ShareAssetType } from '../../asset_interfaces'; export interface BusterUserPalette { id: string; @@ -35,7 +36,7 @@ export interface BusterUserTeam { export interface BusterUserFavorite { id: string; - type: BusterShareAssetType; + type: ShareAssetType; index?: number; name: string; //collections @@ -43,17 +44,11 @@ export interface BusterUserFavorite { collection_id?: string; assets?: { id: string; - type: BusterShareAssetType; + type: ShareAssetType; name: string; }[]; } -export enum BusterShareAssetType { - THREAD = 'thread', - DASHBOARD = 'dashboard', - COLLECTION = 'collection' -} - export interface BusterUser { config: {}; created_at: string; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetCollectionInterfaces.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetCollectionInterfaces.ts deleted file mode 100644 index 3219ae531..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetCollectionInterfaces.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BusterShare } from '../../share/shareInterfaces'; - -export type BusterCollectionAsset = { - id: string; - type: 'collection'; -} & BusterShare; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDashboardInterfaces.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDashboardInterfaces.ts deleted file mode 100644 index a4afcc576..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDashboardInterfaces.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { BusterDashboardMetric } from '../../../buster_rest/dashboards'; -import type { DashboardConfig } from '../../dashboards'; -import { BusterShare } from '../../share/shareInterfaces'; - -export type BusterDashboardAsset = { - id: string; - type: 'dashboard'; - metrics: BusterDashboardMetric[]; - config: DashboardConfig; - created_at: string; - created_by: string; - deleted_at: string | null; - description: string | null; - title: string; - updated_at: string | null; - updated_by: string; -} & BusterShare; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDatasetInterfaces.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDatasetInterfaces.ts deleted file mode 100644 index f0142d4d8..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetDatasetInterfaces.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { FileType } from '../config'; - -export type BusterDatasetAsset = { - id: string; - type: 'dataset'; -}; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetTermInterfaces.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetTermInterfaces.ts deleted file mode 100644 index 24055e590..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetTermInterfaces.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { FileType } from '../config'; - -export type BusterTermAsset = { - id: string; - type: 'term'; -}; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetValueInterfaces.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetValueInterfaces.ts deleted file mode 100644 index 07e159829..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/chatAssetValueInterfaces.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { FileType } from '../config'; - -export type BusterValueAsset = { - id: string; - type: 'value'; -}; diff --git a/web/src/api/buster_socket/chats/chatAssetInterfaces/index.ts b/web/src/api/buster_socket/chats/chatAssetInterfaces/index.ts deleted file mode 100644 index 758c60028..000000000 --- a/web/src/api/buster_socket/chats/chatAssetInterfaces/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { BusterCollectionAsset } from './chatAssetCollectionInterfaces'; -import type { BusterDashboardAsset } from './chatAssetDashboardInterfaces'; -import type { BusterDatasetAsset } from './chatAssetDatasetInterfaces'; -import type { BusterTermAsset } from './chatAssetTermInterfaces'; -import type { BusterValueAsset } from './chatAssetValueInterfaces'; -import type { BusterMetricAsset } from '@/api/asset_interfaces'; -export * from '../../share/shareInterfaces'; - -export type BusterChatAsset = - | BusterMetricAsset - | BusterDashboardAsset - | BusterCollectionAsset - | BusterDatasetAsset - | BusterTermAsset - | BusterValueAsset; - -export { - BusterCollectionAsset, - BusterDashboardAsset, - BusterDatasetAsset, - BusterTermAsset, - BusterValueAsset -}; diff --git a/web/src/api/buster_socket/chats/chatRequests.ts b/web/src/api/buster_socket/chats/chatRequests.ts index 80ac733e5..0992d7804 100644 --- a/web/src/api/buster_socket/chats/chatRequests.ts +++ b/web/src/api/buster_socket/chats/chatRequests.ts @@ -1,5 +1,4 @@ import type { BusterSocketRequestBase } from '../base_interfaces'; -import type { FileType } from './config'; export type ChatCreateNewChat = BusterSocketRequestBase< '/chats/post', diff --git a/web/src/api/buster_socket/chats/chatResponses.ts b/web/src/api/buster_socket/chats/chatResponses.ts index 0699ba031..260f1d2b9 100644 --- a/web/src/api/buster_socket/chats/chatResponses.ts +++ b/web/src/api/buster_socket/chats/chatResponses.ts @@ -1,5 +1,5 @@ import type { RustApiError } from '../../buster_rest/errors'; -import type { BusterChat, BusterChatListItem } from './chatInterfaces'; +import type { BusterChat, BusterChatListItem } from '../../asset_interfaces/chat'; export enum ChatsResponses { '/chats/list:getChatsList' = '/chats/list:getChatsList', diff --git a/web/src/api/buster_socket/chats/index.ts b/web/src/api/buster_socket/chats/index.ts index 81d8b7484..1f6ffab23 100644 --- a/web/src/api/buster_socket/chats/index.ts +++ b/web/src/api/buster_socket/chats/index.ts @@ -1,7 +1,2 @@ -export * from './chatAssetInterfaces'; -export * from './chatInterfaces'; export * from './chatRequests'; export * from './chatResponses'; -export * from './config'; -export * from './chatMessageInterfaces'; -export * from './chatAssetInterfaces'; diff --git a/web/src/api/buster_socket/collections/collectionRequests.ts b/web/src/api/buster_socket/collections/collectionRequests.ts index 37aa09f2b..1f452340e 100644 --- a/web/src/api/buster_socket/collections/collectionRequests.ts +++ b/web/src/api/buster_socket/collections/collectionRequests.ts @@ -1,4 +1,4 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '../../asset_interfaces'; import { BusterSocketRequestBase } from '../base_interfaces'; import { ShareRequest } from '../dashboards'; @@ -28,7 +28,7 @@ export type CollectionUpdateCollection = BusterSocketRequestBase< id: string; name?: string; assets?: { - type: BusterShareAssetType; + type: ShareAssetType; id: string; }[]; } & ShareRequest diff --git a/web/src/api/buster_socket/collections/collectionResponses.ts b/web/src/api/buster_socket/collections/collectionResponses.ts index 380322575..a5691d73c 100644 --- a/web/src/api/buster_socket/collections/collectionResponses.ts +++ b/web/src/api/buster_socket/collections/collectionResponses.ts @@ -1,4 +1,4 @@ -import { BusterCollection, BusterCollectionListItem } from '@/api/buster_rest/collection'; +import { BusterCollection, BusterCollectionListItem } from '@/api/asset_interfaces/collection'; export enum CollectionResponses { '/collections/list:listCollections' = '/collections/list:listCollections', diff --git a/web/src/api/buster_socket/dashboards/dashboardRequests.ts b/web/src/api/buster_socket/dashboards/dashboardRequests.ts index cbd2b7977..e7d38ce92 100644 --- a/web/src/api/buster_socket/dashboards/dashboardRequests.ts +++ b/web/src/api/buster_socket/dashboards/dashboardRequests.ts @@ -1,7 +1,5 @@ -import { BusterVerificationStatus } from '@/api/buster_rest'; -import { BusterSocketRequestBase } from '../base_interfaces'; -import { ShareRole } from '../threads'; -import { DashboardConfig } from './dashboardConfigInterfaces'; +import type { ShareRole, DashboardConfig, VerificationStatus } from '@/api/asset_interfaces'; +import type { BusterSocketRequestBase } from '../base_interfaces'; export type DashboardsListEmitPayload = BusterSocketRequestBase< '/dashboards/list', @@ -58,7 +56,7 @@ export type DashboardUpdate = BusterSocketRequestBase< name?: string; description?: string | null; config?: DashboardConfig; - status?: BusterVerificationStatus; + status?: VerificationStatus; add_to_collections?: string[]; // collection_id remove_from_collections?: string[]; // collection_id remove_users?: string[]; // user_id diff --git a/web/src/api/buster_socket/dashboards/dashboardResponses.ts b/web/src/api/buster_socket/dashboards/dashboardResponses.ts index 7a9ee1fd8..e461df7ed 100644 --- a/web/src/api/buster_socket/dashboards/dashboardResponses.ts +++ b/web/src/api/buster_socket/dashboards/dashboardResponses.ts @@ -1,9 +1,9 @@ -import { +import type { BusterDashboard, BusterDashboardListItem, BusterDashboardResponse, BusterMetricDataResponse -} from '@/api/buster_rest'; +} from '@/api/asset_interfaces'; export enum DashboardResponses { '/dashboards/get:getDashboardState' = '/dashboards/get:getDashboardState', diff --git a/web/src/api/buster_socket/dashboards/index.ts b/web/src/api/buster_socket/dashboards/index.ts index 925367ce1..c73e7f879 100644 --- a/web/src/api/buster_socket/dashboards/index.ts +++ b/web/src/api/buster_socket/dashboards/index.ts @@ -1,3 +1,2 @@ export * from './dashboardRequests'; export * from './dashboardResponses'; -export * from './dashboardConfigInterfaces'; diff --git a/web/src/api/buster_socket/search/searchRequests.ts b/web/src/api/buster_socket/search/searchRequests.ts index 9c25bd413..471c0ad02 100644 --- a/web/src/api/buster_socket/search/searchRequests.ts +++ b/web/src/api/buster_socket/search/searchRequests.ts @@ -1,4 +1,4 @@ -import { BusterSocketRequestBase } from '../base_interfaces'; +import type { BusterSocketRequestBase } from '../base_interfaces'; export type BusterSearchRequest = BusterSocketRequestBase< '/search', diff --git a/web/src/api/buster_socket/search/searchResponses.ts b/web/src/api/buster_socket/search/searchResponses.ts index fdafd6ccc..d7337ab9e 100644 --- a/web/src/api/buster_socket/search/searchResponses.ts +++ b/web/src/api/buster_socket/search/searchResponses.ts @@ -1,4 +1,4 @@ -import { BusterSearchResult } from '@/api/buster_rest/search'; +import type { BusterSearchResult } from '@/api/asset_interfaces/search'; export enum SearchResponses { '/search:search' = '/search:search' diff --git a/web/src/api/buster_socket/share/index.ts b/web/src/api/buster_socket/share/index.ts deleted file mode 100644 index 805f9e87c..000000000 --- a/web/src/api/buster_socket/share/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './shareInterfaces'; diff --git a/web/src/api/buster_socket/threads/threadsRequests.ts b/web/src/api/buster_socket/threads/threadsRequests.ts index 82d71838e..464796fd2 100644 --- a/web/src/api/buster_socket/threads/threadsRequests.ts +++ b/web/src/api/buster_socket/threads/threadsRequests.ts @@ -1,7 +1,7 @@ import { BusterChartConfigProps } from '@/components/charts'; import { BusterSocketRequestBase } from '../base_interfaces'; import { ShareRequest } from '../dashboards'; -import type { BusterVerificationStatus } from '@/api/buster_rest'; +import { VerificationStatus } from '@/api/asset_interfaces'; export type ThreadListEmitPayload = BusterSocketRequestBase< '/threads/list', @@ -9,7 +9,7 @@ export type ThreadListEmitPayload = BusterSocketRequestBase< page_token: number; page_size: number; admin_view: boolean; - filters?: { status: BusterVerificationStatus[] | null }; + filters?: { status: VerificationStatus[] | null }; } >; @@ -62,7 +62,7 @@ export type ThreadUpdateMessage = BusterSocketRequestBase< title?: string; sql?: string; feedback?: 'negative'; - status?: BusterVerificationStatus; + status?: VerificationStatus; } >; diff --git a/web/src/api/buster_socket/threads/threadsResponses.ts b/web/src/api/buster_socket/threads/threadsResponses.ts index 22e9847da..5ac97f61d 100644 --- a/web/src/api/buster_socket/threads/threadsResponses.ts +++ b/web/src/api/buster_socket/threads/threadsResponses.ts @@ -1,4 +1,4 @@ -import { +import type { BusterThread, BusterThreadListItem, BusterThreadSearchItem, diff --git a/web/src/api/buster_socket/user/teamRequests.ts b/web/src/api/buster_socket/user/teamRequests.ts index 033d83450..2ea681e18 100644 --- a/web/src/api/buster_socket/user/teamRequests.ts +++ b/web/src/api/buster_socket/user/teamRequests.ts @@ -1,4 +1,4 @@ -import { BusterSocketRequestBase } from '../base_interfaces'; +import type { BusterSocketRequestBase } from '../base_interfaces'; export type TeamRequestsList = BusterSocketRequestBase< '/teams/list', diff --git a/web/src/api/buster_socket/user/teamResponses.ts b/web/src/api/buster_socket/user/teamResponses.ts index 46b857397..7205d90a0 100644 --- a/web/src/api/buster_socket/user/teamResponses.ts +++ b/web/src/api/buster_socket/user/teamResponses.ts @@ -1,4 +1,4 @@ -import { BusterUserTeam } from '@/api/buster_rest'; +import type { BusterUserTeam } from '@/api/buster_rest'; export enum TeamResponses { '/teams/list:listTeams' = '/teams/list:listTeams' diff --git a/web/src/api/buster_socket/user/userRequests.ts b/web/src/api/buster_socket/user/userRequests.ts index 638fdbdeb..22cabfda7 100644 --- a/web/src/api/buster_socket/user/userRequests.ts +++ b/web/src/api/buster_socket/user/userRequests.ts @@ -1,5 +1,5 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; -import { BusterSocketRequestBase } from '../base_interfaces'; +import type { ShareAssetType } from '@/api/asset_interfaces'; +import type { BusterSocketRequestBase } from '../base_interfaces'; export type UserColorsList = BusterSocketRequestBase<'/users/colors/list', {}>; @@ -29,7 +29,7 @@ export type UsersFavoritePost = BusterSocketRequestBase< '/users/favorites/post', { id: string; - asset_type: BusterShareAssetType; + asset_type: ShareAssetType; index?: number; } >; @@ -40,7 +40,7 @@ export type UserFavoriteDelete = BusterSocketRequestBase< '/users/favorites/delete', { id: string; - asset_type: BusterShareAssetType; + asset_type: ShareAssetType; } >; diff --git a/web/src/app/_helpers/listHelpers.tsx b/web/src/app/_helpers/listHelpers.tsx index 2ecacf918..ee868c7a2 100644 --- a/web/src/app/_helpers/listHelpers.tsx +++ b/web/src/app/_helpers/listHelpers.tsx @@ -1,14 +1,14 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { AppMaterialIcons } from '@/components'; -const iconRecord: Record = { - [BusterShareAssetType.COLLECTION]: 'note_stack', - [BusterShareAssetType.DASHBOARD]: 'grid_view', - [BusterShareAssetType.THREAD]: 'monitoring' +const iconRecord: Record = { + [ShareAssetType.COLLECTION]: 'note_stack', + [ShareAssetType.DASHBOARD]: 'grid_view', + [ShareAssetType.METRIC]: 'monitoring' }; export const asset_typeToIcon = ( - type: BusterShareAssetType, + type: ShareAssetType, props?: { open?: boolean; size?: number } ) => { const { open, size } = props || {}; @@ -16,11 +16,11 @@ export const asset_typeToIcon = ( return ; }; -export const asset_typeToTranslation = (type: BusterShareAssetType) => { - const asset_typeTranslation: Record = { - [BusterShareAssetType.COLLECTION]: 'collection', - [BusterShareAssetType.DASHBOARD]: 'dashboard', - [BusterShareAssetType.THREAD]: 'thread' +export const asset_typeToTranslation = (type: ShareAssetType) => { + const asset_typeTranslation: Record = { + [ShareAssetType.COLLECTION]: 'collection', + [ShareAssetType.DASHBOARD]: 'dashboard', + [ShareAssetType.METRIC]: 'thread' }; return asset_typeTranslation[type]; }; diff --git a/web/src/app/app/_components/AddTypeModal.tsx b/web/src/app/app/_components/AddTypeModal.tsx index f03b920f3..60ad6cdf5 100644 --- a/web/src/app/app/_components/AddTypeModal.tsx +++ b/web/src/app/app/_components/AddTypeModal.tsx @@ -5,13 +5,13 @@ import { BusterList, BusterListColumn, BusterListRow } from '@/components/list'; import { useMemoizedFn, useThrottleFn } from 'ahooks'; import { boldHighlights, formatDate } from '@/utils'; import { - BusterDashboardResponse, - BusterSearchResult, - BusterShareAssetType -} from '@/api/buster_rest'; + type BusterDashboardResponse, + type BusterSearchResult, + ShareAssetType +} from '@/api/asset_interfaces'; import { asset_typeToIcon } from '@/app/_helpers'; import { CircleSpinnerLoaderContainer } from '@/components/loaders'; -import { BusterCollection } from '@/api/buster_rest/collection'; +import { BusterCollection } from '@/api/asset_interfaces/collection'; import { useBusterSearchContextSelector } from '@/context/Search'; import isEmpty from 'lodash/isEmpty'; import { useDashboardContextSelector } from '@/context/Dashboards'; @@ -61,11 +61,11 @@ export const AddTypeModal: React.FC<{ const searchItems = inputValue ? ongoingSearchItems : ongoingSearchItems; const columns: BusterListColumn[] = useMemo(() => { - const fallbackName = (name: string, type: BusterShareAssetType) => { - if (type === BusterShareAssetType.DASHBOARD && !name) { + const fallbackName = (name: string, type: ShareAssetType) => { + if (type === ShareAssetType.DASHBOARD && !name) { return 'New dashboard'; } - if (type === BusterShareAssetType.THREAD && !name) { + if (type === ShareAssetType.METRIC && !name) { return 'New metric'; } diff --git a/web/src/app/app/_components/Dropdowns/SaveToCollectionsDropdown.tsx b/web/src/app/app/_components/Dropdowns/SaveToCollectionsDropdown.tsx index 78c9273a9..95a167583 100644 --- a/web/src/app/app/_components/Dropdowns/SaveToCollectionsDropdown.tsx +++ b/web/src/app/app/_components/Dropdowns/SaveToCollectionsDropdown.tsx @@ -8,7 +8,7 @@ import { useMemoizedFn } from 'ahooks'; import { Button } from 'antd'; import React, { useMemo } from 'react'; import { NewCollectionModal } from '../../collections/_NewCollectionModal'; -import { BusterCollectionListItem } from '@/api/buster_rest/collection'; +import type { BusterCollectionListItem } from '@/api/asset_interfaces'; export const SaveToCollectionsDropdown: React.FC<{ children: React.ReactNode; diff --git a/web/src/app/app/_components/Dropdowns/SaveToDashboardDropdown.tsx b/web/src/app/app/_components/Dropdowns/SaveToDashboardDropdown.tsx index e4fc51596..1764d03e3 100644 --- a/web/src/app/app/_components/Dropdowns/SaveToDashboardDropdown.tsx +++ b/web/src/app/app/_components/Dropdowns/SaveToDashboardDropdown.tsx @@ -9,7 +9,7 @@ import { AppDropdownSelect } from '@/components/dropdown'; import { AppTooltip } from '@/components/tooltip'; import { AppMaterialIcons } from '@/components/icons'; import type { BusterMetricAsset } from '@/api/asset_interfaces'; -import type { BusterDashboardListItem } from '@/api/buster_rest/dashboards'; +import type { BusterDashboardListItem } from '@/api/asset_interfaces'; export const SaveToDashboardDropdown: React.FC<{ children: React.ReactNode; diff --git a/web/src/app/app/_components/Lists/FavoriteStar.tsx b/web/src/app/app/_components/Lists/FavoriteStar.tsx index dc68242eb..c7e9d7a73 100644 --- a/web/src/app/app/_components/Lists/FavoriteStar.tsx +++ b/web/src/app/app/_components/Lists/FavoriteStar.tsx @@ -1,7 +1,7 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { AppMaterialIcons, AppTooltip } from '@/components'; import { useUserConfigContextSelector } from '@/context/Users'; -import React, { useCallback, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { gold } from '@ant-design/colors/es/presets'; import { css } from 'antd-style'; import { createStyles } from 'antd-style'; @@ -28,7 +28,7 @@ const useStyles = createStyles(({ token }) => ({ export const FavoriteStar: React.FC<{ id: string; - type: BusterShareAssetType; + type: ShareAssetType; name: string; className?: string; iconStyle?: 'default' | 'tertiary'; diff --git a/web/src/app/app/_components/Lists/StatusBadgeIndicator.tsx b/web/src/app/app/_components/Lists/StatusBadgeIndicator.tsx index 1d1bc6541..cd8e9bda9 100644 --- a/web/src/app/app/_components/Lists/StatusBadgeIndicator.tsx +++ b/web/src/app/app/_components/Lists/StatusBadgeIndicator.tsx @@ -1,6 +1,7 @@ 'use client'; -import { BusterThreadListItem, BusterVerificationStatus } from '@/api/buster_rest'; +import { BusterThreadListItem } from '@/api/buster_rest'; +import { VerificationStatus } from '@/api/asset_interfaces'; import { AppMaterialIcons, AppPopoverMenu, AppTooltip } from '@/components'; import { useDashboardContextSelector } from '@/context/Dashboards'; import { useUserConfigContextSelector } from '@/context/Users'; @@ -17,7 +18,7 @@ export const StatusBadgeButton: React.FC<{ disabled?: boolean; onChangedStatus?: () => Promise; }> = React.memo( - ({ type, id, status = BusterVerificationStatus.notRequested, onChangedStatus, disabled }) => { + ({ type, id, status = VerificationStatus.notRequested, onChangedStatus, disabled }) => { const onVerifiedDashboard = useDashboardContextSelector((state) => state.onVerifiedDashboard); const onVerifiedThread = useBusterThreadsContextSelector((state) => state.onVerifiedThread); const isAdmin = useUserConfigContextSelector((state) => state.isAdmin); @@ -28,11 +29,8 @@ export const StatusBadgeButton: React.FC<{ setIsOpen(open); }); - const onChangeStatus = useMemoizedFn(async (newStatus: BusterVerificationStatus) => { - const userStatus = [ - BusterVerificationStatus.notRequested, - BusterVerificationStatus.requested - ]; + const onChangeStatus = useMemoizedFn(async (newStatus: VerificationStatus) => { + const userStatus = [VerificationStatus.notRequested, VerificationStatus.requested]; if ((!isAdmin && !userStatus.includes(newStatus)) || newStatus === status) { return; @@ -52,46 +50,46 @@ export const StatusBadgeButton: React.FC<{ () => [ { - label: getTooltipText(BusterVerificationStatus.notRequested), - icon: , - key: BusterVerificationStatus.notRequested, + label: getTooltipText(VerificationStatus.notRequested), + icon: , + key: VerificationStatus.notRequested, onClick: () => { - onChangeStatus(BusterVerificationStatus.notRequested); + onChangeStatus(VerificationStatus.notRequested); } }, { - label: getTooltipText(BusterVerificationStatus.requested), - icon: , - key: BusterVerificationStatus.requested, + label: getTooltipText(VerificationStatus.requested), + icon: , + key: VerificationStatus.requested, onClick: () => { - onChangeStatus(BusterVerificationStatus.requested); + onChangeStatus(VerificationStatus.requested); } }, { - label: getTooltipText(BusterVerificationStatus.inReview), - icon: , - key: BusterVerificationStatus.inReview, + label: getTooltipText(VerificationStatus.inReview), + icon: , + key: VerificationStatus.inReview, disabled: !isAdmin, onClick: () => { - isAdmin && onChangeStatus(BusterVerificationStatus.inReview); + isAdmin && onChangeStatus(VerificationStatus.inReview); } }, { - label: getTooltipText(BusterVerificationStatus.verified), - icon: , - key: BusterVerificationStatus.verified, + label: getTooltipText(VerificationStatus.verified), + icon: , + key: VerificationStatus.verified, disabled: !isAdmin, onClick: () => { - isAdmin && onChangeStatus(BusterVerificationStatus.verified); + isAdmin && onChangeStatus(VerificationStatus.verified); } }, { - label: getTooltipText(BusterVerificationStatus.backlogged), - icon: , - key: BusterVerificationStatus.backlogged, + label: getTooltipText(VerificationStatus.backlogged), + icon: , + key: VerificationStatus.backlogged, disabled: !isAdmin, onClick: () => { - isAdmin && onChangeStatus(BusterVerificationStatus.backlogged); + isAdmin && onChangeStatus(VerificationStatus.backlogged); } } ].map((item, index) => ({ @@ -140,7 +138,7 @@ export const StatusBadgeIndicator: React.FC<{ showTooltip?: boolean; }> = ({ showTooltip = true, - status = BusterVerificationStatus.notRequested, + status = VerificationStatus.notRequested, size = 16, className = '' }) => { @@ -149,7 +147,7 @@ export const StatusBadgeIndicator: React.FC<{ const colorClasses = getColorClasses(status); const tooltipText = getTooltipText(status); const isNotVerified = - status === BusterVerificationStatus.notVerified || BusterVerificationStatus.notRequested; + status === VerificationStatus.notVerified || VerificationStatus.notRequested; const sharedClass = `h-[16px] w-[16px] flex items-center justify-center rounded-full ${colorClasses}`; const _size = isNotVerified ? size : 16; @@ -172,19 +170,19 @@ export const StatusBadgeIndicator: React.FC<{ ); }; -const statusRecordIcon: Record> = { - [BusterVerificationStatus.verified]: () => , - [BusterVerificationStatus.requested]: () => , //contrast - [BusterVerificationStatus.inReview]: () => , - [BusterVerificationStatus.backlogged]: () => , - [BusterVerificationStatus.notVerified]: () => , - [BusterVerificationStatus.notRequested]: () => +const statusRecordIcon: Record> = { + [VerificationStatus.verified]: () => , + [VerificationStatus.requested]: () => , //contrast + [VerificationStatus.inReview]: () => , + [VerificationStatus.backlogged]: () => , + [VerificationStatus.notVerified]: () => , + [VerificationStatus.notRequested]: () => }; const getIcon = (status: BusterThreadListItem['status']) => { return statusRecordIcon[status] || (() => ); }; -const statusRecordColors: Record = { +const statusRecordColors: Record = { verified: '!text-[#34A32D]', requested: '!text-[#F2BE01]', inReview: '!text-[#7C3AED]', @@ -196,7 +194,7 @@ const getColorClasses = (status: BusterThreadListItem['status']) => { return statusRecordColors[status] || statusRecordColors.notRequested; }; -const statusRecordText: Record = { +const statusRecordText: Record = { verified: 'Verified', requested: 'Requested', inReview: 'In review', @@ -205,7 +203,7 @@ const statusRecordText: Record = { notRequested: 'Not requested' }; -const getTooltipText = (status: BusterVerificationStatus) => { +const getTooltipText = (status: VerificationStatus) => { return statusRecordText[status] || statusRecordText.notRequested; }; diff --git a/web/src/app/app/_components/NewThreadModal/NewThreadModal.tsx b/web/src/app/app/_components/NewThreadModal/NewThreadModal.tsx index 272456fff..97e08a656 100644 --- a/web/src/app/app/_components/NewThreadModal/NewThreadModal.tsx +++ b/web/src/app/app/_components/NewThreadModal/NewThreadModal.tsx @@ -6,7 +6,7 @@ import { useAntToken } from '@/styles/useAntToken'; import { useBusterNewThreadsContextSelector } from '@/context/Threads'; import { inputHasText } from '@/utils'; import { useBusterSearchContextSelector } from '@/context/Search'; -import { BusterSearchResult } from '@/api/buster_rest'; +import type { BusterSearchResult } from '@/api/asset_interfaces'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { NewThreadModalDataSourceSelect } from './NewThreadModalDatasourceSelect'; import { SuggestedPromptsContainer } from './SuggestedPromptsContainer'; diff --git a/web/src/app/app/_components/NewThreadModal/SuggestedPromptsContainer.tsx b/web/src/app/app/_components/NewThreadModal/SuggestedPromptsContainer.tsx index dedb1d23a..9627d5aaf 100644 --- a/web/src/app/app/_components/NewThreadModal/SuggestedPromptsContainer.tsx +++ b/web/src/app/app/_components/NewThreadModal/SuggestedPromptsContainer.tsx @@ -1,9 +1,9 @@ -import { BusterSearchResult } from '@/api/buster_rest'; +import type { BusterSearchResult } from '@/api/asset_interfaces'; import { CircleSpinnerLoader } from '@/components'; import { boldHighlights } from '@/utils/element'; import { createStyles } from 'antd-style'; -import React, { useEffect, useMemo } from 'react'; -import { AnimatePresence, motion } from 'framer-motion'; +import React, { useEffect } from 'react'; +import { motion } from 'framer-motion'; export const SuggestedPromptsContainer: React.FC<{ prompts: BusterSearchResult[]; diff --git a/web/src/app/app/_components/ShareMenu/ShareMenu.tsx b/web/src/app/app/_components/ShareMenu/ShareMenu.tsx index 976d11340..9aa703cbe 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenu.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenu.tsx @@ -5,17 +5,16 @@ import { PopoverProps } from 'antd'; import { AppPopover } from '@/components/tooltip/AppPopover'; import { AppTooltip } from '@/components'; import { useMemoizedFn } from 'ahooks'; -import { BusterShareAssetType } from '@/api/buster_rest/users'; -import { BusterShare, ShareRole } from '@/api/buster_socket/chats'; +import { BusterShare, ShareAssetType, ShareRole } from '@/api/asset_interfaces'; import { ShareMenuContent } from './ShareMenuContent'; export const ShareMenu: React.FC< PropsWithChildren<{ placement?: PopoverProps['placement']; shareAssetConfig: BusterShare; - shareType: BusterShareAssetType; + shareType: ShareAssetType; assetId: string; - assetType: BusterShareAssetType; + assetType: ShareAssetType; }> > = ({ children, shareAssetConfig, shareType, assetId, assetType, placement = 'bottomLeft' }) => { const [isOpen, setIsOpen] = React.useState(false); diff --git a/web/src/app/app/_components/ShareMenu/ShareMenuContent.tsx b/web/src/app/app/_components/ShareMenu/ShareMenuContent.tsx index b41663fab..abfa9b6d0 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenuContent.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenuContent.tsx @@ -1,5 +1,4 @@ -import { BusterShareAssetType } from '@/api/buster_rest/users'; -import { BusterShare, ShareRole } from '@/api/buster_socket/chats'; +import { BusterShare, ShareRole, ShareAssetType } from '@/api/asset_interfaces'; import { useBusterNotifications } from '@/context/BusterNotifications'; import React from 'react'; import { ShareMenuTopBar, ShareMenuTopBarOptions } from './ShareMenuTopBar'; @@ -11,8 +10,8 @@ import { ShareMenuContentBody } from './ShareMenuContentBody'; export const ShareMenuContent: React.FC<{ shareAssetConfig: BusterShare; assetId: string; - assetType: BusterShareAssetType; - shareType: BusterShareAssetType; + assetType: ShareAssetType; + shareType: ShareAssetType; permission: ShareRole; }> = React.memo(({ assetId, assetType, shareAssetConfig, shareType, permission }) => { const { openSuccessMessage } = useBusterNotifications(); @@ -26,14 +25,14 @@ export const ShareMenuContent: React.FC<{ const onCopyLink = useMemoizedFn(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD && assetId) { + if (shareType === ShareAssetType.METRIC && assetId) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: assetId }); - } else if (shareType === BusterShareAssetType.DASHBOARD && assetId) { + } else if (shareType === ShareAssetType.DASHBOARD && assetId) { url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId }); - } else if (shareType === BusterShareAssetType.COLLECTION && assetId) { + } else if (shareType === ShareAssetType.COLLECTION && assetId) { url = createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: assetId diff --git a/web/src/app/app/_components/ShareMenu/ShareMenuContentBody.tsx b/web/src/app/app/_components/ShareMenu/ShareMenuContentBody.tsx index 3306fdfea..5243b1f0e 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenuContentBody.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenuContentBody.tsx @@ -1,6 +1,6 @@ -import { BusterShare, ShareRole } from '@/api/buster_socket/chats'; +import { BusterShare, ShareRole } from '@/api/asset_interfaces'; import { ShareMenuTopBarOptions } from './ShareMenuTopBar'; -import { BusterShareAssetType } from '@/api/buster_rest/users'; +import { ShareAssetType } from '@/api/asset_interfaces'; import React from 'react'; import { ShareMenuContentPublish } from './ShareMenuContentPublish'; import { ShareMenuContentEmbed } from './ShareMenuContentEmbed'; @@ -26,9 +26,9 @@ export const ShareMenuContentBody: React.FC<{ goBack: () => void; onCopyLink: () => void; shareAssetConfig: BusterShare; - shareType: BusterShareAssetType; + shareType: ShareAssetType; assetId: string; - assetType: BusterShareAssetType; + assetType: ShareAssetType; }> = React.memo( ({ shareType, diff --git a/web/src/app/app/_components/ShareMenu/ShareMenuContentEmbed.tsx b/web/src/app/app/_components/ShareMenu/ShareMenuContentEmbed.tsx index 3163f1dad..17c986d63 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenuContentEmbed.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenuContentEmbed.tsx @@ -1,4 +1,4 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { AppMaterialIcons } from '@/components'; import { useCollectionsContextSelector } from '@/context/Collections'; import { useDashboardContextSelector } from '@/context/Dashboards'; @@ -15,7 +15,7 @@ export const ShareMenuContentEmbed: React.FC<{ publicExpirationDate: string; publicly_accessible: boolean; password: string | null; - shareType: BusterShareAssetType; + shareType: ShareAssetType; threadId?: string; dashboardId?: string; collectionId?: string; @@ -40,21 +40,21 @@ export const ShareMenuContentEmbed: React.FC<{ const embedURL = useMemo(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: id }); } - if (shareType === BusterShareAssetType.DASHBOARD) { + if (shareType === ShareAssetType.DASHBOARD) { url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: id }); } - if (shareType === BusterShareAssetType.COLLECTION) { + if (shareType === ShareAssetType.COLLECTION) { url = createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: id @@ -76,7 +76,7 @@ export const ShareMenuContentEmbed: React.FC<{ publicly_accessible: true }; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread(payload); } else if (shareType === 'dashboard') { await onShareDashboard(payload); diff --git a/web/src/app/app/_components/ShareMenu/ShareMenuContentPublish.tsx b/web/src/app/app/_components/ShareMenu/ShareMenuContentPublish.tsx index 62f63bf72..33562ba8f 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenuContentPublish.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenuContentPublish.tsx @@ -10,7 +10,7 @@ import { useDashboardContextSelector } from '@/context/Dashboards'; import { useBusterThreadsContextSelector } from '@/context/Threads'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { useCollectionsContextSelector } from '@/context/Collections'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { Text } from '@/components'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { Dayjs } from 'dayjs'; @@ -20,7 +20,7 @@ export const ShareMenuContentPublish: React.FC<{ publicExpirationDate: string; publicly_accessible: boolean; password: string | null; - shareType: BusterShareAssetType; + shareType: ShareAssetType; threadId?: string; dashboardId?: string; collectionId?: string; @@ -51,7 +51,7 @@ export const ShareMenuContentPublish: React.FC<{ const url = useMemo(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: id }); } else if (shareType === 'dashboard') { url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: id }); @@ -70,7 +70,7 @@ export const ShareMenuContentPublish: React.FC<{ public_password: _password || null, public_expiry_date: linkExp }; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread(payload); } else if (shareType === 'dashboard') { await onShareDashboard(payload); @@ -83,7 +83,7 @@ export const ShareMenuContentPublish: React.FC<{ const onSetPasswordProtected = useMemoizedFn(async (v: boolean) => { if (!v) { - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_password: null }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_password: null }); @@ -96,7 +96,7 @@ export const ShareMenuContentPublish: React.FC<{ }); const onSetPassword = useMemoizedFn(async (password: string | null) => { - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_password: password }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_password: password }); @@ -109,7 +109,7 @@ export const ShareMenuContentPublish: React.FC<{ const onSetExpirationDate = useMemoizedFn(async (date: Date | null) => { const linkExp = date ? date.toISOString() : null; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_expiry_date: linkExp }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_expiry_date: linkExp }); diff --git a/web/src/app/app/_components/ShareMenu/ShareMenuTopBar.tsx b/web/src/app/app/_components/ShareMenu/ShareMenuTopBar.tsx index 4e210384a..1e841dd2b 100644 --- a/web/src/app/app/_components/ShareMenu/ShareMenuTopBar.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareMenuTopBar.tsx @@ -1,7 +1,7 @@ import { AppSegmented, AppSegmentedProps } from '@/components'; import React, { useMemo } from 'react'; import { CopyLinkButton } from './CopyLinkButton'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { ShareRole } from '@/api/buster_socket/threads'; import { useMemoizedFn } from 'ahooks'; import { SegmentedValue } from 'antd/es/segmented'; @@ -17,7 +17,7 @@ export const ShareMenuTopBar: React.FC<{ selectedOptions: ShareMenuTopBarOptions; onChangeSelectedOption: (option: ShareMenuTopBarOptions) => void; onCopyLink: () => void; - shareType: BusterShareAssetType; + shareType: ShareAssetType; permission: ShareRole; }> = React.memo( ({ shareType, onCopyLink, selectedOptions, onChangeSelectedOption, permission }) => { @@ -33,12 +33,12 @@ export const ShareMenuTopBar: React.FC<{ { value: ShareMenuTopBarOptions.Publish, label: 'Publish', - show: shareType !== BusterShareAssetType.COLLECTION && isOwner + show: shareType !== ShareAssetType.COLLECTION && isOwner }, { value: ShareMenuTopBarOptions.Embed, label: 'Embed', - show: shareType !== BusterShareAssetType.COLLECTION + show: shareType !== ShareAssetType.COLLECTION } ] .filter((o) => o.show) diff --git a/web/src/app/app/_components/ShareMenu/ShareWithTeamAndGroup.tsx b/web/src/app/app/_components/ShareMenu/ShareWithTeamAndGroup.tsx index 987d26605..da8d0ad98 100644 --- a/web/src/app/app/_components/ShareMenu/ShareWithTeamAndGroup.tsx +++ b/web/src/app/app/_components/ShareMenu/ShareWithTeamAndGroup.tsx @@ -12,11 +12,12 @@ import { ShareRequest } from '@/api/buster_socket/dashboards'; import { useMemoizedFn } from 'ahooks'; import { useCollectionsContextSelector, useIndividualCollection } from '@/context/Collections'; import { Text } from '@/components'; +import { ShareAssetType } from '@/api/asset_interfaces'; export const ShareWithGroupAndTeam: React.FC<{ goBack: () => void; onCopyLink: () => void; - shareType: 'thread' | 'dashboard' | 'collection'; + shareType: ShareAssetType; threadId?: string; dashboardId?: string; collectionId?: string; @@ -34,7 +35,7 @@ export const ShareWithGroupAndTeam: React.FC<{ const { collection } = useIndividualCollection({ collectionId }); const thread = useMemo( - () => (shareType === 'thread' && threadId ? getThread({ threadId }) : null), + () => (shareType === 'metric' && threadId ? getThread({ threadId }) : null), [shareType, threadId] ); @@ -47,7 +48,7 @@ export const ShareWithGroupAndTeam: React.FC<{ } else { payload.team_permissions = [{ team_id: teamId, role }]; } - if (shareType === 'thread') { + if (shareType === 'metric') { await onShareThread(payload); } else if (shareType === 'dashboard') { await onShareDashboard(payload); @@ -59,7 +60,7 @@ export const ShareWithGroupAndTeam: React.FC<{ const listedTeam: { id: string; name: string; role: ShareRole | null }[] = useMemo(() => { const assosciatedPermissiongSearch = (teamId: string) => { - if (shareType === 'thread' && thread) { + if (shareType === 'metric' && thread) { return thread.team_permissions?.find((t) => t.id === teamId); } else if (shareType === 'dashboard' && dashboardResponse) { return dashboardResponse.team_permissions?.find((t) => t.id === teamId); diff --git a/web/src/app/app/_components/ShareMenu_old/ShareMenu.tsx b/web/src/app/app/_components/ShareMenu_old/ShareMenu.tsx index a718478a3..96c77c92e 100644 --- a/web/src/app/app/_components/ShareMenu_old/ShareMenu.tsx +++ b/web/src/app/app/_components/ShareMenu_old/ShareMenu.tsx @@ -13,14 +13,18 @@ import { useStyles } from './useStyles'; import { IndividualSharePerson } from './IndividualSharePerson'; import { ShareMenuContentPublish } from './ShareMenuContentPublish'; import { ShareMenuContentEmbed } from './ShareMenuContentEmbed'; -import { IBusterThread } from '@/context/Threads/interfaces'; +import type { IBusterThread } from '@/context/Threads/interfaces'; import { BusterRoutes, createBusterRoute } from '@/routes'; -import { BusterDashboardResponse, BusterShare, BusterShareAssetType } from '@/api/buster_rest'; +import { + BusterCollection, + BusterDashboardResponse, + BusterShare, + ShareAssetType +} from '@/api/asset_interfaces'; import { useBusterThreadsContextSelector } from '@/context/Threads'; import { AccessDropdown } from './AccessDropdown'; import { ShareRole } from '@/api/buster_socket/threads'; import { ShareRequest } from '@/api/buster_socket/dashboards'; -import { BusterCollection } from '@/api/buster_rest/collection'; import { useCollectionsContextSelector } from '@/context/Collections'; import { Text } from '@/components'; import { useDashboardContextSelector } from '@/context/Dashboards'; @@ -33,7 +37,7 @@ export const ShareMenu: React.FC< thread?: IBusterThread; dashboardResponse?: BusterDashboardResponse; collection?: BusterCollection; - shareType: BusterShareAssetType; + shareType: ShareAssetType; }> > = ({ children, dashboardResponse, collection, thread, shareType, placement = 'bottomLeft' }) => { const [isOpen, setIsOpen] = React.useState(false); @@ -79,7 +83,7 @@ const ShareMenuContent: React.FC<{ thread?: IBusterThread; dashboardResponse?: BusterDashboardResponse; collection?: BusterCollection; - shareType: BusterShareAssetType; + shareType: ShareAssetType; permission: ShareRole; }> = React.memo(({ collection, thread, dashboardResponse, shareType, permission }) => { const { openSuccessMessage } = useBusterNotifications(); @@ -94,7 +98,7 @@ const ShareMenuContent: React.FC<{ const onCopyLink = useMemoizedFn(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD && thread) { + if (shareType === ShareAssetType.METRIC && thread) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: thread.id }); } else if (shareType === 'dashboard' && dashboardResponse) { url = createBusterRoute({ @@ -163,7 +167,7 @@ const ShareMenuContentBody: React.FC<{ thread?: IBusterThread; dashboardResponse?: BusterDashboardResponse; collection?: BusterCollection; - shareType: BusterShareAssetType; + shareType: ShareAssetType; }> = React.memo( ({ shareType, diff --git a/web/src/app/app/_components/ShareMenu_old/ShareMenuContentEmbed.tsx b/web/src/app/app/_components/ShareMenu_old/ShareMenuContentEmbed.tsx index 3163f1dad..17c986d63 100644 --- a/web/src/app/app/_components/ShareMenu_old/ShareMenuContentEmbed.tsx +++ b/web/src/app/app/_components/ShareMenu_old/ShareMenuContentEmbed.tsx @@ -1,4 +1,4 @@ -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { AppMaterialIcons } from '@/components'; import { useCollectionsContextSelector } from '@/context/Collections'; import { useDashboardContextSelector } from '@/context/Dashboards'; @@ -15,7 +15,7 @@ export const ShareMenuContentEmbed: React.FC<{ publicExpirationDate: string; publicly_accessible: boolean; password: string | null; - shareType: BusterShareAssetType; + shareType: ShareAssetType; threadId?: string; dashboardId?: string; collectionId?: string; @@ -40,21 +40,21 @@ export const ShareMenuContentEmbed: React.FC<{ const embedURL = useMemo(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: id }); } - if (shareType === BusterShareAssetType.DASHBOARD) { + if (shareType === ShareAssetType.DASHBOARD) { url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: id }); } - if (shareType === BusterShareAssetType.COLLECTION) { + if (shareType === ShareAssetType.COLLECTION) { url = createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: id @@ -76,7 +76,7 @@ export const ShareMenuContentEmbed: React.FC<{ publicly_accessible: true }; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread(payload); } else if (shareType === 'dashboard') { await onShareDashboard(payload); diff --git a/web/src/app/app/_components/ShareMenu_old/ShareMenuContentPublish.tsx b/web/src/app/app/_components/ShareMenu_old/ShareMenuContentPublish.tsx index 62f63bf72..33562ba8f 100644 --- a/web/src/app/app/_components/ShareMenu_old/ShareMenuContentPublish.tsx +++ b/web/src/app/app/_components/ShareMenu_old/ShareMenuContentPublish.tsx @@ -10,7 +10,7 @@ import { useDashboardContextSelector } from '@/context/Dashboards'; import { useBusterThreadsContextSelector } from '@/context/Threads'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { useCollectionsContextSelector } from '@/context/Collections'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { Text } from '@/components'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { Dayjs } from 'dayjs'; @@ -20,7 +20,7 @@ export const ShareMenuContentPublish: React.FC<{ publicExpirationDate: string; publicly_accessible: boolean; password: string | null; - shareType: BusterShareAssetType; + shareType: ShareAssetType; threadId?: string; dashboardId?: string; collectionId?: string; @@ -51,7 +51,7 @@ export const ShareMenuContentPublish: React.FC<{ const url = useMemo(() => { let url = ''; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { url = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: id }); } else if (shareType === 'dashboard') { url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: id }); @@ -70,7 +70,7 @@ export const ShareMenuContentPublish: React.FC<{ public_password: _password || null, public_expiry_date: linkExp }; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread(payload); } else if (shareType === 'dashboard') { await onShareDashboard(payload); @@ -83,7 +83,7 @@ export const ShareMenuContentPublish: React.FC<{ const onSetPasswordProtected = useMemoizedFn(async (v: boolean) => { if (!v) { - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_password: null }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_password: null }); @@ -96,7 +96,7 @@ export const ShareMenuContentPublish: React.FC<{ }); const onSetPassword = useMemoizedFn(async (password: string | null) => { - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_password: password }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_password: password }); @@ -109,7 +109,7 @@ export const ShareMenuContentPublish: React.FC<{ const onSetExpirationDate = useMemoizedFn(async (date: Date | null) => { const linkExp = date ? date.toISOString() : null; - if (shareType === BusterShareAssetType.THREAD) { + if (shareType === ShareAssetType.METRIC) { await onShareThread({ id, public_expiry_date: linkExp }); } else if (shareType === 'dashboard') { await onShareDashboard({ id, public_expiry_date: linkExp }); diff --git a/web/src/app/app/_components/ShareMenu_old/ShareMenuTopBar.tsx b/web/src/app/app/_components/ShareMenu_old/ShareMenuTopBar.tsx index 4e210384a..1e841dd2b 100644 --- a/web/src/app/app/_components/ShareMenu_old/ShareMenuTopBar.tsx +++ b/web/src/app/app/_components/ShareMenu_old/ShareMenuTopBar.tsx @@ -1,7 +1,7 @@ import { AppSegmented, AppSegmentedProps } from '@/components'; import React, { useMemo } from 'react'; import { CopyLinkButton } from './CopyLinkButton'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { ShareRole } from '@/api/buster_socket/threads'; import { useMemoizedFn } from 'ahooks'; import { SegmentedValue } from 'antd/es/segmented'; @@ -17,7 +17,7 @@ export const ShareMenuTopBar: React.FC<{ selectedOptions: ShareMenuTopBarOptions; onChangeSelectedOption: (option: ShareMenuTopBarOptions) => void; onCopyLink: () => void; - shareType: BusterShareAssetType; + shareType: ShareAssetType; permission: ShareRole; }> = React.memo( ({ shareType, onCopyLink, selectedOptions, onChangeSelectedOption, permission }) => { @@ -33,12 +33,12 @@ export const ShareMenuTopBar: React.FC<{ { value: ShareMenuTopBarOptions.Publish, label: 'Publish', - show: shareType !== BusterShareAssetType.COLLECTION && isOwner + show: shareType !== ShareAssetType.COLLECTION && isOwner }, { value: ShareMenuTopBarOptions.Embed, label: 'Embed', - show: shareType !== BusterShareAssetType.COLLECTION + show: shareType !== ShareAssetType.COLLECTION } ] .filter((o) => o.show) diff --git a/web/src/app/app/_controllers/AppNoPageAccess.tsx b/web/src/app/app/_controllers/AppNoPageAccess.tsx index 95b9d6ef4..47e0aa532 100644 --- a/web/src/app/app/_controllers/AppNoPageAccess.tsx +++ b/web/src/app/app/_controllers/AppNoPageAccess.tsx @@ -1,6 +1,6 @@ 'use client'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { asset_typeToTranslation } from '@/app/_helpers'; import { BusterLogo } from '@/assets/svg/BusterLogo'; import { Title } from '@/components/text'; @@ -12,7 +12,7 @@ import Link from 'next/link'; import React from 'react'; export const AppNoPageAccess: React.FC<{ - asset_type: BusterShareAssetType; + asset_type: ShareAssetType; threadId?: string; dashboardId?: string; }> = React.memo(({ asset_type, threadId, dashboardId }) => { diff --git a/web/src/app/app/_controllers/AppPasswordAccess.tsx b/web/src/app/app/_controllers/AppPasswordAccess.tsx index 50a46b6e3..8da632537 100644 --- a/web/src/app/app/_controllers/AppPasswordAccess.tsx +++ b/web/src/app/app/_controllers/AppPasswordAccess.tsx @@ -5,7 +5,7 @@ import React, { useRef } from 'react'; import { Title } from '@/components/text'; import { Button, Input, InputRef, Typography } from 'antd'; import { LoginConfigProvider } from '@/app/auth/login/_components/LoginConfigProvider'; -import type { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { useBusterAssetsContextSelector } from '@/context/Assets/BusterAssetsProvider'; import { useMemoizedFn } from 'ahooks'; @@ -14,7 +14,7 @@ const { Text } = Typography; export const AppPasswordAccess: React.FC<{ threadId?: string; dashboardId?: string; - type: BusterShareAssetType; + type: ShareAssetType; children: React.ReactNode; }> = React.memo(({ children, threadId, dashboardId, type }) => { const getAssetPassword = useBusterAssetsContextSelector((state) => state.getAssetPassword); diff --git a/web/src/app/app/_controllers/AppSidebar/FavoritesDropdown.tsx b/web/src/app/app/_controllers/AppSidebar/FavoritesDropdown.tsx index 262f11dd6..ce457ce3f 100644 --- a/web/src/app/app/_controllers/AppSidebar/FavoritesDropdown.tsx +++ b/web/src/app/app/_controllers/AppSidebar/FavoritesDropdown.tsx @@ -1,4 +1,5 @@ -import { BusterShareAssetType, BusterUserFavorite } from '@/api/buster_rest'; +import type { BusterUserFavorite } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { AppMenuGroupSingleSortable } from '@/components/menu'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { useUserConfigContextSelector } from '@/context/Users'; @@ -112,7 +113,7 @@ const createListItem = ({ }); let name = item.name || item.collection_name; - if (item.type === BusterShareAssetType.THREAD) { + if (item.type === ShareAssetType.METRIC) { link = createBusterRoute({ route: BusterRoutes.APP_THREAD_ID, threadId: item.id diff --git a/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/SaveToDashboardButton.tsx b/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/SaveToDashboardButton.tsx index 5dac91b71..e12245b48 100644 --- a/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/SaveToDashboardButton.tsx +++ b/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/SaveToDashboardButton.tsx @@ -1,11 +1,11 @@ -import { BusterDashboardListItem } from '@/api/buster_rest'; +import { BusterDashboardListItem } from '@/api/asset_interfaces'; import { AppMaterialIcons, AppTooltip } from '@/components'; import { AppDropdownSelect } from '@/components/dropdown'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { useDashboardContextSelector } from '@/context/Dashboards'; import { useBusterThreadsContextSelector } from '@/context/Threads'; import { IBusterThread } from '@/context/Threads/interfaces'; -import { BusterRootRoutes, BusterRoutes, createBusterRoute } from '@/routes'; +import { BusterRoutes, createBusterRoute } from '@/routes'; import { useMemoizedFn, useMount, useUnmount } from 'ahooks'; import { Button } from 'antd'; import React, { useEffect, useMemo } from 'react'; diff --git a/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/ThreadControllerHeaderPrimary.tsx b/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/ThreadControllerHeaderPrimary.tsx index a86881509..56342c0fa 100644 --- a/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/ThreadControllerHeaderPrimary.tsx +++ b/web/src/app/app/_controllers/ThreadController/ThreadControllerHeader/ThreadControllerHeaderPrimary.tsx @@ -22,7 +22,7 @@ import { PreventNavigation } from '@/components'; import { useUserConfigContextSelector } from '@/context/Users'; -import { BusterShareAssetType } from '@/api/buster_rest'; +import { ShareAssetType } from '@/api/asset_interfaces'; import { useMemoizedFn, useMount } from 'ahooks'; import { BusterMessageData, IBusterThreadMessage } from '@/context/Threads/interfaces'; import { useDisableSaveChanges } from './useDisableSaveChanges'; @@ -150,7 +150,7 @@ export const ThreadControllerHeaderPrimary: React.FC<{ /> @@ -197,7 +197,7 @@ export const ThreadControllerHeaderPrimary: React.FC<{ disabled={disableButtons} /> - +