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

[fix](com render sql): replace code for render sql com #190

Merged
merged 2 commits into from
Jan 25, 2024
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 packages/sqle/src/components/RenderSQL/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RenderSQLStyleWrapper } from './style';
const RenderSQL: React.FC<RenderSQLProps> = ({
sql,
rows = 10,
tooltip,
tooltip = true,
onClick
}) => {
if (!sql) {
Expand Down
15 changes: 5 additions & 10 deletions packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,75 +16,70 @@
import { IAuditPlanSQLHeadV1 } from '@actiontech/shared/lib/api/sqle/service/common';
import { AuditPlanSQLHeadV1TypeEnum } from '@actiontech/shared/lib/api/sqle/service/common.enum';
import { formatTime } from '@actiontech/shared/lib/utils/Common';
import HighlightCode from '../../../../utils/HighlightCode';
import { useTableRequestParams } from '@actiontech/shared/lib/components/ActiontechTable';

import RenderSQL from '../../../../components/RenderSQL';

const DetailCom = () => {
const { t } = useTranslation();

const urlParams = useParams<PlanDetailUrlParams>();
const { projectName } = useCurrentProject();

const {
data: auditTask,
run: getTaskInfo,
loading: taskLoading
} = useRequest(() => {
return audit_plan
.getAuditPlanV1({
audit_plan_name: urlParams.auditPlanName ?? '',
project_name: projectName
})
.then((res) => res.data);
});

const { pagination, tableChange } = useTableRequestParams();
const [columns, setColumns] = useState<ColumnType<any>[]>([]);

const {
loading,
data: sqlList,
refresh
} = useRequest(
() =>
audit_plan
.getAuditPlanSQLsV1({
project_name: projectName,
audit_plan_name: urlParams.auditPlanName ?? '',
page_index: pagination.page_index,
page_size: pagination.page_size
})
.then((res) => {
return {
head: res.data.data?.head,
list: res.data.data?.rows,
total: res.data.total_nums
};
}),
{
ready: !!urlParams.auditPlanName,
refreshDeps: [urlParams.auditPlanName, pagination],

onSuccess: (res) => {
const { head = [] } = res;
setColumns(
(head as IAuditPlanSQLHeadV1[]).map((item) => ({
title: item.desc,
dataIndex: item.name,
width: item.type === AuditPlanSQLHeadV1TypeEnum.sql ? 300 : 'auto',
width: item.type === AuditPlanSQLHeadV1TypeEnum.sql ? 500 : 'auto',

Check warning on line 75 in packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 75 in packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
render: (text) => {
if (item.type === AuditPlanSQLHeadV1TypeEnum.sql) {
// todo: RenderSQL
return (
<div className="sql-cont-width">
<pre
dangerouslySetInnerHTML={{
__html: HighlightCode.highlightSql(text)
}}
className="pre-warp-break-all"
></pre>
<div className="sql-cont-width" style={{ width: 500 }}>
<RenderSQL sql={text} />
</div>
);

Check warning on line 82 in packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 83 in packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 83 in packages/sqle/src/page/AuditPlan/PlanDetail/DetailCom/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
if (item.name === 'last_receive_timestamp') {
return formatTime(text);
Expand Down
Loading
Loading