Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboards and charts): editable tiles | slottable menu items #1758

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

filipgutica
Copy link
Contributor

@filipgutica filipgutica commented Nov 1, 2024

Summary

https://konghq.atlassian.net/browse/MA-3367

  • add new edit-tile event to dashboard renderer
  • forward go-to -explore prop to analytics chart through tile definition
  • add new editable property to tile definition that will add an "edit" item to the analytics chart kebab menu. Clicking on edit, will emit an @edit-tile event with the entire GridTile object containing the tile layout, definition and index

@edit-tile event

{
    "layout": {
        "position": {
            "col": 0,
            "row": 2
        },
        "size": {
            "cols": 3,
            "rows": 2
        }
    },
    "meta": {
        "chart": {
            "type": "horizontal_bar",
            "chartTitle": "Horizontal bar chart of mock data",
            "allowCsvExport": true
        },
        "query": {
            "datasource": "basic",
            "dimensions": [
                "route"
            ]
        },
        "editable": true
    },
    "id": 3
}
image

@filipgutica filipgutica requested a review from a team as a code owner November 1, 2024 05:50
@filipgutica filipgutica force-pushed the feat/dashboard-renderer-go-to-explore branch from ee386d3 to e20f568 Compare November 1, 2024 05:54
Copy link
Contributor

@adorack adorack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to review.

@filipgutica filipgutica force-pushed the feat/dashboard-renderer-go-to-explore branch from e20f568 to 39d5b82 Compare November 1, 2024 16:16
@@ -46,18 +46,24 @@ const overrideTimeframe: Ref<Timeframe> = computed(() => {
return relativePeriod
})

const options = computed<ProviderProps>(() => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a type error here that's somehow getting past CI... 🤔

No overload matches this call.
  Overload 1 of 2, '(getter: ComputedGetter<Partial<{ description: string; containerTitle: string; refreshInterval: number; datasource: "advanced" | "basic"; dimension: "api_product" | "api_product_version" | "control_plane" | ... 9 more ... | "iso_code"; ... 8 more ...; percentileLatency: boolean; }> & Omit<...>>, debugOptions?: DebuggerOptions | undefined): ComputedRef<...>', gave the following error.
    Type '"advanced" | "basic" | "ai"' is not assignable to type '"advanced" | "basic" | undefined'.
      Type '"ai"' is not assignable to type '"advanced" | "basic" | undefined'.
  Overload 2 of 2, '(options: WritableComputedOptions<Partial<{ description: string; containerTitle: string; refreshInterval: number; datasource: "advanced" | "basic"; dimension: "api_product" | "api_product_version" | "control_plane" | ... 9 more ... | "iso_code"; ... 8 more ...; percentileLatency: boolean; }> & Omit<...>, Partial<...> & Omit<...>>, debugOptions?: DebuggerOptions | undefined): WritableComputedRef<...>', gave the following error.
    Argument of type '() => { datasource: "advanced" | "basic" | "ai"; overrideTimeframe: Timeframe; tz: string; additionalFilter: ExploreFilter[]; longCardTitles: boolean | undefined; containerTitle: string | undefined; description: string | undefined; percentileLatency: boolean | undefined; refreshInterval: number; queryReady: boolean; }' is not assignable to parameter of type 'WritableComputedOptions<Partial<{ description: string; containerTitle: string; refreshInterval: number; datasource: "advanced" | "basic"; dimension: "api_product" | "api_product_version" | "control_plane" | ... 9 more ... | "iso_code"; ... 8 more ...; percentileLatency: boolean; }> & Omit<...>, Partial<...> & Omit<....'.ts-plugin(2769)
MetricsProvider.vue.d.ts(67, 5): The expected type comes from property 'datasource' which is declared here on type 'Partial<{ description: string; containerTitle: string; refreshInterval: number; datasource: "advanced" | "basic"; dimension: "api_product" | "api_product_version" | "control_plane" | ... 9 more ... | "iso_code"; ... 8 more ...; percentileLatency: boolean; }> & Omit<...>'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's from updates to analytics-utilities which introduced the ai datasource, while the provider props in metrics provider defines datasource property like so: datasource?: "basic" | "advanced" | undefined;

Not sure if my change is the right one, or we should add ai to the acceptable datasources in MetricsProvider

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I'll make a note to look at this later. I think this is the fault of the schema; it shouldn't allow setting ai as a datasource for metric cards. I think what you have for now is fine.

- add new edit-tile event to dashboard renderer
- forward go to explore to analytics chart through tile definition
- add new editable property to tile definition that will add an "edit" item to
the analytics chart kebab menu. Clicking on edit, will emit an @edit-tile event
with the entire GridTile<T> object containing the tile layout, definition and index
@filipgutica filipgutica force-pushed the feat/dashboard-renderer-go-to-explore branch from 39d5b82 to b103fc2 Compare November 1, 2024 16:59
@@ -55,6 +55,14 @@ const allowCsvExport = {
type: 'boolean',
} as const

const goToExplore = {
Copy link
Contributor

@adorack adorack Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think either of these properties should be exposed in the schema. The things in the schema are eventually going to be part of the public API for dashboards; there's no case where an end user should be able to directly configure these props.

I'd recommend:

  • editable is exposed via context. I think it's OK (especially for now) to say that either all tiles are editable or none are.
  • goToExplore is probably a base URL that's configured via the analytics bridge, and the query data provider calculates the final URL to hand to AnalyticsChart.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the dashboard know if the tiles should have go to explore or not? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming some tiles will support it while some would not. EG TopNTable doesn't map to anything in Explore, same with "slottable" tiles

@@ -46,18 +46,24 @@ const overrideTimeframe: Ref<Timeframe> = computed(() => {
return relativePeriod
})

const options = computed<ProviderProps>(() => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I'll make a note to look at this later. I think this is the fault of the schema; it shouldn't allow setting ai as a datasource for metric cards. I think what you have for now is fine.

@filipgutica filipgutica force-pushed the feat/dashboard-renderer-go-to-explore branch from bd46c63 to 231a753 Compare November 1, 2024 20:00
@filipgutica filipgutica requested a review from adorack November 1, 2024 21:18
@@ -3,7 +3,7 @@
<BaseAnalyticsChartRenderer
:chart-options="chartOptions"
:context="context"
:editable="editable"
:editable="context.editable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're already passing in context -- no need for the extra prop. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -61,7 +61,7 @@ const componentData = computed(() => {
queryReady: props.queryReady,
chartOptions: props.definition.chart,
height: props.height - PADDING_SIZE * 2,
editable: props.definition.editable,
editable: props.context.editable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to pass in this prop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's still there...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, my bad. I got rid of using the prop, forgot to revert this line 😅
24443a5

@@ -59,10 +60,6 @@ const goToExplore = {
type: 'string',
} as const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove goToExplore as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -61,7 +61,7 @@ const componentData = computed(() => {
queryReady: props.queryReady,
chartOptions: props.definition.chart,
height: props.height - PADDING_SIZE * 2,
editable: props.definition.editable,
editable: props.context.editable,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it's still there...

@filipgutica filipgutica requested a review from adorack November 4, 2024 18:30
@filipgutica filipgutica enabled auto-merge (squash) November 4, 2024 18:35
@filipgutica filipgutica merged commit 2b0a8fd into main Nov 4, 2024
10 checks passed
@filipgutica filipgutica deleted the feat/dashboard-renderer-go-to-explore branch November 4, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants