Skip to content

Commit

Permalink
chore: old pipeline allowed to access dashboard (#1343)
Browse files Browse the repository at this point in the history
Co-authored-by: Meng Xin Zhu <[email protected]>
  • Loading branch information
tyyzqmf and zxkane authored May 20, 2024
1 parent 8d806b4 commit 91ddf7e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 56 deletions.
2 changes: 0 additions & 2 deletions frontend/public/locales/en-US/analytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@
"emptyData": "No Data",
"emptyDataMessage": "Please configure metrics to query",
"emptyExploreMessage": "There are no explore modules available for the current project",
"emptyAnalyzeMessage": "There are no analyses available for the current project",
"emptyDashboardMessage": "No dashboard data has been found yet",
"noDataAvailableTitle": "No clickstream data available for analytics",
"noDataAvailableMessage": "The solution did not find any project has clickstream data yet, please contact your system admin to start collecting data.",
"information": {
Expand Down
4 changes: 2 additions & 2 deletions frontend/public/locales/en-US/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dashboard": "Dashboard",
"realtime": "Realtime",
"explore": "Explore",
"analyzes": "Analyzes",
"analyzes": "Analyses",
"segments": "Segments",
"createSegment": "Create Segment",
"editSegment": "Edit Segment",
Expand All @@ -38,7 +38,7 @@
"realtime": "Realtime",
"dashboards": "Dashboards",
"explore": "Explore",
"analyzes": "Analyzes",
"analyzes": "Analyses",
"metadata": "Metadata",
"segments": "Segments",
"data-management": "Data Management"
Expand Down
2 changes: 0 additions & 2 deletions frontend/public/locales/zh-CN/analytics.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,6 @@
"emptyData": "无数据",
"emptyDataMessage": "请配置指标进行查询",
"emptyExploreMessage": "当前项目没有任何探索模块可用",
"emptyAnalyzeMessage": "当前项目尚未找到任何分析数据",
"emptyDashboardMessage": "尚未找到对应的仪表板",
"noDataAvailableTitle": "没有可用于分析的点击流数据",
"noDataAvailableMessage": "尚未找到任何具有点击流数据的项目,请与您的系统管理员联系以开始收集数据。",
"information": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ ul.menu-list li.checkbox-item {
width: 100%;
border: 0px;
overflow: 'hidden';
min-height: 100vh;
min-height: 200px;
&.fixed-height {
height: 100vh;
}
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/pages/analytics/comps/ExploreEmbedFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { Box, SpaceBetween } from '@cloudscape-design/components';
import { createEmbeddingContext } from 'amazon-quicksight-embedding-sdk';
import ExtendIcon from 'components/common/ExtendIcon';
import Loading from 'components/common/Loading';
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -97,20 +98,15 @@ const ExploreEmbedFrame: React.FC<ExploreEmbedFrameProps> = (
textAlign="center"
color="text-status-inactive"
>
<ExtendIcon icon="ClipboardData" color="#666" />
{embedPage === 'explore' && (
<SpaceBetween size="m">
<ExtendIcon icon="ClipboardData" color="#666" />
{t('analytics:emptyDataMessage')}
</SpaceBetween>
)}
{embedPage === 'dashboard' && (
{(embedPage === 'dashboard' || embedPage === 'analyze') && (
<SpaceBetween size="m">
{t('analytics:emptyDashboardMessage')}
</SpaceBetween>
)}
{embedPage === 'analyze' && (
<SpaceBetween size="m">
{t('analytics:emptyAnalyzeMessage')}
<Loading />
</SpaceBetween>
)}
</Box>
Expand Down
84 changes: 59 additions & 25 deletions frontend/src/pages/analytics/explore/AnalyticsExplore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ import AnalyticsFunnel from '../funnel/AnalyticsFunnel';
import AnalyticsPath from '../path/AnalyticsPath';
import AnalyticsRetention from '../retention/AnalyticsRetention';

const ExploreRenderCondition = {
Loading: 'Loading',
Empty: 'Empty',
Funnel: 'Funnel',
Event: 'Event',
Path: 'Path',
Retention: 'Retention',
Attribution: 'Attribution',
};

const AnalyticsExplore: React.FC = () => {
const { t } = useTranslation();
const { projectId, appId } = useParams();
Expand Down Expand Up @@ -99,6 +109,9 @@ const AnalyticsExplore: React.FC = () => {
];

const [pipeline, setPipeline] = useState<IPipeline | null>(null);
const [renderCondition, setRenderCondition] = useState<string>(
ExploreRenderCondition.Loading
);
const { data, loading } = useUserEventParameter();

const [pathNodes, setPathNodes] = useState<{
Expand Down Expand Up @@ -162,6 +175,26 @@ const AnalyticsExplore: React.FC = () => {
}
};

const setCondition = () => {
if (loadingData) {
setRenderCondition(ExploreRenderCondition.Loading);
} else if (!pipeline) {
setRenderCondition(ExploreRenderCondition.Empty);
} else if (!pipeline.templateInfo?.isLatest) {
setRenderCondition(ExploreRenderCondition.Empty);
} else if (selectedOption?.value === 'Funnel') {
setRenderCondition(ExploreRenderCondition.Funnel);
} else if (selectedOption?.value === 'Event') {
setRenderCondition(ExploreRenderCondition.Event);
} else if (selectedOption?.value === 'Path') {
setRenderCondition(ExploreRenderCondition.Path);
} else if (selectedOption?.value === 'Retention') {
setRenderCondition(ExploreRenderCondition.Retention);
} else if (selectedOption?.value === 'Attribution') {
setRenderCondition(ExploreRenderCondition.Attribution);
}
};

useEffect(() => {
if (projectId && appId) {
loadPipeline();
Expand All @@ -174,6 +207,10 @@ const AnalyticsExplore: React.FC = () => {
}
}, [selectedOption]);

useEffect(() => {
setCondition();
}, [pipeline, selectedOption, loadingData]);

useEffect(() => {
dispatch?.({ type: StateActionType.CLEAR_HELP_PANEL });
}, []);
Expand Down Expand Up @@ -242,8 +279,10 @@ const AnalyticsExplore: React.FC = () => {
</div>
</div>
</AnalyticsCustomHeader>
{loadingData && <Loading />}
{!pipeline && !loadingData && (
{renderCondition === ExploreRenderCondition.Loading && (
<Loading />
)}
{renderCondition === ExploreRenderCondition.Empty && (
<SpaceBetween direction="vertical" size="xxl">
<Container>
<Box textAlign="center" color="inherit">
Expand All @@ -259,8 +298,7 @@ const AnalyticsExplore: React.FC = () => {
</SpaceBetween>
)}
{pipeline &&
!loadingData &&
selectedOption?.value === 'Funnel' && (
renderCondition === ExploreRenderCondition.Funnel && (
<AnalyticsFunnel
loadingEvents={loading}
loading={false}
Expand All @@ -274,23 +312,21 @@ const AnalyticsExplore: React.FC = () => {
groupParameters={data.groupParameters}
/>
)}
{pipeline &&
!loadingData &&
selectedOption?.value === 'Event' && (
<AnalyticsEvent
loadingEvents={loading}
loading={false}
pipeline={pipeline}
builtInMetadata={data?.builtInMetaData}
metadataEvents={data?.metaDataEvents}
metadataEventParameters={data?.metaDataEventParameters}
metadataUserAttributes={data?.metaDataUserAttributes}
categoryEvents={data?.categoryEvents}
presetParameters={data.presetParameters}
groupParameters={data.groupParameters}
/>
)}
{pipeline && !loadingData && selectedOption?.value === 'Path' && (
{pipeline && renderCondition === ExploreRenderCondition.Event && (
<AnalyticsEvent
loadingEvents={loading}
loading={false}
pipeline={pipeline}
builtInMetadata={data?.builtInMetaData}
metadataEvents={data?.metaDataEvents}
metadataEventParameters={data?.metaDataEventParameters}
metadataUserAttributes={data?.metaDataUserAttributes}
categoryEvents={data?.categoryEvents}
presetParameters={data.presetParameters}
groupParameters={data.groupParameters}
/>
)}
{pipeline && renderCondition === ExploreRenderCondition.Path && (
<AnalyticsPath
loadingEvents={loading}
loading={false}
Expand All @@ -305,8 +341,7 @@ const AnalyticsExplore: React.FC = () => {
/>
)}
{pipeline &&
!loadingData &&
selectedOption?.value === 'Retention' && (
renderCondition === ExploreRenderCondition.Retention && (
<AnalyticsRetention
loadingEvents={loading}
loading={false}
Expand All @@ -321,8 +356,7 @@ const AnalyticsExplore: React.FC = () => {
/>
)}
{pipeline &&
!loadingData &&
selectedOption?.value === 'Attribution' && (
renderCondition === ExploreRenderCondition.Attribution && (
<AnalyticsAttribution
loadingEvents={loading}
loading={false}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const apiRequest = (

// Error handler
function errMsg(err: { response: { status: any; data: ApiResponse<null> } }) {
if (err && err.response) {
if (err && err.response && err.response.status >= 400) {
switch (err.response.status) {
case 400:
alertMsg(err.response?.data?.message);
Expand Down
15 changes: 2 additions & 13 deletions src/control-plane/backend/lambda/api/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,21 +1133,10 @@ function getIamRoleBoundaryArn(): string | undefined {
function pipelineAnalysisStudioEnabled(pipeline: IPipeline): boolean {
const redshiftStackVersionStr = getStackVersion(pipeline, PipelineStackType.DATA_MODELING_REDSHIFT);
const reportStackVersionStr = getStackVersion(pipeline, PipelineStackType.REPORTING);
if (!redshiftStackVersionStr || !reportStackVersionStr) {
if (!redshiftStackVersionStr || !reportStackVersionStr || !pipeline?.reporting?.quickSight?.accountName) {
return false;
}
const redshiftStackVersion = SolutionVersion.Of(redshiftStackVersionStr);
const reportStackVersion = SolutionVersion.Of(reportStackVersionStr);
const pipelineVersion = SolutionVersion.Of(pipeline.templateVersion ?? FULL_SOLUTION_VERSION);
if (
pipeline?.reporting?.quickSight?.accountName &&
pipelineVersion.greaterThanOrEqualTo(SolutionVersion.V_1_1_6) &&
redshiftStackVersion.greaterThanOrEqualTo(SolutionVersion.V_1_1_6) &&
reportStackVersion.greaterThanOrEqualTo(SolutionVersion.V_1_1_6)
) {
return true;
}
return false;
return true;
};

function getStackVersion(pipeline: IPipeline, stackType: PipelineStackType): string | undefined {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ export async function getDashboardTitleProps(analysisType: AnalysisType, query:
const t = await i18next.changeLanguage(locale);
let title = '';
let subTitle = ' ';
const tableTitle = t('dashboard.title.tableChart');
const tableTitle = query.chartTitle ? `${query.chartTitle} - ${t('dashboard.title.tableChart')}` : t('dashboard.title.tableChart');

if (query.action === ExploreRequestAction.PUBLISH) {
title = query.chartTitle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ describe('Pipeline test', () => {
solutionVersion: FULL_SOLUTION_VERSION,
},
templateVersion: 'v1.1.0',
analysisStudioEnabled: false,
analysisStudioEnabled: true,
},
});
});
Expand Down

0 comments on commit 91ddf7e

Please sign in to comment.