Skip to content

Commit

Permalink
consistent use of "tabulator" naming
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Sep 23, 2024
1 parent b7db103 commit 27e6d32
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions catalog/app/containers/Admin/Buckets/Buckets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1424,15 +1424,15 @@ function PreviewCard({
)
}

interface LongQueryConfigSingleProps extends Model.GQLTypes.TabulatorTable {}
interface TabulatorTableProps extends Model.GQLTypes.TabulatorTable {}

function LongQueryConfigSingle({ name, config }: LongQueryConfigSingleProps) {
function TabulatorTable({ name, config }: TabulatorTableProps) {
const json = React.useMemo(() => yaml.parse(config), [config])
// @ts-expect-error
return <JsonDisplay name={name} topLevel value={json} />
}

interface LongQueryConfigCardProps {
interface TabulatorCardProps {
bucket: string
className: string
disabled: boolean
Expand All @@ -1444,15 +1444,15 @@ interface LongQueryConfigCardProps {
}

// TODO: use dialog confirm
function LongQueryConfigCard({
function TabulatorCard({
bucket,
className,
disabled,
editing,
onEdit,
onDirty,
tabulatorTables,
}: LongQueryConfigCardProps) {
}: TabulatorCardProps) {
const { dirty } = OnDirty.use()
React.useEffect(() => onDirty(dirty), [dirty, onDirty])
const handleEdit = React.useCallback(
Expand Down Expand Up @@ -1488,7 +1488,7 @@ function LongQueryConfigCard({
>
{!!tabulatorTables.length &&
tabulatorTables.map((table, i) => (
<LongQueryConfigSingle {...table} key={`${table.name}_${i}`} />
<TabulatorTable {...table} key={`${table.name}_${i}`} />
))}
</Card>
)
Expand Down Expand Up @@ -2017,7 +2017,7 @@ function Edit({ bucket, back, submit, tabulatorTables }: EditProps) {
/>
</div>
<OnDirty.Provider>
<LongQueryConfigCard
<TabulatorCard
bucket={bucket.name}
className={classes.card}
disabled={disabled}
Expand Down
24 changes: 12 additions & 12 deletions catalog/app/containers/Admin/Buckets/Tabulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const validateConfig: FF.FieldValidator<string> = (inputStr?: string) => {
return undefined
}

const useLongQueryConfigFormStyles = M.makeStyles((t) => ({
const useTabulatorTableStyles = M.makeStyles((t) => ({
delete: {
color: t.palette.error.main,
marginBottom: 'auto',
Expand Down Expand Up @@ -144,25 +144,25 @@ const useLongQueryConfigFormStyles = M.makeStyles((t) => ({

type FormValues = Pick<Model.GQLTypes.TabulatorTable, 'name' | 'config'>

interface LongQueryConfigFormProps {
interface TabulatorTableProps {
bucketName: string
className: string
onEdited?: () => void
}

interface AddNew extends LongQueryConfigFormProps {
interface AddNew extends TabulatorTableProps {
onClose: () => void
tabulatorTable?: never // We create new config, so we don't have one
isLast: boolean
}

interface EditExisting extends LongQueryConfigFormProps {
interface EditExisting extends TabulatorTableProps {
onClose?: never // Don't close editing config
tabulatorTable: FormValues
isLast?: never
}

function LongQueryConfigForm({
function TabulatorTable({
bucketName,
className,
onClose,
Expand All @@ -171,7 +171,7 @@ function LongQueryConfigForm({
isLast,
}: AddNew | EditExisting) {
const setTabulatorTable = GQL.useMutation(SET_TABULATOR_TABLE_MUTATION)
const classes = useLongQueryConfigFormStyles()
const classes = useTabulatorTableStyles()

const { push: notify } = Notifications.use()

Expand Down Expand Up @@ -349,7 +349,7 @@ function LongQueryConfigForm({
)
}

const useConfigsStyles = M.makeStyles((t) => ({
const useStyles = M.makeStyles((t) => ({
item: {
position: 'relative',
'& + &': {
Expand Down Expand Up @@ -382,28 +382,28 @@ const useConfigsStyles = M.makeStyles((t) => ({
},
}))

interface ConfigsProps {
interface TabulatorProps {
bucket: string
tabulatorTables: Model.GQLTypes.BucketConfig['tabulatorTables']
onClose: () => void
}

export default function Configs({ bucket, onClose, tabulatorTables }: ConfigsProps) {
const classes = useConfigsStyles()
export default function Tabulator({ bucket, onClose, tabulatorTables }: TabulatorProps) {
const classes = useStyles()
loadMode('yaml')
const [toAdd, setToAdd] = React.useState(false)
return (
<>
{tabulatorTables.map((tabulatorTable) => (
<LongQueryConfigForm
<TabulatorTable
bucketName={bucket}
className={classes.item}
key={tabulatorTable.name}
tabulatorTable={tabulatorTable}
/>
))}
{((!!tabulatorTables.length && toAdd) || !tabulatorTables.length) && (
<LongQueryConfigForm
<TabulatorTable
bucketName={bucket}
className={classes.item}
isLast={!tabulatorTables.length}
Expand Down

0 comments on commit 27e6d32

Please sign in to comment.