Skip to content

Commit

Permalink
Embeds: Add option to hide the Pivot view from embedded Explore dashb…
Browse files Browse the repository at this point in the history
…oards (#5996)

* Add `hide_pivot` boolean to Explore YAML under an `embeds` key

* Consume `hide_pivot` in UI

* Review

---------

Co-authored-by: Benjamin Egelund-Müller <[email protected]>
  • Loading branch information
ericpgreen2 and begelundmuller committed Oct 29, 2024
1 parent 4ddd8c0 commit 3b51664
Show file tree
Hide file tree
Showing 10 changed files with 662 additions and 623 deletions.
1,234 changes: 623 additions & 611 deletions proto/gen/rill/runtime/v1/resources.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions proto/gen/rill/runtime/v1/resources.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions proto/gen/rill/runtime/v1/runtime.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4061,6 +4061,9 @@ definitions:
defaultPreset:
$ref: '#/definitions/v1ExplorePreset'
description: Preset UI state to show by default.
embedsHidePivot:
type: boolean
description: If true, the pivot tab will be hidden when the explore is embedded.
securityRules:
type: array
items:
Expand Down
2 changes: 2 additions & 0 deletions proto/rill/runtime/v1/resources.proto
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ message ExploreSpec {
repeated string time_zones = 10;
// Preset UI state to show by default.
ExplorePreset default_preset = 15;
// If true, the pivot tab will be hidden when the explore is embedded.
bool embeds_hide_pivot = 16;
// Security for the explore dashboard.
// These are not currently parsed from YAML, but will be derived from the parent metrics view.
repeated SecurityRule security_rules = 12;
Expand Down
4 changes: 4 additions & 0 deletions runtime/compilers/rillv1/parse_explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type ExploreYAML struct {
ComparisonMode string `yaml:"comparison_mode"`
ComparisonDimension string `yaml:"comparison_dimension"`
} `yaml:"defaults"`
Embeds struct {
HidePivot bool `yaml:"hide_pivot"`
} `yaml:"embeds"`
Security *SecurityPolicyYAML `yaml:"security"`
}

Expand Down Expand Up @@ -254,6 +257,7 @@ func (p *Parser) parseExplore(node *Node) error {
r.ExploreSpec.TimeRanges = timeRanges
r.ExploreSpec.TimeZones = tmp.TimeZones
r.ExploreSpec.DefaultPreset = defaultPreset
r.ExploreSpec.EmbedsHidePivot = tmp.Embeds.HidePivot
r.ExploreSpec.SecurityRules = rules

return nil
Expand Down
2 changes: 1 addition & 1 deletion web-admin/src/features/embeds/ExploreEmbed.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<DashboardStateProvider {exploreName}>
<DashboardURLStateProvider {metricsViewName}>
<DashboardThemeProvider>
<Dashboard {exploreName} {metricsViewName} />
<Dashboard {exploreName} {metricsViewName} isEmbedded />
</DashboardThemeProvider>
</DashboardURLStateProvider>
</DashboardStateProvider>
Expand Down
23 changes: 13 additions & 10 deletions web-common/src/features/dashboards/tab-bar/TabBar.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<script lang="ts">
import Chart from "@rilldata/web-common/components/icons/Chart.svelte";
import Pivot from "@rilldata/web-common/components/icons/Pivot.svelte";
import Tag from "@rilldata/web-common/components/tag/Tag.svelte";
import { getStateManagers } from "@rilldata/web-common/features/dashboards/state-managers/state-managers";
import { metricsExplorerStore } from "@rilldata/web-common/features/dashboards/stores/dashboard-stores";
import Tab from "./Tab.svelte";
import Tag from "@rilldata/web-common/components/tag/Tag.svelte";
import { behaviourEvent } from "@rilldata/web-common/metrics/initMetrics";
import { BehaviourEventMedium } from "@rilldata/web-common/metrics/service/BehaviourEventTypes";
import {
MetricsEventScreenName,
MetricsEventSpace,
} from "@rilldata/web-common/metrics/service/MetricsTypes";
// import { featureFlags } from "../../feature-flags";
import Tab from "./Tab.svelte";
// const { pivot: pivotAllowed } = featureFlags;
export let hidePivot: boolean = false;
const StateManagers = getStateManagers();
Expand All @@ -24,17 +23,21 @@
},
} = StateManagers;
const tabs = [
$: tabs = [
{
label: "Explore",
Icon: Chart,
beta: false,
},
{
label: "Pivot",
Icon: Pivot,
beta: false,
},
...(hidePivot
? []
: [
{
label: "Pivot",
Icon: Pivot,
beta: false,
},
]),
];
$: currentTabIndex = $showPivot ? 1 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
export let exploreName: string;
export let metricsViewName: string;
export let isEmbedded: boolean = false;
const { cloudDataViewer, readOnly } = featureFlags;
Expand All @@ -43,6 +44,8 @@
$: explore = useExploreValidSpec($runtime.instanceId, exploreName);
$: mockUserHasNoAccess =
$selectedMockUserStore && $explore.error?.response?.status === 404;
$: hidePivot = isEmbedded && $explore.data?.explore?.embedsHidePivot;
</script>

<article
Expand All @@ -61,7 +64,7 @@
<section class="flex relative justify-between gap-x-4 py-4 pb-6 px-4">
<Filters />
<div class="absolute bottom-0 flex flex-col right-0">
<TabBar />
<TabBar {hidePivot} />
</div>
</section>
{/key}
Expand Down
8 changes: 8 additions & 0 deletions web-common/src/proto/gen/rill/runtime/v1/resources_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2137,6 +2137,13 @@ export class ExploreSpec extends Message<ExploreSpec> {
*/
defaultPreset?: ExplorePreset;

/**
* If true, the pivot tab will be hidden when the explore is embedded.
*
* @generated from field: bool embeds_hide_pivot = 16;
*/
embedsHidePivot = false;

/**
* Security for the explore dashboard.
* These are not currently parsed from YAML, but will be derived from the parent metrics view.
Expand Down Expand Up @@ -2164,6 +2171,7 @@ export class ExploreSpec extends Message<ExploreSpec> {
{ no: 9, name: "time_ranges", kind: "message", T: ExploreTimeRange, repeated: true },
{ no: 10, name: "time_zones", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 15, name: "default_preset", kind: "message", T: ExplorePreset },
{ no: 16, name: "embeds_hide_pivot", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 12, name: "security_rules", kind: "message", T: SecurityRule, repeated: true },
]);

Expand Down
2 changes: 2 additions & 0 deletions web-common/src/runtime-client/gen/index.schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,8 @@ If the list is empty, a default list should be shown.
The values should be valid IANA location identifiers. */
timeZones?: string[];
defaultPreset?: V1ExplorePreset;
/** If true, the pivot tab will be hidden when the explore is embedded. */
embedsHidePivot?: boolean;
/** Security for the explore dashboard.
These are not currently parsed from YAML, but will be derived from the parent metrics view. */
securityRules?: V1SecurityRule[];
Expand Down

1 comment on commit 3b51664

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Please sign in to comment.