Skip to content

Commit

Permalink
Fix: Use logical or for labels (#6249)
Browse files Browse the repository at this point in the history
* Fix: Use logical or for labels

* Lint fix
  • Loading branch information
djbarnwal committed Dec 17, 2024
1 parent 54b9bd9 commit bf948d5
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions web-admin/src/features/alerts/metadata/AlertFilters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<div animate:flip={{ duration: 200 }}>
{#if dimension?.column}
<DimensionFilterReadOnlyChip
label={label ?? name}
label={label || name}
values={selectedValues}
{isInclude}
/>
Expand All @@ -73,7 +73,7 @@
{#each currentMeasureFilters as { name, label, dimensionName, filter } (name)}
<div animate:flip={{ duration: 200 }}>
<MeasureFilterReadOnlyChip
label={label ?? name}
label={label || name}
{dimensionName}
{filter}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
let open = showUpgradeDialog;
</script>

<SettingsContainer title={plan?.displayName ?? "Team plan"}>
<SettingsContainer title={plan?.displayName || "Team plan"}>
<div slot="body">
<div>
<div class="flex flex-row items-center gap-x-1 text-sm">
Expand Down
2 changes: 1 addition & 1 deletion web-admin/src/features/billing/plans/TrialPlan.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
$: title =
(plan?.displayName ?? "Trial plan") + (trialEnded ? " expired" : "");
(plan?.displayName || "Trial plan") + (trialEnded ? " expired" : "");
let open = showUpgradeDialog;
$: type = (trialEnded ? "trial-expired" : "base") as TeamPlanDialogTypes;
Expand Down
2 changes: 1 addition & 1 deletion web-admin/src/features/bookmarks/BookmarkDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const formState = createForm<BookmarkFormValues>({
initialValues: {
displayName: bookmark?.resource.displayName ?? "Default Label",
displayName: bookmark?.resource.displayName || "Default Label",
description: bookmark?.resource.description ?? "",
shared: bookmark?.resource.shared ? "true" : "false",
filtersOnly: bookmark?.filtersOnly ?? false,
Expand Down
2 changes: 1 addition & 1 deletion web-admin/src/features/navigation/TopNavigationBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
onPublicURLPage,
);
$: publicURLDashboardTitle =
$exploreQuery.data?.explore?.spec?.displayName ?? dashboard ?? "";
$exploreQuery.data?.explore?.spec?.displayName || dashboard || "";
$: currentPath = [organization, project, dashboard, report || alert];
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
function useValidDashboardTitle(dashboard: DashboardResource) {
return (
dashboard?.resource.explore?.spec?.displayName ??
dashboard?.resource.explore?.spec?.displayName ||
dashboard?.resource.meta.name.name
);
}
Expand Down
4 changes: 2 additions & 2 deletions web-common/src/features/alerts/alert-preview-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function getSchemaEntryForField(
return {
name: field.name as string,
type: field.type?.code ?? TypeCode.CODE_STRING,
label: dimension.displayName ?? field.name,
label: dimension.displayName || field.name,
enableResize: false,
enableSorting: false,
};
Expand All @@ -125,7 +125,7 @@ function getSchemaEntryForField(
return undefined;

let label: VirtualizedTableColumns["label"] =
measure.displayName ?? field.name;
measure.displayName || field.name;
let format = measure.formatPreset;
let type: string = field.type?.code ?? TypeCode.CODE_STRING;
if (
Expand Down
2 changes: 1 addition & 1 deletion web-common/src/features/alerts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function generateAlertName(
if (!measure || !typeEntry) return undefined;

const measureLabel =
measure.displayName ?? measure.expression ?? (measure.name as string);
measure.displayName || measure.expression || (measure.name as string);

let comparisonTitle = "";
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The main feature-set component for dashboard filters
<div animate:flip={{ duration: 200 }}>
{#if dimension?.column || dimension?.expression}
<DimensionFilterReadOnlyChip
label={label ?? name}
label={label || name}
values={selectedValues}
{isInclude}
/>
Expand All @@ -75,7 +75,7 @@ The main feature-set component for dashboard filters
{#each measureFilters as { name, label, dimensionName, filter } (name)}
<div animate:flip={{ duration: 200 }}>
<MeasureFilterReadOnlyChip
label={label ?? name}
label={label || name}
{dimensionName}
{filter}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { LeaderboardContextColumn } from "@rilldata/web-common/features/dashboards/leaderboard-context-column";
import Button from "@rilldata/web-common/components/button/Button.svelte";
import DashboardVisibilityDropdown from "@rilldata/web-common/components/menu/shadcn/DashboardVisibilityDropdown.svelte";
import * as Select from "@rilldata/web-common/components/select";
import { LeaderboardContextColumn } from "@rilldata/web-common/features/dashboards/leaderboard-context-column";
import { metricsExplorerStore } from "web-common/src/features/dashboards/stores/dashboard-stores";
import { getStateManagers } from "../state-managers/state-managers";
import * as Select from "@rilldata/web-common/components/select";
import Button from "@rilldata/web-common/components/button/Button.svelte";
export let exploreName: string;
Expand Down Expand Up @@ -82,7 +82,7 @@
selected={{ value: activeLeaderboardMeasure.name, label: "" }}
items={measures.map((measure) => ({
value: measure.name ?? "",
label: measure.displayName ?? measure.name,
label: measure.displayName || measure.name,
}))}
onSelectedChange={(newSelection) => {
if (!newSelection?.value) return;
Expand All @@ -93,7 +93,7 @@
<Button type="text" label="Select a measure to filter by">
<span class="truncate text-gray-700 hover:text-inherit">
Showing <b>
{activeLeaderboardMeasure?.displayName ??
{activeLeaderboardMeasure?.displayName ||
activeLeaderboardMeasure.name}
</b>
</span>
Expand All @@ -108,12 +108,12 @@
{#each measures as measure (measure.name)}
<Select.Item
value={measure.name}
label={measure.displayName ?? measure.name}
label={measure.displayName || measure.name}
class="text-[12px]"
>
<div class="flex flex-col">
<div class:font-bold={$leaderboardMeasureName === measure.name}>
{measure.displayName ?? measure.name}
{measure.displayName || measure.name}
</div>

<p class="ui-copy-muted" style:font-size="11px">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const measureLabel = ({
const measure = validMetricsView?.measures?.find(
(d) => d.name === measureName,
);
return measure?.displayName ?? measureName;
return measure?.displayName || measureName;
};
};
export const isMeasureValidPercentOfTotal = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@
// Note: undefined values are filtered out above, so the
// empty string fallback is unreachable.
({
name: m.name ?? "",
label: m.displayName ?? "",
name: m.name || "",
label: m.displayName || "",
}),
);
$: selectedMeasureLabel =
$allMeasures.find((m) => m.name === expandedMeasureName)?.displayName ??
$allMeasures.find((m) => m.name === expandedMeasureName)?.displayName ||
expandedMeasureName;
$: excludeMode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import CaretDownIcon from "@rilldata/web-common/components/icons/CaretDownIcon.svelte";
import ExploreIcon from "@rilldata/web-common/components/icons/ExploreIcon.svelte";
import { removeLeadingSlash } from "@rilldata/web-common/features/entity-management/entity-mappers";
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient";
import type { V1Resource } from "@rilldata/web-common/runtime-client";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import { queryClient } from "@rilldata/web-common/lib/svelte-query/globalQueryClient";
import { useGetExploresForMetricsView } from "../dashboards/selectors";
import { allowPrimary } from "../dashboards/workspace/DeployProjectCTA.svelte";
import { resourceColorMapping } from "../entity-management/resource-icon-mapping";
import { ResourceKind } from "../entity-management/resource-selectors";
import { createAndPreviewExplore } from "./create-and-preview-explore";
import { allowPrimary } from "../dashboards/workspace/DeployProjectCTA.svelte";
export let resource: V1Resource | undefined;
Expand Down Expand Up @@ -47,7 +47,7 @@
<DropdownMenu.Group>
{#each dashboards as resource (resource?.meta?.name?.name)}
{@const label =
resource?.explore?.state?.validSpec?.displayName ??
resource?.explore?.state?.validSpec?.displayName ||
resource?.meta?.name?.name}
{@const filePath = resource?.meta?.filePaths?.[0]}
{#if label && filePath}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
}}
let:item
>
{items.find((m) => m.name === item)?.displayName ?? item}
{items.find((m) => m.name === item)?.displayName || item}
</SelectionDropdown>
{/if}
</div>

0 comments on commit bf948d5

Please sign in to comment.