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: Categorical dashboard filters #1677

Merged
merged 22 commits into from
Aug 13, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9ab3d69
refactor: Set the ground for dashboards data filters
bprusinowski Jul 24, 2024
e246b8a
feat: Display dashboard data filters in the options panel
bprusinowski Jul 24, 2024
7fca689
refactor: Do not mirror configurator dashboard filters in dashboard f…
bprusinowski Jul 24, 2024
42a5eea
feat: Add initial dashboard data filters logic
bprusinowski Jul 25, 2024
bec48ee
fix: Accessing with value
bprusinowski Jul 25, 2024
dbc18ab
chore: Remove console.log
bprusinowski Jul 25, 2024
1c42987
fix: useSyncInteractiveFilters
bprusinowski Jul 25, 2024
24df881
feat: Disable reloading of interactive filters when dashboard filters…
bprusinowski Jul 25, 2024
966810b
feat: Sort dashboard categorical filters
bprusinowski Jul 25, 2024
5a7f5ac
feat: Add a way to set override dashboard filters
bprusinowski Jul 29, 2024
940c287
fix: Maintaining the interactive filters state in tab layout
bprusinowski Jul 29, 2024
b55a51e
fix: Opening of metadata panel from global interactive filters
bprusinowski Jul 29, 2024
e6f6378
refactor: Extract helper
ptbrowne Aug 2, 2024
daf43d9
refactor: Use fromEntries techniques to create new obj
ptbrowne Aug 2, 2024
bb9c7ba
refactor
ptbrowne Aug 5, 2024
2db20b3
refactor: Extract snapshot function
ptbrowne Aug 5, 2024
c88732f
refactor: Save snapshot directly returns restore function
ptbrowne Aug 5, 2024
5b82112
test: Add test for restorer
ptbrowne Aug 5, 2024
0c100f9
refactor: Extract function closer to domain
ptbrowne Aug 5, 2024
ec5a130
refactor: rename for clarity
ptbrowne Aug 12, 2024
f86a7c2
refactor: Import order
ptbrowne Aug 12, 2024
e620968
fix: When changing dashboard config default value, cube query filters…
ptbrowne Aug 12, 2024
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
26 changes: 15 additions & 11 deletions app/charts/shared/chart-data-filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const useChartDataFiltersState = ({
dataSource,
chartConfig,
preparedFilters,
dashboardFilters,
});
return {
open,
Expand Down Expand Up @@ -539,20 +540,19 @@ export const DataFilterTemporalDimension = ({
);
};

type EnsurePossibleInteractiveFiltersProps = {
dataSource: DataSource;
chartConfig: ChartConfig;
preparedFilters?: PreparedFilter[];
};

/**
* This runs every time the state changes and it ensures that the selected interactive
* filters return at least 1 observation. Otherwise they are reloaded.
*
* This behavior is disabled when the dashboard filters are active.
*/
const useEnsurePossibleInteractiveFilters = (
props: EnsurePossibleInteractiveFiltersProps
) => {
const { dataSource, chartConfig, preparedFilters } = props;
const useEnsurePossibleInteractiveFilters = (props: {
dataSource: DataSource;
chartConfig: ChartConfig;
dashboardFilters: DashboardFiltersConfig | undefined;
preparedFilters?: PreparedFilter[];
}) => {
const { dataSource, chartConfig, dashboardFilters, preparedFilters } = props;
const [, dispatch] = useConfiguratorState();
const loadingState = useLoadingState();
const [error, setError] = useState<Error>();
Expand All @@ -569,7 +569,10 @@ const useEnsurePossibleInteractiveFilters = (

useEffect(() => {
const run = async () => {
if (!filtersByCubeIri) {
if (
!filtersByCubeIri ||
dashboardFilters?.dataFilters.componentIris.length
) {
return;
}

Expand Down Expand Up @@ -667,6 +670,7 @@ const useEnsurePossibleInteractiveFilters = (
loadingState,
filtersByCubeIri,
getInteractiveFiltersState,
dashboardFilters?.dataFilters.componentIris.length,
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved
]);

return { error };
Expand Down
Loading