Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
bfcd24b
feat(project-route): add project dashboard create route & apply route…
piggggggggy Apr 9, 2025
2c13d52
fix(dashboard-shared): separate shared dashboard form dashboards serv…
piggggggggy Apr 9, 2025
bfe8d58
fix(dashboard-create-page): apply dashboard-shared
piggggggggy Apr 9, 2025
40f9590
chore: apply change model to dashboard schema
piggggggggy Apr 9, 2025
ae031dd
fix(dashboard-shared): apply project entry context to create step2
piggggggggy Apr 9, 2025
5e93382
feat(dashboard-shared): separate dashboard detail from dashboard deta…
piggggggggy Apr 9, 2025
3aa9648
feat(dashboard-shared): remove dashboards service context from dashbo…
piggggggggy Apr 9, 2025
df84c90
feat(dashboard-shared): separate dashboard shared component from dash…
piggggggggy Apr 9, 2025
df37d4e
feat(project-dashboard-create): create page & project dashboard query…
piggggggggy Apr 9, 2025
77d52a5
feat(project-dashboard-tab): create dashboard create button & apply p…
piggggggggy Apr 9, 2025
730bdcd
feat(project-dashboard): create project detail/create components
piggggggggy Apr 9, 2025
7edd0df
chore: small fix
piggggggggy Apr 9, 2025
7fd1c5e
chore: fix wrong query (dashboard list)
piggggggggy Apr 9, 2025
a8aacef
fix(dashboard-manageable): refactoring with changed sharing policy
piggggggggy Apr 9, 2025
2a78f12
chore: small fix
piggggggggy Apr 9, 2025
aafb52e
chore: solve lint error
piggggggggy Apr 10, 2025
1340045
chore: add optional chaining
piggggggggy Apr 10, 2025
9433adf
chore: solve widget load bug
piggggggggy Apr 10, 2025
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
@@ -1,5 +1,5 @@
// Base Model
import type { GLOBAL_VARIABLE_FILTER_TYPE_MAP } from '@/services/dashboards/constants/dashboard-global-variable';
import type { GLOBAL_VARIABLE_FILTER_TYPE_MAP } from '@/services/dashboard-shared/dashboard-detail/constants/dashboard-global-variable';

