Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(options/etapi): improve layout to match new design
Elian Doran76a632c9778b
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 9fd4a8fd24..9ddb1f2c52 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1605,6 +1605,7 @@"create_token": "Create new ETAPI token","existing_tokens": "Existing tokens","no_tokens_yet": "There are no tokens yet. Click on the button above to create one.",+ "no_tokens": "There are no tokens yet.","token_name": "Token name","created": "Created","actions": "Actions",diff --git a/apps/client/src/widgets/type_widgets/options/etapi.tsx b/apps/client/src/widgets/type_widgets/options/etapi.tsxindex c1d354d3f3..328e62b196 100644--- a/apps/client/src/widgets/type_widgets/options/etapi.tsx+++ b/apps/client/src/widgets/type_widgets/options/etapi.tsx@@ -1,17 +1,17 @@+import { EtapiToken, PostTokensResponse } from "@triliumnext/commons";import { useCallback, useEffect, useState } from "preact/hooks";++import dialog from "../../../services/dialog";import { t } from "../../../services/i18n";-import Button from "../../react/Button";-import FormText from "../../react/FormText";-import RawHtml from "../../react/RawHtml";-import OptionsSection from "./components/OptionsSection";-import { EtapiToken, PostTokensResponse } from "@triliumnext/commons";import server from "../../../services/server";import toast from "../../../services/toast";-import dialog from "../../../services/dialog";import { formatDateTime } from "../../../utils/formatters";import ActionButton from "../../react/ActionButton";+import Button from "../../react/Button";import { useTriliumEvent } from "../../react/hooks";-import HelpButton from "../../react/HelpButton";+import NoItems from "../../react/NoItems";+import OptionsRow from "./components/OptionsRow";+import OptionsSection from "./components/OptionsSection";type RenameTokenCallback = (tokenId: string, oldName: string) => Promise<void>;type DeleteTokenCallback = (tokenId: string, name: string ) => Promise<void>;@@ -52,24 +52,23 @@ export default function EtapiSettings() {}, []);return (- <OptionsSection title={t("etapi.title")}>- <FormText>- {t("etapi.description")}- <HelpButton helpPage="pgxEVkzLl1OP" />- </FormText>-- <Button- size="small" icon="bx bx-plus"- text={t("etapi.create_token")}- onClick={createTokenCallback}- />-- <hr />-- <h5>{t("etapi.existing_tokens")}</h5>+ <OptionsSection+ title={t("etapi.title")}+ description={t("etapi.description")}+ helpUrl="pgxEVkzLl1OP"+ ><TokenList tokens={tokens} />++ <OptionsRow name="create-etapi-token" centered>+ <Button+ name="create-etapi-token-button"+ size="micro" icon="bx bx-plus"+ text={t("etapi.create_token")}+ onClick={createTokenCallback}+ />+ </OptionsRow></OptionsSection>- )+ );}function TokenList({ tokens }: { tokens: EtapiToken[] }) {@@ -95,46 +94,36 @@ function TokenList({ tokens }: { tokens: EtapiToken[] }) {await server.remove(`etapi-tokens/${tokenId}`);}, []);- return (- tokens.length ? (- <div style={{ overflow: "auto"}}>- <table className="table table-stripped">- <thead>- <tr>- <th>{t("etapi.token_name")}</th>- <th>{t("etapi.created")}</th>- <th>{t("etapi.actions")}</th>- </tr>- </thead>- <tbody>- {tokens.map(({ etapiTokenId, name, utcDateCreated}) => (- <tr>- <td>{name}</td>- <td>{formatDateTime(utcDateCreated)}</td>- <td>- {etapiTokenId && (- <>- <ActionButton- icon="bx bx-edit-alt"- text={t("etapi.rename_token")}- onClick={() => renameCallback(etapiTokenId, name)}- />-- <ActionButton- icon="bx bx-trash"- text={t("etapi.delete_token")}- onClick={() => deleteCallback(etapiTokenId, name)}- />- </>- )}- </td>- </tr>- ))}- </tbody>- </table>- </div>- ) : (- <div>{t("etapi.no_tokens_yet")}</div>- )- );+ if (!tokens.length) {+ return <NoItems icon="bx bx-key" text={t("etapi.no_tokens")} />;+ }++ return <>+ {tokens.map(({ etapiTokenId, name, utcDateCreated }) => (+ <OptionsRow+ key={etapiTokenId ?? name}+ name="etapi-token"+ label={name}+ description={formatDateTime(utcDateCreated)}+ >+ <div>+ {etapiTokenId && (+ <>+ <ActionButton+ icon="bx bx-edit-alt"+ text={t("etapi.rename_token")}+ onClick={() => renameCallback(etapiTokenId, name)}+ />++ <ActionButton+ icon="bx bx-trash"+ text={t("etapi.delete_token")}+ onClick={() => deleteCallback(etapiTokenId, name)}+ />+ </>+ )}+ </div>+ </OptionsRow>+ ))}+ </>;}