Skip to content

Commit

Permalink
fix: table strucre error and error component
Browse files Browse the repository at this point in the history
  • Loading branch information
invm authored and Michael Ionov committed Jan 15, 2024
1 parent 8ac0290 commit a164128
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/components/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { useAppSelector } from 'services/Context';
import { ConnectionsService } from 'services/Connections';
import { t } from 'utils/i18n';
import { OpenIssue } from './Screens/Settings/OpenIssue';
import { relaunch } from '@tauri-apps/api/process';

const Error = (props: { err: Record<'message' | 'stack', string> }) => {
console.log({ error: props.err, stack: props.err?.stack });

const {
connections: { clearStore },
} = useAppSelector();

return (
<div class="flex flex-col items-center justify-center h-full w-full">
<h2 class="text-xl font-bold"> Something went wrong </h2>
<div class="flex flex-col items-center justify-center h-full w-full px-20">
<h2 class="text-xl font-bold text-error">{t('error.something_went_wrong')}</h2>
<OpenIssue />
<br />

<button class="btn btn-sm btn-secondary" onClick={async () => await clearStore()}>
<button class="btn btn-sm btn-secondary" onClick={async () => await ConnectionsService().clearStore()}>
{t('settings.clear_cache')}
</button>
<span class="text-lg">{props.err.message}</span>
<br />
<h4>Stack: </h4>
<button class="btn btn-sm btn-primary" onClick={async () => await relaunch()}>
{t('error.relaunch_app')}
</button>
<span class="text-lg pt-10">{props.err.message}</span>
<br />
<h4 class="text-xl font-bold text-error">{t('error.stack')}</h4>
<span class="text-lg">{props.err.stack}</span>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const TableStructureTab = () => {
{(item) => (
<Match when={item === tab()}>
<StructureTable
data={getContentData("TableStructure")[item]}
data={getContentData("TableStructure")[item] ?? []}
type={item}
dialect={getConnection().connection.dialect}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DialectType, Row, TableStrucureEntityType } from 'interfaces';

export const StructureTable = (props: { data: Row[]; dialect: DialectType; type: TableStrucureEntityType }) => {
const columns = Object.keys(props.data[0]);
const columns = Object.keys(props.data?.[0] ?? {});
const rows = props.data.map((row) => columns.map((column) => row[column]));
return (
<div class="overflow-x-auto">
Expand Down
5 changes: 5 additions & 0 deletions src/utils/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
"download": "Click here to update and relaod",
"release_notes": "Release notes",
"close": "Close"
},
"error":{
"something_went_wrong": "Something went wrong",
"stack": "Stack",
"relaunch_app": "Relaunch app"
}
}
}

0 comments on commit a164128

Please sign in to comment.