interface DashboardGlobalVariableBase {
key: string; // new_variable
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/api-clients/dashboard/_types/dashboard-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@ import type { PrivateDashboardGetParameters } from '@/api-clients/dashboard/priv
import type { PrivateDashboardListParameters } from '@/api-clients/dashboard/private-dashboard/schema/api-verbs/list';
import type { PrivateDashboardUpdateParameters } from '@/api-clients/dashboard/private-dashboard/schema/api-verbs/update';
import type { PrivateDashboardModel } from '@/api-clients/dashboard/private-dashboard/schema/model';
import type { PrivateFolderModel } from '@/api-clients/dashboard/private-folder/schema/model';
import type { PublicDashboardChangeFolderParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/change-folder';
import type { PublicDashboardCreateParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/create';
import type { PublicDashboardDeleteParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/delete';
import type { PublicDashboardGetParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/get';
import type { PublicDashboardListParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/list';
import type { PublicDashboardUpdateParameters } from '@/api-clients/dashboard/public-dashboard/schema/api-verbs/update';
import type { PublicDashboardModel } from '@/api-clients/dashboard/public-dashboard/schema/model';
import type { PublicFolderModel } from '@/api-clients/dashboard/public-folder/schema/model';

import type { VariableModelType } from '@/lib/variable-models';
import type { Value } from '@/lib/variable-models/_base/types';


export type DashboardType = typeof DASHBOARD_TYPE[keyof typeof DASHBOARD_TYPE];
export type DashboardFolderType = 'PUBLIC'|'PRIVATE';

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
export type DashboardModel = PublicDashboardModel | PrivateDashboardModel;
export type DashboardFolderModel = PublicFolderModel | PrivateFolderModel;
export type DashboardCreateParams = PublicDashboardCreateParameters | PrivateDashboardCreateParameters;
export type DashboardChangeFolderParams = PublicDashboardChangeFolderParameters | PrivateDashboardChangeFolderParameters;
export type DashboardListParams = PublicDashboardListParameters | PrivateDashboardListParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export interface PublicDashboardCreateParameters {
workspace_id?: string;
resource_group: Extract<ResourceGroupType, 'DOMAIN'|'WORKSPACE'|'PROJECT'>;
project_id?: string;
project_group_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface PublicDashboardListParameters {
name?: string;
workspace_id?: string;
project_id?: string;
project_group_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface PublicDashboardModel {
folder_id: string;
resource_group: Extract<ResourceGroupType, 'DOMAIN'|'WORKSPACE'|'PROJECT'>;
project_id: string;
project_group_id: string;
workspace_id: string;
domain_id: string;
created_at: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface PublicFolderCreateParameters {
dashboards?: string[];
workspace_id?: string;
project_id?: string;
project_group_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface PublicFolderListParameters {
name?: string;
workspace_id?: string;
project_id?: string;
project_group_id?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface PublicFolderModel {
tags: Tags;
resource_group: Extract<ResourceGroupType, 'DOMAIN'|'WORKSPACE'|'PROJECT'>;
project_id: string;
project_group_id: string;
workspace_id: string;
domain_id: string;
created_at: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import type {
DataTableDataType, DataTableSourceType, DataTableOperator, DataTableAddOptions, DataTableTransformOptions,
} from '@/common/modules/widgets/types/widget-model';

import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardWidgetListQuery } from '@/services/dashboards/shared/composables/use-dashboard-widget-list-query';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';
import { useDashboardWidgetListQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-widget-list-query';

const widgetGenerateStore = useWidgetGenerateStore();
const widgetGenerateState = widgetGenerateStore.state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import type { DataTableQueryFilterForDropdown } from '@/common/modules/widgets/t

import { blue, gray } from '@/styles/colors';

import { getOrderedGlobalVariables } from '@/services/dashboards/helpers/dashboard-global-variables-helper';
import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';
import { getOrderedGlobalVariables } from '@/services/dashboard-shared/dashboard-detail/helpers/dashboard-global-variables-helper';


interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import type {
JoinOptions, ValueMappingOptions, ConcatOptions, AggregateOptions, AggregateFunction,
} from '@/common/modules/widgets/types/widget-model';

import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { PButton, PPopover, PCopyButton } from '@cloudforet/mirinae';

import type { DashboardGlobalVariable } from '@/api-clients/dashboard/_types/dashboard-global-variable-type';

import { getOrderedGlobalVariables } from '@/services/dashboards/helpers/dashboard-global-variables-helper';
import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';
import { getOrderedGlobalVariables } from '@/services/dashboard-shared/dashboard-detail/helpers/dashboard-global-variables-helper';

const route = useRoute();
const dashboardId = computed(() => route.params.dashboardId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { gray, white } from '@/styles/colors';
import { SIZE_UNITS } from '@/services/asset-inventory/constants/asset-analysis-constant';
import { GRANULARITY } from '@/services/cost-explorer/constants/cost-explorer-constant';
import type { Granularity } from '@/services/cost-explorer/types/cost-explorer-query-type';
import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import WidgetFieldValueManager from '@/common/modules/widgets/_widget-field-valu
import type { DataTableModel } from '@/common/modules/widgets/types/widget-data-table-type';
import type { WidgetType } from '@/common/modules/widgets/types/widget-model';

import DashboardToolsetDateDropdown from '@/services/dashboards/shared/components/DashboardToolsetDateDropdown.vue';
import DashboardVariablesV2 from '@/services/dashboards/shared/components/DashboardVariablesV2.vue';
import { useDashboardGetQuery } from '@/services/dashboards/shared/composables/use-dashboard-get-query';
import { useDashboardWidgetListQuery } from '@/services/dashboards/shared/composables/use-dashboard-widget-list-query';
import { useDashboardDetailInfoStore } from '@/services/dashboards/shared/stores/dashboard-detail-info-store';
import DashboardToolsetDateDropdown from '@/services/dashboard-shared/dashboard-detail/components/DashboardToolsetDateDropdown.vue';
import DashboardVariablesV2 from '@/services/dashboard-shared/dashboard-detail/components/DashboardVariablesV2.vue';
import { useDashboardGetQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-get-query';
import { useDashboardWidgetListQuery } from '@/services/dashboard-shared/dashboard-detail/composables/use-dashboard-widget-list-query';
import { useDashboardDetailInfoStore } from '@/services/dashboard-shared/dashboard-detail/stores/dashboard-detail-info-store';
import type { AllReferenceTypeInfo } from '@/services/dashboards/stores/all-reference-type-info-store';
import {
useAllReferenceTypeInfoStore,
Expand Down Expand Up @@ -318,6 +318,7 @@ onUnmounted(() => {
/>
<dashboard-variables-v2 disable-save-button
widget-mode
:dashboard-id="dashboardId"
:is-project-dashboard="!!dashboard?.project_id"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { computed } from 'vue';

import { useScopedQuery } from '@/api-clients/_common/composables/use-scoped-query';
import { usePrivateDataTableApi } from '@/api-clients/dashboard/private-data-table/composables/use-private-data-table-api';
import type { DataTableGetParameters } from '@/api-clients/dashboard/private-data-table/schema/api-verbs/get';
import { usePublicDataTableApi } from '@/api-clients/dashboard/public-data-table/composables/use-public-data-table-api';
import { useServiceQueryKey } from '@/query/query-key/use-service-query-key';

Expand All @@ -15,28 +14,25 @@ export const useWidgetDataTableQuery = (dataTableId: ComputedRef<string|undefine
const { publicDataTableAPI } = usePublicDataTableApi();
const { privateDataTableAPI } = usePrivateDataTableApi();

const isPrivate = computed(() => {
if (!dataTableId.value) return false;
return dataTableId.value.startsWith('private');
});
const isPrivate = computed(() => dataTableId.value?.startsWith('private'));

const { key: publicKey, params: publicParams } = useServiceQueryKey('dashboard', 'public-data-table', 'get', {
contextKey: dataTableId,
params: {
data_table_id: dataTableId.value,
} as DataTableGetParameters,
params: computed(() => ({
data_table_id: dataTableId.value as string,
})),
});
const { key: privateKey, params: privateParams } = useServiceQueryKey('dashboard', 'private-data-table', 'get', {
contextKey: dataTableId,
params: {
data_table_id: dataTableId.value,
} as DataTableGetParameters,
params: computed(() => ({
data_table_id: dataTableId.value as string,
})),
});

const privateDataTableQuery = useScopedQuery({
queryKey: privateKey,
queryFn: () => {
if (!dataTableId.value) {
if (!privateParams.value.data_table_id) {
throw new Error('DataTable ID is required for fetching data');
}
return privateDataTableAPI.get(privateParams.value);
Expand All @@ -48,7 +44,7 @@ export const useWidgetDataTableQuery = (dataTableId: ComputedRef<string|undefine
const publicDataTableQuery = useScopedQuery({
queryKey: publicKey,
queryFn: () => {
if (!dataTableId.value) {
if (!publicParams.value.data_table_id) {
throw new Error('DataTable ID is required for fetching data');
}
return publicDataTableAPI.get(publicParams.value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { range } from 'lodash';
import { describe, it, expect } from 'vitest';

import { getRefinedXYChartData } from '@/services/dashboards/widgets/_helpers/widget-chart-data-helper';
import { getRefinedXYChartData } from '@/services/dashboard-shared/dashboard-detail/legacy/widgets/_helpers/widget-chart-data-helper';

interface SubData {
date: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { InheritOptions, WidgetConfig, WidgetOptionsSchema } from '@/api-cl
import {
getInheritingOptionKeys,
getInitialWidgetInheritOptions,
} from '@/services/dashboards/widgets/_helpers/widget-inherit-options-helper';
} from '@/services/dashboard-shared/dashboard-detail/legacy/widgets/_helpers/widget-inherit-options-helper';



Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { WidgetFilterKey, WidgetFiltersMap } from '@/api-clients/dashboard/_types/widget-type';

import { setFilterAndGetWidgetFiltersMap } from '@/services/dashboards/widgets/_helpers/widget-options-filters-helper';
import { setFilterAndGetWidgetFiltersMap } from '@/services/dashboard-shared/dashboard-detail/legacy/widgets/_helpers/widget-options-filters-helper';


describe('[Widget Options Filters Helper] setFilterAndGetWidgetFiltersMap', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { InheritOptions, WidgetConfig, WidgetOptions } from '@/api-clients/
import {
getInitialSchemaProperties, getNonInheritedWidgetOptionNamesAmongUsedVariables,
getRefinedSchemaProperties, getWidgetOptionKeyByVariableKey,
} from '@/services/dashboards/widgets/_helpers/widget-schema-helper';
} from '@/services/dashboard-shared/dashboard-detail/legacy/widgets/_helpers/widget-schema-helper';

const DEFAULT_WIDGET_CONFIG = {
widget_config_id: 'test',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe } from 'vitest';

import { getWidgetValueLabel } from '@/services/dashboard-shared/dashboard-detail/legacy/widgets/_helpers/widget-value-label-helper';
import type { AllReferenceTypeInfo } from '@/services/dashboards/stores/all-reference-type-info-store';
import { getWidgetValueLabel } from '@/services/dashboards/widgets/_helpers/widget-value-label-helper';

const mockAllReferenceTypeInfo: AllReferenceTypeInfo = {
provider: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type {
WidgetFieldComponentProps,
} from '@/common/modules/widgets/types/widget-field-type';

import { useDashboardDetailInfoStore } from '@/services/dashboards/shared/stores/dashboard-detail-info-store';
import { useDashboardDetailInfoStore } from '@/services/dashboard-shared/dashboard-detail/stores/dashboard-detail-info-store';

const GRANULARITY_UNIT_MAP = {
MONTHLY: { singular: 'Month', plural: 'Months' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// composables/useDashboardRouteContext.ts
import { computed } from 'vue';
import { useRoute } from 'vue-router/composables';

import { useAppContextStore } from '@/store/app-context/app-context-store';

import { MENU_ID } from '@/lib/menu/config';

type EntryPoint = 'ADMIN' | 'WORKSPACE' | 'PROJECT' | 'UNKNOWN';
type ProjectContextType = 'PROJECT' | 'PROJECT_GROUP' | undefined;

/**
* Provides contextual information about the current dashboard route.
*
* - `entryPoint` tells where this dashboard page is accessed from.
* - If `entryPoint === 'PROJECT'`, then `projectGroupOrProjectId` and `projectContextType` will be available.
* (Business logic guarantees this, though they are optional in the type system.)
* - Use `entryPoint === 'PROJECT'` check before using project-specific fields.
*/
export const useDashboardRouteContext = () => {
const route = useRoute();
const appContextStore = useAppContextStore();

const isAdminMode = computed(() => appContextStore.getters.isAdminMode);

const entryPoint = computed<EntryPoint>(() => {
// Global admin mode overrides route-level checks
if (isAdminMode.value) return 'ADMIN';

// Project dashboard route (nested under project-level menu)
if (route.matched.some((m) => m.meta.menuId === MENU_ID.PROJECT)) return 'PROJECT';
if (route.matched.some((m) => m.meta.menuId === MENU_ID.DASHBOARDS)) return 'WORKSPACE';
return 'UNKNOWN';
});

const projectGroupOrProjectId = computed(() => {
if (entryPoint.value !== 'PROJECT') return undefined;
const id = route.params.projectGroupOrProjectId;
return typeof id === 'string' ? id : undefined;
});

const projectContextType = computed<ProjectContextType>(() => {
const id = projectGroupOrProjectId.value;
if (!id) return undefined;
if (id.startsWith('pg-')) return 'PROJECT_GROUP';
if (id.startsWith('project-')) return 'PROJECT';
return undefined;
});

return {
entryPoint,
isAdminMode,
projectGroupOrProjectId,
projectContextType,
};
};
Loading
Loading