Skip to content

Commit

Permalink
fix: Dvt-table header if field === 'date' for formating date never to…
Browse files Browse the repository at this point in the history
… all coding for remove changes fixed
  • Loading branch information
omerfbolat committed May 20, 2024
1 parent 17f901e commit e5c6349
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 95 deletions.
18 changes: 9 additions & 9 deletions superset-frontend/src/components/DvtTable/dvt-table-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const TableData = {
],
iconExampleData: [
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -254,7 +254,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -264,7 +264,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -274,7 +274,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -284,7 +284,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -294,7 +294,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -304,7 +304,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -314,7 +314,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand All @@ -324,7 +324,7 @@ const TableData = {
sql: 'Select',
},
{
date: '2023.05.29 15:53:47 * 03:00',
date: '2023.05.29 15:53:47',
tabName: 'Pysical',
database: 'PostgreSQL',
schema: 'Public',
Expand Down
149 changes: 63 additions & 86 deletions superset-frontend/src/components/DvtTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ const DvtTable: React.FC<DvtTableProps> = ({
const [openRow, setOpenRow] = useState<number | null>(null);
const [collapseRowId, setCollapseRowId] = useState<string>('');

const formatDateTime = (dateTimeString: string) => {
const [datePart, timePart] = dateTimeString.split(' ');
const [day, month, year] = datePart.split('.');
const [hour, minute, second] = timePart.split(':');

const formattedDate = `${day}.${month}.${year}`;
const formattedTime = `${hour}:${minute}:${second}`;

return {
date: formattedDate,
time: formattedTime,
};
};
const totalFlex = header.reduce(
(total, header) => total + (header.flex || 1),
0,
Expand Down Expand Up @@ -437,80 +424,70 @@ const DvtTable: React.FC<DvtTableProps> = ({
{row[column.field]}
</StyledTableUrl>
)}
{column.field === 'date' ? (
<>
{formatDateTime(row[column.field]).date}
<br />
{formatDateTime(row[column.field]).time}
</>
) : (
<>
{column.clicks?.map(
(
clicks: {
icon: string;
click: (row: any) => void;
colour: string;
popperLabel?: string;
},
index,
) => (
<React.Fragment key={index}>
{clicks.popperLabel && (
<DvtPopper label={clicks.popperLabel}>
<Icon
onClick={() => clicks.click(row)}
fileName={clicks.icon}
iconColor={
clicks.colour ||
supersetTheme.colors.grayscale.dark2
}
iconSize="xl"
style={{
marginRight: 3.6,
visibility: column.showHover
? openRow === rowIndex
? 'visible'
: 'hidden'
: 'visible',
height: '56px',
display: 'flex',
alignItems: 'center',
}}
/>
</DvtPopper>
)}
{!clicks.popperLabel && (
<Icon
onClick={() => clicks.click(row)}
fileName={clicks.icon}
iconColor={
clicks.colour ||
supersetTheme.colors.grayscale.dark2
}
iconSize="xl"
style={{
marginRight: 3.6,
visibility: column.showHover
? openRow === rowIndex
? 'visible'
: 'hidden'
: 'visible',
}}
/>
)}
</React.Fragment>
),
)}

{column.field !== 'action' &&
!column.input &&
!column.editor &&
!column.radio &&
column.field &&
!column.urlField && <>{row[column.field]}</>}
</>
{column.clicks?.map(
(
clicks: {
icon: string;
click: (row: any) => void;
colour: string;
popperLabel?: string;
},
index,
) => (
<React.Fragment key={index}>
{clicks.popperLabel && (
<DvtPopper label={clicks.popperLabel}>
<Icon
onClick={() => clicks.click(row)}
fileName={clicks.icon}
iconColor={
clicks.colour ||
supersetTheme.colors.grayscale.dark2
}
iconSize="xl"
style={{
marginRight: 3.6,
visibility: column.showHover
? openRow === rowIndex
? 'visible'
: 'hidden'
: 'visible',
height: '56px',
display: 'flex',
alignItems: 'center',
}}
/>
</DvtPopper>
)}
{!clicks.popperLabel && (
<Icon
onClick={() => clicks.click(row)}
fileName={clicks.icon}
iconColor={
clicks.colour ||
supersetTheme.colors.grayscale.dark2
}
iconSize="xl"
style={{
marginRight: 3.6,
visibility: column.showHover
? openRow === rowIndex
? 'visible'
: 'hidden'
: 'visible',
}}
/>
)}
</React.Fragment>
),
)}

{column.field !== 'action' &&
!column.input &&
!column.editor &&
!column.radio &&
column.field &&
!column.urlField && <>{row[column.field]}</>}
</StyledTableIcon>
</StyledTableTd>
))}
Expand Down

0 comments on commit e5c6349

Please sign in to comment.