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

Feature/dataset explorer chart update chart #355

Merged
merged 188 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
daace7f
Merge tag '2.0.0' into cccs-2.0
cccs-RyanS Jul 25, 2022
928d983
[cccs-2.0] updating docker file (#188)
cccs-RyanS Jul 29, 2022
6fe7950
[CLDN-1565] Fixing bugs (#189)
cccs-RyanS Aug 8, 2022
53d4005
Feature/cldn 1565 (#192)
cccs-RyanS Aug 9, 2022
497e761
Feature/cldn 1609 (#195)
cccs-RyanS Aug 16, 2022
685d621
[CLDN-1609] Updating image (#196)
cccs-RyanS Aug 16, 2022
bbec5b2
[CLDN-1620] Making rendering use advanced type (#197)
cccs-RyanS Aug 17, 2022
163e440
updating image (#198)
cccs-RyanS Aug 18, 2022
8bc4533
[CLDN-1609] Fixing all QA bugs (#201)
cccs-RyanS Aug 23, 2022
3ecbde1
Feature/cldn 1541 (#200)
cccs-Dustin Aug 23, 2022
4346c25
[CLDN-1609] Updating docker image (#202)
cccs-RyanS Aug 23, 2022
44fbf92
[cccs-2.0] Fixing case sensitivity (#203)
cccs-RyanS Sep 12, 2022
8e95aa8
Fix/cccs 2.0 (#204)
cccs-Dustin Sep 12, 2022
29f2ff6
Fixed issue with Typescript (#205)
cccs-Dustin Sep 14, 2022
0b28483
Fix cccs 2.0 (#206)
cccs-Dustin Sep 14, 2022
6e68cd9
Feature/cldn 1563 (#207)
cccs-Dustin Sep 16, 2022
516b9db
Updated image (#208)
cccs-Dustin Sep 16, 2022
9e99e8c
[CLDN-1683] Added code to show column descriptions as tooltips in the…
cccs-Dustin Sep 20, 2022
5788b73
Feature/cldn 1676 (#210)
cccs-Dustin Sep 22, 2022
85719e6
Updating Superset Base Image Tag (#211)
cccs-Dustin Sep 23, 2022
30ecdf3
added adhoc filter plugin files
cccs-RyanK Sep 23, 2022
5b9d83d
Made sure that adhoc filter uses the adhoc filter object
cccs-Dustin Sep 23, 2022
22285cd
added adhocfiltercontrol to native adhoc filter
cccs-RyanK Sep 27, 2022
080d279
fixed hook that made too many requests
cccs-RyanK Sep 27, 2022
99d9f5a
fixed applied filter label
cccs-RyanK Sep 27, 2022
80151b6
removed duplicate files
cccs-RyanK Sep 28, 2022
3a66d93
Removed uneeded functions
cccs-Dustin Sep 28, 2022
1e04870
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-Dustin Sep 28, 2022
8e310c6
Removed uneeded functions and variables
cccs-Dustin Sep 28, 2022
ac5e203
Removed unused props variables
cccs-Dustin Sep 28, 2022
be85fab
modifying base image tag
cccs-RyanK Sep 28, 2022
c53c43d
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-RyanK Sep 28, 2022
673ffac
Removed unused config settings
cccs-Dustin Sep 28, 2022
7c681b5
Merge branch 'Adding-Dashboard-Adhoc-Filters' of github.com:Cybercent…
cccs-Dustin Sep 28, 2022
c796777
removed column for filter config form
cccs-RyanK Sep 29, 2022
157aaae
Improved the applied filter(s) modal
cccs-Dustin Sep 29, 2022
257eec8
Temp update to build image
cccs-Dustin Sep 29, 2022
14c936a
fixed string formatting issue:
cccs-RyanK Sep 29, 2022
3a6b4bf
updating superset base image tag
cccs-RyanK Sep 29, 2022
94de584
added setFocused hooks to filter when hovering
cccs-RyanK Oct 4, 2022
1c8ab53
Fixed the right click to emit dashboard cross-filters (#213)
cccs-Dustin Oct 5, 2022
69aef0d
Updated superset base image (#214)
cccs-Dustin Oct 5, 2022
3fe2450
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Oct 7, 2022
58be3bb
fixed unused declaration error
cccs-RyanK Oct 7, 2022
ab53b1e
updating image
cccs-RyanK Oct 7, 2022
37daf44
Prevent invalid filter values from being saved (#215)
reesercollins Oct 7, 2022
ddfc44d
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Oct 11, 2022
41f25ef
[cccs-2.0] fixing trino req (#216)
cccs-RyanS Oct 11, 2022
9d9a0d3
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset int…
cccs-RyanK Oct 11, 2022
0b71bbf
updating superset-base image tag
cccs-RyanK Oct 11, 2022
b522737
added option to emit a filter from a default column for a row in ag grid
cccs-RyanK Oct 14, 2022
87b70ad
Update trino python client (#219)
cccs-Dustin Oct 14, 2022
cf6e97e
Updated superset's base image tag (#221)
cccs-Dustin Oct 14, 2022
ed0c5f4
Update superset-frontend/src/cccs-viz/plugins/plugin-chart-cccs-grid/…
cccs-RyanK Oct 19, 2022
9c7efc4
changed control panel to plural
cccs-RyanK Oct 31, 2022
dc52e1d
Merge branch 'emit-a-filter-for-a-default-column-in-aggrid-context-me…
cccs-RyanK Oct 31, 2022
518248b
disallow columns that are not a part of the chart to be selected as d…
cccs-RyanK Nov 2, 2022
f706484
updated image tag
cccs-RyanK Nov 4, 2022
94252a5
updated control panel logic for agg mode
cccs-RyanK Nov 7, 2022
c111044
update image tag
cccs-RyanK Nov 7, 2022
2d6c805
fixed issues
cccs-RyanK Nov 9, 2022
cacf040
updating base image
cccs-RyanK Nov 9, 2022
8d74228
fixed refactor error
cccs-RyanK Nov 10, 2022
9d0f6cd
updating base image
cccs-RyanK Nov 10, 2022
fcc6a8d
fixed so that option disables properly
cccs-RyanK Nov 14, 2022
609b2ab
updating base image
cccs-RyanK Nov 14, 2022
f0b4db2
Merge branch 'cccs-2.0' into emit-a-filter-for-a-default-column-in-ag…
cccs-RyanK Nov 14, 2022
6d8dc99
Merge pull request #220 from CybercentreCanada/emit-a-filter-for-a-de…
cccs-RyanK Nov 15, 2022
5512ded
Add users API to get and delete users (#223)
reesercollins Nov 18, 2022
953531f
Merge branch 'cccs-2.0' of github.com:CybercentreCanada/superset into…
cccs-RyanK Nov 21, 2022
fc2207b
updating image
cccs-RyanK Nov 21, 2022
330f3e5
Update cccs-build/superset/Dockerfile
cccs-RyanK Nov 22, 2022
0635660
Merge pull request #218 from CybercentreCanada/Adding-Dashboard-Adhoc…
cccs-RyanK Nov 23, 2022
0d5fee8
Added ability to certify entities with multiple values (#224)
reesercollins Nov 24, 2022
2cee63f
Feature/cldn 1749 (#222)
cccs-RyanS Dec 1, 2022
7ef6d75
Prevent non-admins from using users api (#236)
reesercollins Dec 8, 2022
e0ec100
added styles to highlight adhoc filter when focused and fix awkward e…
cccs-RyanK Dec 30, 2022
90aa381
removed suggestions from popping up
cccs-RyanK Dec 30, 2022
b14a496
added comment
cccs-RyanK Dec 30, 2022
bebe51a
fixed unused import error
cccs-RyanK Jan 3, 2023
4e9562b
updating base image
cccs-RyanK Jan 5, 2023
8aaf728
Update Dockerfile
cccs-RyanK Jan 17, 2023
f26f285
Merge pull request #242 from CybercentreCanada/CLDN-1828-Fix-minor-is…
cccs-RyanK Jan 17, 2023
5a67b21
[CLDN-1829] fixing principle filter logic with state (#234) (#244)
cccs-RyanS Jan 17, 2023
263ace7
[cccs-2.0] Updating image (#245)
cccs-RyanS Jan 19, 2023
eee6b9b
value set to empty list instead of undefined
Feb 3, 2023
eb317db
Merge branch 'cccs-2.0' into CLDN-1928-filter-incorrectly-displays-as…
cccs-RyanK Feb 3, 2023
fba5e3e
updating base image
Feb 6, 2023
99b808a
Feature/cldn 1748 (#243)
cccs-RyanS Feb 6, 2023
22c8982
CLDN-1710 including schema in search columns for datasets api (#253)
cccs-nik Feb 6, 2023
6538a68
Update Dockerfile
cccs-RyanK Feb 6, 2023
cf3eea4
Merge branch 'cccs-2.0' into CLDN-1928-filter-incorrectly-displays-as…
cccs-RyanK Feb 6, 2023
aa4db47
Merge pull request #252 from CybercentreCanada/CLDN-1928-filter-incor…
cccs-RyanK Feb 6, 2023
6165862
CLDN-1710 tag update (#255)
cccs-nik Feb 6, 2023
7657bc9
update image tag
cccs-RyanK Feb 14, 2023
e415cb2
Merge pull request #260 from CybercentreCanada/update-image-tag
cccs-RyanK Feb 15, 2023
1ec3298
Merge remote-tracking branch 'origin/cccs-2.0.1' into merge-cccs-2.0.1
cccs-RyanK Feb 15, 2023
9dea21a
updating image tag
cccs-RyanK Feb 16, 2023
3f1c735
Update vault image to get new CAs
cccs-RyanK Feb 20, 2023
7d8647d
update image tag
cccs-RyanK Feb 23, 2023
763e0dd
Merge pull request #263 from CybercentreCanada/cccs-RyanK-Update-Vaul…
cccs-RyanK Feb 23, 2023
8eeaef0
Merge branch 'cccs-2.0' into merge-cccs-2.0.1
cccs-RyanK Feb 23, 2023
6104740
Merge pull request #261 from CybercentreCanada/merge-cccs-2.0.1
cccs-RyanK Feb 23, 2023
4c098df
Update Dockerfile
cccs-RyanK Feb 23, 2023
1519293
Merge branch 'cccs-2.0' into update-2.0-image-tag
cccs-RyanK Feb 23, 2023
aa96651
Update Dockerfile
cccs-RyanK Feb 24, 2023
b0cd852
Merge pull request #265 from CybercentreCanada/update-2.0-image-tag
cccs-RyanK Feb 24, 2023
aa270f2
Feature/cldn 1773 (#269)
cccs-RyanS Mar 10, 2023
c088022
Updating docker file (#270)
cccs-RyanS Mar 13, 2023
592337e
Feature/cldn 1968 (Display JSON data inline) (#268)
cccs-Dustin Mar 15, 2023
b269270
Feature/cldn 1968 (#272)
cccs-Dustin Mar 15, 2023
dbbdaaf
Adding componenets
cccs-RyanS May 1, 2023
7a334b4
[CLDN-2142] Finish Dateetime Picker and reorg control panael
cccs-RyanS May 4, 2023
51f83e3
added changes to align cccs-viz with upstream cross-filtering
cccs-RyanK May 4, 2023
4340877
fixed column sorting being reset on emit filters
cccs-RyanK May 4, 2023
d4b6937
fixed errors
cccs-RyanK May 4, 2023
0c44cca
[CLDN-2142] Adding validation for advanced type input
cccs-RyanS May 4, 2023
1361ed9
update base image
cccs-RyanK May 8, 2023
2f3bea1
update base image
cccs-RyanK May 8, 2023
f6b3cfd
advanced type null fix
cccs-RyanK May 11, 2023
cf711d1
removed legacy time section
cccs-RyanK May 3, 2023
2004bdd
removed unused import
cccs-RyanK May 3, 2023
a7238a2
updating docker image
cccs-RyanK May 12, 2023
1d06ec6
fixed bootstrap data
cccs-RyanK May 15, 2023
8a6d0ab
update docker file
cccs-RyanK May 15, 2023
2f1cb1b
[CLDN-2064] Fixed column header reset bug
cccs-Dustin Apr 19, 2023
52d302d
fix column sorting not updating columns
cccs-RyanK May 15, 2023
e97e267
updating base image
cccs-RyanK May 15, 2023
2958c8b
updating base image
cccs-RyanK May 15, 2023
57a8d4b
[expore++] Fixing bugs with page reload
cccs-RyanS May 16, 2023
f2c287a
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanS May 16, 2023
20b6288
Merge remote-tracking branch 'origin/fix/CLDN-2009-emiting-filters-re…
cccs-RyanS May 18, 2023
fc40300
fixing build errors
cccs-RyanS May 18, 2023
0974145
Dockerfile update
cccs-RyanS May 18, 2023
ff4f94e
CLDN-2198 updated formatting and removed change dataset button from c…
cccs-RyanK Jun 7, 2023
3b85b5d
CLDN-2202 updated formatting and fixed time range validation errors
cccs-RyanK Jun 7, 2023
0d866b8
CLDN-2195 prevent running an emtpy query aggregate mode
cccs-RyanK Jun 7, 2023
25303c5
CLDN-2203 make wording in date errors consistent with labels
cccs-RyanK Jun 7, 2023
d1b7a26
CLDN-2205 make time range invisible when no time column is selected
cccs-RyanK Jun 7, 2023
6dffa90
CLDN-2206 Fixed formatting, labelling, classname, and disable selecto…
cccs-RyanK Jun 7, 2023
5a7edd9
CLDN-2207 show advanced type labels and not ids in selector dropdown
cccs-RyanK Jun 8, 2023
34c0af6
CLDN-2208 clear values when selector is changed
cccs-RyanK Jun 8, 2023
cf57f5b
CLDN-2210 change button name to Swap Dataset
cccs-RyanK Jun 8, 2023
ec58e0e
CLDN-2211 fix query builder to use actual values rather than strings
cccs-RyanK Jun 8, 2023
09e92d6
fixed npm errors
cccs-RyanK Jun 8, 2023
e3e29c7
update image tag
cccs-RyanK Jun 8, 2023
1b2246f
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanK Jun 8, 2023
71e05bd
merge fixes and tool tip update
cccs-RyanK Jun 8, 2023
da54e58
CLDN-2209 fix incorrect dimensions after swapping datasets
cccs-RyanK Jun 9, 2023
adb7fa4
Select All not working on swap datasets, default to no selection
cccs-RyanK Jun 9, 2023
49711f1
fixed npm build errros
cccs-RyanK Jun 9, 2023
596340e
update base image
cccs-RyanK Jun 9, 2023
c5f4bcd
CLDN-2208 Mandatory to have a value if selector is selected and inval…
cccs-RyanK Jun 12, 2023
212b47b
disable time range when no time column is selected
cccs-RyanK Jun 12, 2023
b34b629
change selector to advanced data type and values now saved in form da…
cccs-RyanK Jun 13, 2023
f02e228
fix refactor mistake and allow querying ranges of advanced types
cccs-RyanK Jun 13, 2023
887762b
added comments and removed debugging lines
cccs-RyanK Jun 13, 2023
aa1e2ca
remove unecessary tool tip and fix npm issues
cccs-RyanK Jun 14, 2023
74b776c
validation in progress to prevent running query on bad values
cccs-RyanK Jun 14, 2023
641133e
update base image
cccs-RyanK Jun 14, 2023
d1a73eb
fix for temporarily caching form data
cccs-RyanK Jun 14, 2023
ecc9113
readded tooltip
cccs-RyanK Jun 14, 2023
ec14ee4
fixed tooltip, added order by
cccs-RyanK Jun 14, 2023
aa50127
npm error fix
cccs-RyanK Jun 14, 2023
d81c384
update base image
cccs-RyanK Jun 14, 2023
631277a
removed changes from hogwarts table viz
cccs-RyanK Jun 16, 2023
6a3210c
fix error in tooltip for adt value
cccs-RyanK Jun 19, 2023
41538c6
update image tag
cccs-RyanK Jun 19, 2023
a2c3502
removed unused adhoc time filter
cccs-RyanK Jun 21, 2023
f14e5a5
fixed import order
cccs-RyanK Jun 21, 2023
f877f4f
update docker file
cccs-RyanK Jun 21, 2023
b2850d0
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart
cccs-RyanS Jul 5, 2023
846ec1e
[dataset explorer] pr feedback
cccs-RyanS Jul 5, 2023
bb81a99
Updating docker file
cccs-RyanS Jul 10, 2023
7feb454
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart-update-chart
cccs-RyanS Jul 10, 2023
987fca2
testing datetime formatting
cccs-RyanK Jul 13, 2023
6520390
fixing npm error
cccs-RyanK Jul 17, 2023
67175d9
updating image tag
cccs-RyanK Jul 17, 2023
108f4ed
small formatting fix
cccs-RyanK Jul 17, 2023
887cb55
update image tag
cccs-RyanK Jul 17, 2023
8c5a9b3
Merge branch 'dataset-explorer-date-test' into feature/dataset-explor…
cccs-RyanK Jul 18, 2023
0d961e9
fixes to control panel
cccs-RyanK Jul 24, 2023
4d4ae81
fix npm issues
cccs-RyanK Jul 24, 2023
6d4b3d6
updated base image tag
cccs-RyanK Jul 25, 2023
0413773
update base image tag
cccs-RyanK Jul 25, 2023
f092ce5
fixed default values for control components
cccs-RyanK Jul 25, 2023
6a53e9f
updated base image tag
cccs-RyanK Jul 25, 2023
db21fe3
Merge branch 'cccs-2.1' into feature/dataset-explorer-chart-update-chart
cccs-RyanK Jul 26, 2023
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
2 changes: 1 addition & 1 deletion cccs-build/superset/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Vault CA container import
ARG VAULT_CA_CONTAINER=uchimera.azurecr.io/cccs/hogwarts/vault-ca:master_11376_a25c34e1
FROM $VAULT_CA_CONTAINER AS vault_ca
FROM uchimera.azurecr.io/cccs/superset-base:cccs-2.1_20230704153241_b7209
FROM uchimera.azurecr.io/cccs/superset-base:feature_dataset-explorer-chart-update-chart_20230725150622_b7385

USER root

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,33 @@ const AdvancedDataTypeValueControlValueControl: React.FC<Props> = ({
value = [],
description,
}) => {
const [rawValues, setRawValues] = useState([]);
const [rawValues, setRawValues] = useState(
value && ensureIsArray(value).length === 1 ? value[0].rawData : [],
);
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const [currentAdvancedDataType, setCurrentAdvancedDataType] =
useState<string>();
useState<string>(advancedDataType);

const default_advanced_data_type_state = {
parsedAdvancedDataType: '',
advancedDataTypeOperatorList: [],
errorMessage: '',
useDefaultOperators: false,
values: value && ensureIsArray(value).length === 1 ? value[0].data : [],
};

const {
advancedDataTypesState,
subjectAdvancedDataType,
fetchAdvancedDataTypeValueCallback,
} = useAdvancedDataTypes(() => {});
} = useAdvancedDataTypes(() => {}, default_advanced_data_type_state);

const onChangeWrapper = (selection: any) => {
setValidationErrors([...validationErrors, 'Validation in progress']);
setValidationErrors(
selection.length > 0
? [...validationErrors, 'Validation in progress']
: [...validationErrors],
);
setRawValues(selection);
};

Expand All @@ -68,8 +82,7 @@ const AdvancedDataTypeValueControlValueControl: React.FC<Props> = ({

useEffect(() => {
const data =
advancedDataTypesState.parsedAdvancedDataType.length > 0 &&
advancedDataTypesState.parsedAdvancedDataType.split(',').length > 0
advancedDataTypesState.values.length > 0
? {
data: advancedDataTypesState.values,
columns: datasource.columns
Expand All @@ -82,11 +95,13 @@ const AdvancedDataTypeValueControlValueControl: React.FC<Props> = ({
}, [advancedDataTypesState, validationErrors]);

useEffect(() => {
fetchAdvancedDataTypeValueCallback(
rawValues,
advancedDataTypesState,
ensureIsArray(advancedDataType)[0],
);
if (rawValues.length > 0) {
fetchAdvancedDataTypeValueCallback(
rawValues,
advancedDataTypesState,
ensureIsArray(advancedDataType)[0],
);
}
}, [advancedDataType, rawValues, subjectAdvancedDataType]);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangeDatasourceModal } from 'src/components/Datasource';
import { withTheme } from '@superset-ui/core';
import { connect, useDispatch } from 'react-redux';
import Button from 'src/components/Button';
import { updateFormDataByDatasource } from 'src/explore/actions/exploreActions';
import { updateCCCSFormDataByDatasource } from 'src/explore/actions/exploreActions';

export interface Props {
colorScheme: string;
Expand Down Expand Up @@ -32,7 +32,7 @@ const ChangeDatasourceButtonControll: React.FC<Props> = ({
setShowChangeDatasourceModal(!showChangeDatasourceModal);
};
const onDatasourceSave = (new_datasource: any) => {
dispatch(updateFormDataByDatasource(datasource, new_datasource));
dispatch(updateCCCSFormDataByDatasource(datasource, new_datasource));
};
const onChangeWrapper = (a: any) => {
onChange(a);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React, { useEffect, useState } from 'react';
import { SLOW_DEBOUNCE, SupersetClient, t, withTheme } from '@superset-ui/core';
import {
NO_TIME_RANGE,
SLOW_DEBOUNCE,
SupersetClient,
t,
withTheme,
} from '@superset-ui/core';
import {
buildTimeRangeString,
formatTimeRange,
Expand All @@ -21,7 +27,7 @@ export interface Props {
name: string;
actions: object;
label: string;
value?: object[];
value?: string;
onChange: (value: any, errors: any[]) => void;
default: string;
disabled: boolean;
Expand Down Expand Up @@ -52,9 +58,17 @@ const fetchTimeRange = async (timeRange: string) => {
};

const DatetimeControl: React.FC<Props> = props => {
const [timeRange, setTimeRange] = useState(props.default);
// if the value passed in is "no filter", leave the control empty
// if the value does not exist, set it to the default
const [timeRange, setTimeRange] = useState(
props.value
? props.value === NO_TIME_RANGE
? ''
: props.value
: props.default,
);
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const [actualTimeRange, setactualTimeRange] = useState<string>();
const [actualTimeRange, setActualTimeRange] = useState<string>();

const [since, until] = timeRange.split(SEPARATOR);

Expand All @@ -64,7 +78,9 @@ const DatetimeControl: React.FC<Props> = props => {

function onChange(control: 'since' | 'until', value: string) {
if (control === 'since') {
setTimeRange(`${value}${SEPARATOR}${until}`);
setTimeRange(
until ? `${value}${SEPARATOR}${until}` : `${value}${SEPARATOR}`,
);
} else {
setTimeRange(`${since}${SEPARATOR}${value}`);
}
Expand All @@ -74,7 +90,7 @@ const DatetimeControl: React.FC<Props> = props => {
() => {
fetchTimeRange(timeRange)
.then(value => {
setactualTimeRange(
setActualTimeRange(
value?.value ? `Actual Time Range ${value?.value}` : '',
);
setValidationErrors(value?.error ? [value?.error] : []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ensureIsArray,
getMetricLabel,
PostProcessingRule,
QueryFormColumn,
QueryMode,
QueryObject,
removeDuplicates,
Expand Down Expand Up @@ -125,7 +126,7 @@ const buildQuery: BuildQuery<CccsGridQueryFormData> = (
const { advanced_data_type_value } = formData;
const { advanced_data_type_selection } = formData;
let filter = [];
if (advanced_data_type_selection.length > 0) {
if (ensureIsArray(advanced_data_type_selection).length > 0) {
// in the case of ipv4s sometimes they can be ranges and not simple values
// this will be handled in the advanced data type definition in the future
// to avoid this complex logic
Expand All @@ -152,8 +153,21 @@ const buildQuery: BuildQuery<CccsGridQueryFormData> = (
[],
);
}

// load the time range as a filter if it exists
if (baseQueryObject.granularity) {
baseQueryObject.filters?.push({
col: baseQueryObject.granularity as QueryFormColumn,
op: 'TEMPORAL_RANGE',
val: baseQueryObject.time_range || '',
});
}

const baseQueryObjectCopy = baseQueryObject;
baseQueryObjectCopy.granularity = undefined;

const queryObject = {
...baseQueryObject,
...baseQueryObjectCopy,
formData: formDataCopy,
orderby,
metrics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ const config: ControlPanelConfig = {
'expression',
),
clearable: false,
optionRenderer: (c: any) => (
<StyledColumnOption column={c} showType />
),
valueKey: 'column_name',
rerender: ['time_range'],
mapStateToProps: state => {
Expand All @@ -141,12 +138,23 @@ const config: ControlPanelConfig = {
state.datasource &&
'granularity_sqla' in state.datasource
) {
props.choices = state.datasource.granularity_sqla;
props.default = null;
props.options = state.datasource.columns
.filter(c =>
ensureIsArray(
(state.datasource as Dataset)?.granularity_sqla,
)
.map(g => g[0])
.includes(c.column_name),
)
.map(c => ({
label: c.verbose_name ? c.verbose_name : c.column_name,
column_name: c.column_name,
}));
props.default = undefined;
if (state.datasource.main_dttm_col) {
props.default = state.datasource.main_dttm_col;
} else if (props.choices && props.choices.length > 0) {
props.default = props.choices[0].column_name;
} else if (props.options && props.options.length > 0) {
props.default = props.options.column_name;
}
}
return props;
Expand Down
13 changes: 13 additions & 0 deletions superset-frontend/src/explore/actions/exploreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ export function updateFormDataByDatasource(
};
}

export const UPDATE_CCCS_FORM_DATA_BY_DATASOURCE =
'UPDATE_CCCS_FORM_DATA_BY_DATASOURCE';
export function updateCCCSFormDataByDatasource(
prevDatasource: Dataset,
newDatasource: Dataset,
) {
return {
type: UPDATE_CCCS_FORM_DATA_BY_DATASOURCE,
prevDatasource,
newDatasource,
};
}

export const POST_DATASOURCE_STARTED = 'POST_DATASOURCE_STARTED';
export const FETCH_DATASOURCE_SUCCEEDED = 'FETCH_DATASOURCE_SUCCEEDED';
export function fetchDatasourceSucceeded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ const INITIAL_ADVANCED_DATA_TYPES_STATE: AdvancedDataTypesState = {
values: [],
};

const useAdvancedDataTypes = (validHandler: (isValid: boolean) => void) => {
const useAdvancedDataTypes = (
validHandler: (isValid: boolean) => void,
default_state: AdvancedDataTypesState = INITIAL_ADVANCED_DATA_TYPES_STATE,
) => {
const [advancedDataTypesState, setAdvancedDataTypesState] =
useState<AdvancedDataTypesState>(INITIAL_ADVANCED_DATA_TYPES_STATE);
useState<AdvancedDataTypesState>(default_state);
const [subjectAdvancedDataType, setSubjectAdvancedDataType] = useState<
string | undefined
>();
Expand Down
95 changes: 95 additions & 0 deletions superset-frontend/src/explore/reducers/exploreReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,101 @@ export default function exploreReducer(state = {}, action) {
controlsTransferred,
};
},
[actions.UPDATE_CCCS_FORM_DATA_BY_DATASOURCE]() {
const newFormData = { ...state.form_data };
const { prevDatasource, newDatasource } = action;
const controls = { ...state.controls };
const controlsTransferred = [];

if (
prevDatasource.id !== newDatasource.id ||
prevDatasource.type !== newDatasource.type
) {
newFormData.datasource = newDatasource.uid;
}
// reset control values for column/metric related controls
Object.entries(controls).forEach(([controlName, controlState]) => {
if (
// for direct column select controls
controlState.valueKey === 'column_name' ||
// for all other controls
'savedMetrics' in controlState ||
'columns' in controlState ||
('options' in controlState && !Array.isArray(controlState.options))
) {
newFormData[controlName] = getControlValuesCompatibleWithDatasource(
newDatasource,
controlState,
controlState.value,
);
if (
ensureIsArray(newFormData[controlName]).length > 0 &&
newFormData[controlName] !== controls[controlName].default
) {
controlsTransferred.push(controlName);
}
}
});

const newState = {
...state,
controls,
datasource: action.newDatasource,
};
const newControls = getControlsState(newState, newFormData);

if (newControls.advanced_data_type_selection) {
// filter out incompatible Advanced Data Types in the new Datasource
const advancedDataTypeSelectionControl =
newControls.advanced_data_type_selection;
newFormData.advanced_data_type_selection = newDatasource.columns.some(
c => c.advanced_data_type === advancedDataTypeSelectionControl.value,
)
? advancedDataTypeSelectionControl.value
: [];
newControls.advanced_data_type_selection.value =
newFormData.advanced_data_type_selection;
// check if the new datasource has any columns with the same Advanced Data Type
if (
ensureIsArray(newFormData.advanced_data_type_selection).length > 0
) {
// transfer the control to use the new columns
newControls.advanced_data_type_value.value[0].columns =
newDatasource.columns
.filter(
c =>
c.advanced_data_type ===
advancedDataTypeSelectionControl.value,
)
.map(c => c.column_name);
controlsTransferred.push('advanced_data_type_selection');
controlsTransferred.push('advanced_data_type_value');
} else {
// if there are no compatible columns, clear the controls and disable the value control
newControls.advanced_data_type_value.value = [
{ columns: [], data: [], rawData: [] },
];
newControls.advanced_data_type_value.disabled = true;
newControls.advanced_data_type_value.advancedDataType = [];
newFormData.advanced_data_type_value =
newControls.advanced_data_type_value.value;
}
}
// check if date column is compatible with new datasource
if (!newDatasource.columns.includes(newFormData.granularity_sqla)) {
// set the time column to the new default time column
newControls.granularity_sqla.value = newDatasource.main_dttm_col;
newFormData.granularity_sqla = newDatasource.main_dttm_col;
// disable the time range if there is no default
newControls.time_range.disabled = !newDatasource.main_dttm_col;
}
return {
...newState,
form_data: newFormData,
controls: newControls,
controlsTransferred,
};
},
[actions.FETCH_DATASOURCES_STARTED]() {
return {
...state,
Expand Down