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

svletecheck --ignore cleanup: fix most of "time-controls" folder #3651

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
run: |-
npx prettier --check "web-common/**/*"
npx eslint web-common --quiet
npx svelte-check --threshold error --workspace web-common --no-tsconfig --ignore "src/components/data-graphic,src/features/dashboards/(time-series|time-controls)"
npx svelte-check --threshold error --workspace web-common --no-tsconfig --ignore "src/components/data-graphic,src/features/dashboards/time-series,src/features/dashboards/time-controls/TimeRangeSelector.svelte,src/features/dashboards/time-controls/TimeControls.svelte"

- name: Prettier checks and lint for web local
if: steps.filter.outputs.local == 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ This component needs to do the following:
<MenuItem
selected={option.name === intermediateSelection}
on:before-select={() => {
intermediateSelection = option.name;
if (option.name) {
intermediateSelection = option.name;
}
}}
on:select={() => {
enableComparison("dimension", option.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
start: Date,
end: Date,
minTimeGrain: V1TimeGrain
): string {
): string | undefined {
const allowedTimeGrains = getAllowedTimeGrains(start, end);
const allowedMaxGrain = allowedTimeGrains[allowedTimeGrains.length - 1];

Expand All @@ -80,7 +80,7 @@
}

// HAM, you left off here.
let error = undefined;
let error: string | undefined = undefined;
$: if (start && end) {
error = validateTimeRange(
parseLocaleStringDate(start),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
$runtime.instanceId,
modelName
);
$: timestampColumns = $timestampColumnsQuery?.data;

// CAST SAFETY: must be string[], since we filter out undefined values
$: timestampColumns =
($timestampColumnsQuery?.data?.filter(
(x) => x !== undefined
) as string[]) ?? [];

$: isReadOnlyDashboard = $featureFlags.readOnly === true;

$: redirectToScreen = timestampColumns?.length > 0 ? "metrics" : "model";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
const queryClient = useQueryClient();
$: dashboardStore = useDashboardStore(metricViewName);

let baseTimeRange: TimeRange;
let minTimeGrain: V1TimeGrain;
let baseTimeRange: TimeRange | undefined;
let minTimeGrain: V1TimeGrain | undefined;
let availableTimeZones: string[] = [];

$: metaQuery = useMetaQuery($runtime.instanceId, metricViewName);
Expand All @@ -61,7 +61,7 @@
!!$metaQuery?.data?.table &&
!!$metaQuery?.data?.timeDimension
) {
availableTimeZones = $metaQuery?.data?.availableTimeZones;
availableTimeZones = $metaQuery?.data?.availableTimeZones ?? [];

/**
* Remove the timezone selector if no timezone key is present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

$: dashboardStore = useDashboardStore(metricViewName);
$: activeTimeGrain = $timeControlsStore.selectedTimeRange?.interval;
$: activeTimeGrainLabel = TIME_GRAIN[activeTimeGrain]?.label;
$: activeTimeGrainLabel =
activeTimeGrain && TIME_GRAIN[activeTimeGrain]?.label;

$: timeGrains = timeGrainOptions
? timeGrainOptions
Expand Down
22 changes: 16 additions & 6 deletions web-common/src/features/entity-management/resource-status-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export function initialResourceStatusStore(
([resourceName, projectParserResp]) => {
if (
!projectParserResp.data ||
projectParserResp.data.projectParser.state.parseErrors.filter(
(projectParserResp?.data?.projectParser?.state?.parseErrors?.filter(
(s) => s.filePath === filePath
).length > 0
).length ?? 0) > 0
) {
return ResourceStatus.Errored;
}
Expand Down Expand Up @@ -106,12 +106,17 @@ export function resourceStatusStore(
)
return { status: ResourceStatus.Busy };

const changed =
!lastUpdatedOn ||
(res.data?.meta?.stateUpdatedOn !== undefined
? res.data?.meta?.stateUpdatedOn > lastUpdatedOn
: false);

return {
status: !res.data?.meta?.reconcileError
? ResourceStatus.Idle
: ResourceStatus.Errored,
changed:
!lastUpdatedOn || res.data?.meta?.stateUpdatedOn > lastUpdatedOn,
changed,
};
}
);
Expand Down Expand Up @@ -144,13 +149,18 @@ export function waitForResourceUpdate(
if (status.status === ResourceStatus.Busy) return;
if (timer) clearTimeout(timer);

const do_end =
status.status === ResourceStatus.Idle &&
status.changed !== undefined &&
status.changed;

if (idled) {
end(status.status === ResourceStatus.Idle && status.changed);
end(do_end);
return;
} else {
idled = true;
timer = setTimeout(() => {
end(status.status === ResourceStatus.Idle && status.changed);
end(do_end);
}, 500);
}
});
Expand Down