diff --git a/studio/components/grid/components/formatter/ForeignKeyFormatter.tsx b/studio/components/grid/components/formatter/ForeignKeyFormatter.tsx index 7ab84e7dab5..edb9b9084c3 100644 --- a/studio/components/grid/components/formatter/ForeignKeyFormatter.tsx +++ b/studio/components/grid/components/formatter/ForeignKeyFormatter.tsx @@ -34,9 +34,9 @@ export const ForeignKeyFormatter = ( return (
-

+ {value === null ? : value} -

+
) diff --git a/studio/components/grid/components/grid/ColumnHeader.tsx b/studio/components/grid/components/grid/ColumnHeader.tsx index bee2b472b4c..59759b12cf2 100644 --- a/studio/components/grid/components/grid/ColumnHeader.tsx +++ b/studio/components/grid/components/grid/ColumnHeader.tsx @@ -134,7 +134,11 @@ export function ColumnHeader({ function renderColumnIcon(type: ColumnType) { switch (type) { case 'foreign_key': - return + return ( +
+ +
+ ) default: return null } diff --git a/studio/components/grid/components/header/Header.tsx b/studio/components/grid/components/header/Header.tsx index f3ec5f36a83..2d44e7e15e9 100644 --- a/studio/components/grid/components/header/Header.tsx +++ b/studio/components/grid/components/header/Header.tsx @@ -1,141 +1,128 @@ -import * as React from 'react'; -import { useDispatch, useTrackedState } from '../../store'; -import { - Button, - Divider, - IconDownload, - IconPlus, - IconX, - IconTrash, - Typography, -} from '@supabase/ui'; -import FileSaver from 'file-saver'; -import FilterDropdown from './filter'; -import SortPopover from './sort'; -import StatusLabel from './StatusLabel'; -import RefreshButton from './RefreshButton'; -import { exportRowsToCsv } from '../../utils'; -import { showConfirmAlert } from '../common'; +import * as React from 'react' +import { useDispatch, useTrackedState } from '../../store' +import { Button, Divider, IconDownload, IconPlus, IconX, IconTrash, Typography } from '@supabase/ui' +import FileSaver from 'file-saver' +import FilterDropdown from './filter' +import SortPopover from './sort' +import StatusLabel from './StatusLabel' +import RefreshButton from './RefreshButton' +import { exportRowsToCsv } from '../../utils' +import { showConfirmAlert } from '../common' type HeaderProps = { - onAddColumn?: () => void; - onAddRow?: () => void; - headerActions?: React.ReactNode; -}; + onAddColumn?: () => void + onAddRow?: () => void + headerActions?: React.ReactNode +} -const Header: React.FC = ({ - onAddColumn, - onAddRow, - headerActions, -}) => { - const state = useTrackedState(); - const { selectedRows } = state; +const Header: React.FC = ({ onAddColumn, onAddRow, headerActions }) => { + const state = useTrackedState() + const { selectedRows } = state return ( -
-
- {selectedRows.size > 0 ? ( - - ) : ( - - )} -
+
+ {selectedRows.size > 0 ? ( + + ) : ( + + )}
{headerActions}
- ); -}; -export default Header; + ) +} +export default Header type DefaultHeaderProps = { - onAddColumn?: () => void; - onAddRow?: () => void; -}; -const DefaultHeader: React.FC = ({ - onAddColumn, - onAddRow, -}) => { + onAddColumn?: () => void + onAddRow?: () => void +} +const DefaultHeader: React.FC = ({ onAddColumn, onAddRow }) => { const renderNewColumn = (onAddColumn?: () => void) => { - if (!onAddColumn) return null; - return ( - - ); - }; - - const renderAddRow = (onAddRow?: () => void) => { - if (!onAddRow) return null; + if (!onAddColumn) return null return ( + ) + } + + const renderAddRow = (onAddRow?: () => void) => { + if (!onAddRow) return null + return ( + - ); - }; + ) + } return ( - <> - - - - - {renderNewColumn(onAddColumn)} - {renderAddRow(onAddRow)} - - ); -}; +
+
+ + + +
+
+
+ {renderNewColumn(onAddColumn)} + {renderAddRow(onAddRow)} +
+
+ ) +} -type RowHeaderProps = {}; +type RowHeaderProps = {} const RowHeader: React.FC = ({}) => { - const state = useTrackedState(); - const dispatch = useDispatch(); + const state = useTrackedState() + const dispatch = useDispatch() - const { selectedRows, rows: allRows, editable } = state; + const { selectedRows, rows: allRows, editable } = state const onRowsDelete = () => { showConfirmAlert({ title: 'Confirm to delete', - message: - 'Are you sure you want to delete the selected rows? This action cannot be undone.', + message: 'Are you sure you want to delete the selected rows? This action cannot be undone.', onConfirm: async () => { - const rowIdxs = Array.from(selectedRows) as number[]; - const rows = allRows.filter((x) => rowIdxs.includes(x.idx)); - const { error } = state.rowService!.delete(rows); + const rowIdxs = Array.from(selectedRows) as number[] + const rows = allRows.filter((x) => rowIdxs.includes(x.idx)) + const { error } = state.rowService!.delete(rows) if (error) { - if (state.onError) state.onError(error); + if (state.onError) state.onError(error) } else { - dispatch({ type: 'REMOVE_ROWS', payload: { rowIdxs } }); + dispatch({ type: 'REMOVE_ROWS', payload: { rowIdxs } }) dispatch({ type: 'SELECTED_ROWS_CHANGE', payload: { selectedRows: new Set() }, - }); + }) } }, - }); - }; + }) + } function onRowsExportCsv() { - const rows = allRows.filter((x) => selectedRows.has(x.idx)); - const csv = exportRowsToCsv(state.table!.columns, rows); - const csvData = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); - FileSaver.saveAs(csvData, `${state.table!.name}_rows.csv`); + const rows = allRows.filter((x) => selectedRows.has(x.idx)) + const csv = exportRowsToCsv(state.table!.columns, rows) + const csvData = new Blob([csv], { type: 'text/csv;charset=utf-8;' }) + FileSaver.saveAs(csvData, `${state.table!.name}_rows.csv`) } function deselectRows() { dispatch({ type: 'SELECTED_ROWS_CHANGE', payload: { selectedRows: new Set() }, - }); + }) } return ( @@ -147,11 +134,7 @@ const RowHeader: React.FC = ({}) => { onClick={deselectRows} />
- + {selectedRows.size > 1 ? `${selectedRows.size} rows selected` : `${selectedRows.size} row selected`} @@ -160,7 +143,8 @@ const RowHeader: React.FC = ({}) => { {editable && ( <> - + - ); -}; -export default RefreshButton; + ) +} +export default RefreshButton diff --git a/studio/components/grid/components/header/filter/FilterPopover.tsx b/studio/components/grid/components/header/filter/FilterPopover.tsx index 512b6000117..817cae1d318 100644 --- a/studio/components/grid/components/header/filter/FilterPopover.tsx +++ b/studio/components/grid/components/header/filter/FilterPopover.tsx @@ -1,40 +1,37 @@ -import React, { FC } from 'react'; -import { Button, IconPlus, IconFilter, Popover } from '@supabase/ui'; -import { useDispatch, useTrackedState } from '../../../store'; -import FilterRow from './FilterRow'; +import React, { FC } from 'react' +import { Button, IconPlus, IconFilter, Popover } from '@supabase/ui' +import { useDispatch, useTrackedState } from '../../../store' +import FilterRow from './FilterRow' const FilterPopover: FC = () => { - const state = useTrackedState(); + const state = useTrackedState() const btnText = state.filters.length > 0 - ? `Filtered by ${state.filters.length} rule${ - state.filters.length > 1 ? 's' : '' - }` - : 'Filter'; + ? `Filtered by ${state.filters.length} rule${state.filters.length > 1 ? 's' : ''}` + : 'Filter' return ( - } - > + }> - ); -}; -export default FilterPopover; + ) +} +export default FilterPopover const Filter: FC = () => { - const state = useTrackedState(); - const dispatch = useDispatch(); + const state = useTrackedState() + const dispatch = useDispatch() function onAddFilter() { dispatch({ @@ -44,27 +41,19 @@ const Filter: FC = () => { operator: '=', value: '', }, - }); + }) } return (
{state.filters.map((_, index) => ( - + ))} {state.filters.length == 0 && (
-
- No filters applied to this view -
-

- Add a column below to filter the view -

+
No filters applied to this view
+

Add a column below to filter the view

)}
@@ -75,5 +64,5 @@ const Filter: FC = () => {
- ); -}; + ) +} diff --git a/studio/components/grid/components/header/sort/SortPopover.tsx b/studio/components/grid/components/header/sort/SortPopover.tsx index 30431861154..d2d09548afe 100644 --- a/studio/components/grid/components/header/sort/SortPopover.tsx +++ b/studio/components/grid/components/header/sort/SortPopover.tsx @@ -1,70 +1,63 @@ -import React, { FC } from 'react'; -import { Button, IconList, IconChevronDown, Popover } from '@supabase/ui'; -import { DropdownControl } from '../../common'; -import { useDispatch, useTrackedState } from '../../../store'; -import SortRow from './SortRow'; +import React, { FC } from 'react' +import { Button, IconList, IconChevronDown, Popover } from '@supabase/ui' +import { DropdownControl } from '../../common' +import { useDispatch, useTrackedState } from '../../../store' +import SortRow from './SortRow' const SortPopover: FC = () => { - const state = useTrackedState(); + const state = useTrackedState() const btnText = state.sorts.length > 0 - ? `Sorted by ${state.sorts.length} rule${ - state.sorts.length > 1 ? 's' : '' - }` - : 'Sort'; + ? `Sorted by ${state.sorts.length} rule${state.sorts.length > 1 ? 's' : ''}` + : 'Sort' return ( - } - > + }> - ); -}; -export default SortPopover; + ) +} +export default SortPopover const Sort: FC = () => { - const state = useTrackedState(); - const dispatch = useDispatch(); + const state = useTrackedState() + const dispatch = useDispatch() const columns = state?.table?.columns!.filter((x) => { - const found = state.sorts.find((y) => y.column == x.name); - return !found; - }); + const found = state.sorts.find((y) => y.column == x.name) + return !found + }) const dropdownOptions = columns?.map((x) => { - return { value: x.name, label: x.name }; - }) || []; + return { value: x.name, label: x.name } + }) || [] function onAddSort(columnName: string | number) { dispatch({ type: 'ADD_SORT', payload: { column: columnName, ascending: true }, - }); + }) } return ( -
+
{state.sorts.map((x, index) => ( ))} {state.sorts.length == 0 && (
-
- No sorts applied to this view -
-

- Add a column below to sort the view -

+
No sorts applied to this view
+

Add a column below to sort the view

)} @@ -83,15 +76,13 @@ const Sort: FC = () => { iconRight={} className="sb-grid-dropdown__item-trigger" > - {`Pick ${ - state.sorts.length > 1 ? 'another' : 'a' - } column to sort by`} + {`Pick ${state.sorts.length > 1 ? 'another' : 'a'} column to sort by`} ) : ( -

All columns have been added

+

All columns have been added

)}
- ); -}; + ) +} diff --git a/studio/styles/grid.scss b/studio/styles/grid.scss index 39438d13854..5a5717514bc 100644 --- a/studio/styles/grid.scss +++ b/studio/styles/grid.scss @@ -10,7 +10,7 @@ .rdg-cell { @apply flex; @apply border-scale-400 dark:border-scale-500 border-r border-b text-sm; - @apply text-typography-body-light dark:text-typography-body-dark; + @apply text-scale-1200; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -129,12 +129,6 @@ @apply hover:bg-bg-secondary-light dark:hover:bg-bg-secondary-dark; } - .rdg-row .rdg-cell span, -/* .rdg-row .rdg-cell svg, */ -.rdg-row .rdg-cell div { - @apply text-typography-body-light dark:text-typography-body-dark; - } - .tab-cursor { cursor: pointer !important; } @@ -466,18 +460,17 @@ } .sb-grid-column-header__inner { - @apply flex items-center space-x-2 overflow-hidden overflow-ellipsis; + @apply flex items-center gap-2 overflow-hidden overflow-ellipsis; } .sb-grid-column-header__inner__name { - @apply overflow-hidden overflow-ellipsis text-sm; - @apply text-typography-body-light dark:text-typography-body-dark; + @apply text-scale-1200 overflow-hidden overflow-ellipsis text-xs; } .sb-grid-column-header__inner__format { @apply text-xs; @apply overflow-hidden overflow-ellipsis font-normal; - @apply text-typography-body-secondary-light dark:text-typography-body-secondary-dark; + @apply text-scale-1000; } .sb-grid-column-header__inner__primary-key { @@ -485,8 +478,7 @@ } .sb-grid-column-header__inner svg { - @apply mr-1; - @apply border-green-900 text-green-900 dark:border-green-900 dark:text-green-900; + @apply border-brand-900 text-brand-900 dark:border-brand-900 dark:text-brand-900; } /*