codeant-ai-for-open-source[bot] commented on code in PR #44206:
URL: https://github.com/apache/superset/pull/44206#discussion_r4200913953
##########
superset-frontend/src/explore/components/controls/ViewQueryModal.tsx:
##########
@@ -44,14 +51,34 @@ type Result = {
error?: string;
};
+export function getSemanticReportState(
+ queriesResponse: readonly { query?: string }[] | null | undefined,
+): 'has-requests' | 'none-reported' | 'not-run' {
+ if (!queriesResponse?.length) {
+ return 'not-run';
+ }
+ return queriesResponse.some(entry => entry.query)
+ ? 'has-requests'
+ : 'none-reported';
+}
+
const ViewQueryModalContainer = styled.div`
height: 100%;
display: flex;
flex-direction: column;
- gap: ${({ theme }) => theme.sizeUnit * 4}px;
+ gap: ${({ theme }: { theme: SupersetTheme }) => theme.sizeUnit * 4}px;
`;
const ViewQueryModal: FC<Props> = ({ latestQueryFormData, ownState }) => {
+ const isSemanticView =
+ new DatasourceKey(latestQueryFormData.datasource).type ===
+ DatasourceType.SemanticView;
+ const queriesResponse = useSelector<
+ RootState,
+ ChartState['queriesResponse'] | undefined
+ >(
+ state => state.charts?.[latestQueryFormData.slice_id ??
0]?.queriesResponse,
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `3e2d2de`.
The chart-state selector now prefers the supplied `chartId` before falling
back to `latestQueryFormData.slice_id` or `0`.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset-frontend/src/explore/components/controls/ViewQueryModal.tsx:
##########
@@ -76,22 +103,51 @@ const ViewQueryModal: FC<Props> = ({ latestQueryFormData,
ownState }) => {
setError(null);
})
.catch(response => {
- getClientErrorObject(response).then(({ error, message }) => {
- setError(
- error ||
- message ||
- response.statusText ||
- t('Sorry, An error occurred'),
- );
- setIsLoading(false);
- });
+ getClientErrorObject(response).then(
+ ({ error, message }: ClientErrorObject) => {
+ setError(
+ error ||
+ message ||
+ response.statusText ||
+ t('Sorry, An error occurred'),
+ );
+ setIsLoading(false);
+ },
+ );
});
},
[latestQueryFormData, ownState],
);
useEffect(() => {
- loadChartData('query');
- }, [loadChartData]);
+ if (!isSemanticView) {
+ loadChartData('query');
+ }
+ }, [isSemanticView, loadChartData]);
+
+ if (isSemanticView) {
+ const reportState = getSemanticReportState(queriesResponse);
+ const noRequestMessage = t('No provider query is available for this run.');
+ return (
+ <ViewQueryModalContainer>
+ {reportState === 'not-run' ? (
+ <Alert
+ type="info"
+ message={t(
+ 'The provider query will be available after the chart runs.',
+ )}
+ />
+ ) : (
+ queriesResponse?.map((entry, index) =>
+ entry.query ? (
+ <SemanticRequestView key={index} requestText={entry.query} />
+ ) : (
+ <Alert key={index} type="info" message={noRequestMessage} />
+ ),
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `3e2d2de`.
Entries with an `error` now render an error alert, and the no-provider-query
fallback is shown only when an entry has neither an error nor a query.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]