From bf2ae74bfde70a2da995ab7e3bb38901ff96aef7 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 20 Aug 2024 18:05:43 +0700 Subject: [PATCH] fix: fileID representation of SQL report files --- .../src/components/ReportFile/ReportFile.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ui/packages/platform/src/components/ReportFile/ReportFile.tsx b/ui/packages/platform/src/components/ReportFile/ReportFile.tsx index e1106028..6614b0b9 100644 --- a/ui/packages/platform/src/components/ReportFile/ReportFile.tsx +++ b/ui/packages/platform/src/components/ReportFile/ReportFile.tsx @@ -6,7 +6,7 @@ */ import { Component, HTMLAttributeAnchorTarget } from 'react' -import { TextField, Button } from '@material-ui/core' +import { Button, TextField } from '@material-ui/core' import ReactMarkdown from 'react-markdown' import rehypeRaw from 'rehype-raw' import remarkGfm from 'remark-gfm' @@ -124,15 +124,13 @@ const textAreaStyles = ( class ReportFile extends Component { getFileId() { - let id = parseInt(this.props.match.params.fileId, 10) - /* eslint eqeqeq: 1 */ - id = - id == parseInt(this.props.match.params.fileId) - ? id - : parseInt(this.props.match.params.fileId) - /* eslint eqeqeq: 0 */ - - return id + let fileID = this.props.match.params.fileId + let parseID = parseInt(fileID, 10) + + // To distinct different fileIDs. For example, "72215" and "1_1.sql". + // {ORG_URL}/reports/268/files/72215/md + // {ORG_URL}/reports/268/files/1_1.sql/sql?raw + return (fileID.toString() == parseID.toString()) ? parseID : fileID } componentDidMount() {