Skip to content

Commit

Permalink
Have only one source of truth for TAB LABELS
Browse files Browse the repository at this point in the history
  • Loading branch information
guergana committed Dec 14, 2024
1 parent 915e094 commit 26682e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 5 additions & 3 deletions client/components/Editors/Dialect/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export default function Layout() {
const helpItem = useStore((state) => state.helpItem)
const { t } = useTranslation()
const MENU_ITEMS: types.IMenuItem[] = [
{ section: 'dialect', name: t('dialect') },
{ section: 'dialect', name: t('default') },
{ section: 'dialect/format', name: capitalize(format) || t('format') },
]
const MENU_LABELS = [t('dialect'), t('format')]

const MENU_LABELS = MENU_ITEMS.map((item) => item.name)

return (
<Box sx={{ height: '100%', padding: 2 }}>
<Box sx={{ height: '100%' }}>
<SimpleTabs
labels={MENU_LABELS}
orientation="vertical"
Expand Down
10 changes: 2 additions & 8 deletions client/components/Editors/Resource/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ export default function Layout() {
const TOP_TAB_LABELS = [t('resource'), t('dialect'), t('schema')]

const RESOURCE_MENU_ITEMS: types.IMenuItem[] = [
{ section: 'resource', name: t('resource') },
{ section: 'resource', name: t('default') },
{ section: 'resource/integrity', name: t('integrity') },
{ section: 'resource/licenses', name: t('licenses') },
{ section: 'resource/contributors', name: t('contributors') },
{ section: 'resource/sources', name: t('sources') },
]

const MENU_LABELS = [
t('resource'),
t('integrity'),
t('licenses'),
t('contributors'),
t('sources'),
]
const MENU_LABELS = RESOURCE_MENU_ITEMS.map((item) => item.name)

// We use memo to avoid nested editors re-rerender
const handleDialectChange = React.useMemo(() => {
Expand Down
7 changes: 4 additions & 3 deletions client/components/Editors/Schema/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ export default function Layout() {
const helpItem = useStore((state) => state.helpItem)
const { t } = useTranslation()
const MENU_ITEMS: types.IMenuItem[] = [
{ section: 'schema', name: t('schema') },
{ section: 'schema', name: t('default') },
{ section: 'schema/fields', name: t('fields') },
{ section: 'schema/foreignKeys', name: t('foreign-keys') },
]

const MENU_LABELS = [t('schema'), t('fields'), t('foreign-keys')]
const MENU_LABELS = MENU_ITEMS.map((item) => item.name)

return (
<Box sx={{ padding: 2, height: '100%' }}>
<Box sx={{ height: '100%' }}>
<SimpleTabs
labels={MENU_LABELS}
orientation="vertical"
Expand Down

0 comments on commit 26682e7

Please sign in to comment.