added format command and added trailing commas to reduce conflicts

This commit is contained in:
dswbx
2025-02-26 20:06:03 +01:00
parent 88b5359f1c
commit 7743f71a11
414 changed files with 3622 additions and 3610 deletions

View File

@@ -12,11 +12,11 @@ import { routes, useNavigate } from "ui/lib/routes";
export function AuthIndex() {
const { app } = useBknd();
const {
config: { roles, strategies, entity_name, enabled }
config: { roles, strategies, entity_name, enabled },
} = useBkndAuth();
const users_entity = entity_name;
const $q = useApiQuery((api) => api.data.count(users_entity), {
enabled
enabled,
});
const usersTotal = $q.data?.count ?? 0;
const rolesTotal = Object.keys(roles ?? {}).length ?? 0;
@@ -57,9 +57,9 @@ export function AuthIndex() {
actions={[
{
label: "View all",
href: usersLink
href: usersLink,
},
{ label: "Add new", variant: "default", href: usersLink }
{ label: "Add new", variant: "default", href: usersLink },
]}
/>
<KpiCard
@@ -67,7 +67,7 @@ export function AuthIndex() {
value={!enabled ? 0 : rolesTotal}
actions={[
{ label: "View all", href: rolesLink },
{ label: "Manage", variant: "default", href: rolesLink }
{ label: "Manage", variant: "default", href: rolesLink },
]}
/>
<KpiCard
@@ -75,7 +75,7 @@ export function AuthIndex() {
value={!enabled ? 0 : strategiesTotal}
actions={[
{ label: "View all", href: strategiesLink },
{ label: "Manage", variant: "default", href: strategiesLink }
{ label: "Manage", variant: "default", href: strategiesLink },
]}
/>
</div>
@@ -120,7 +120,7 @@ const Item = ({ title, done = false, to }: { title: string; done?: boolean; to?:
<p
className={clsx(
"font-medium text-primary/80 leading-none",
done ? "line-through" : ""
done ? "line-through" : "",
)}
>
{title}

View File

@@ -54,14 +54,14 @@ function AuthRolesEditInternal({ params }) {
label: "Advanced Settings",
onClick: () =>
navigate(routes.settings.path(["auth", "roles", roleName]), {
absolute: true
})
absolute: true,
}),
},
{
label: "Delete",
onClick: handleDelete,
destructive: true
}
destructive: true,
},
]}
position="bottom-end"
>
@@ -77,7 +77,7 @@ function AuthRolesEditInternal({ params }) {
<Breadcrumbs2
path={[
{ label: "Roles & Permissions", href: routes.auth.roles.list() },
{ label: roleName }
{ label: roleName },
]}
/>
</AppShell.SectionHeader>

View File

@@ -16,8 +16,8 @@ export function AuthRolesList() {
role: name,
permissions: role.permissions,
is_default: role.is_default ?? false,
implicit_allow: role.implicit_allow ?? false
}))
implicit_allow: role.implicit_allow ?? false,
})),
);
function handleClick(row) {
@@ -31,14 +31,14 @@ export function AuthRolesList() {
schema: {
type: "object",
properties: {
name: StringIdentifier
name: StringIdentifier,
},
required: ["name"]
required: ["name"],
},
uiSchema: {
name: {
"ui:title": "Role name"
}
"ui:title": "Role name",
},
},
onSubmit: async (data) => {
if (data.name.length > 0) {
@@ -46,11 +46,11 @@ export function AuthRolesList() {
navigate(routes.auth.roles.edit(data.name));
}
}
}
},
},
{
title: "New Role"
}
title: "New Role",
},
);
}

View File

@@ -11,7 +11,7 @@ import {
type FieldProps,
Form,
FormDebug,
Subscribe
Subscribe,
} from "ui/components/form/json-schema-form";
import { useBrowserTitle } from "ui/hooks/use-browser-title";
import * as AppShell from "ui/layouts/AppShell/AppShell";
@@ -21,17 +21,17 @@ import { combine } from "zustand/middleware";
const useAuthSettingsStore = create(
combine(
{
advanced: [] as string[]
advanced: [] as string[],
},
(set) => ({
toggleAdvanced: (which: string) =>
set((state) => ({
advanced: state.advanced.includes(which)
? state.advanced.filter((w) => w !== which)
: [...state.advanced, which]
}))
})
)
: [...state.advanced, which],
})),
}),
),
);
export function AuthSettings(props) {
@@ -47,7 +47,7 @@ export function AuthSettings(props) {
const formConfig = {
ignoreKeys: ["roles", "strategies"],
options: { keepEmpty: true, debug: isDebug() }
options: { keepEmpty: true, debug: isDebug() },
};
function AuthSettingsInternal() {
@@ -66,7 +66,7 @@ function AuthSettingsInternal() {
selector={(state) => ({
dirty: state.dirty,
errors: state.errors.length > 0,
submitting: state.submitting
submitting: state.submitting,
})}
>
{({ dirty, errors, submitting }) => (

View File

@@ -11,7 +11,7 @@ import {
TbBrandInstagram,
TbBrandOauth,
TbBrandX,
TbSettings
TbSettings,
} from "react-icons/tb";
import { twMerge } from "tailwind-merge";
import { useBknd } from "ui/client/bknd";
@@ -28,7 +28,7 @@ import {
Subscribe,
useDerivedFieldContext,
useFormError,
useFormValue
useFormValue,
} from "ui/components/form/json-schema-form";
import { useBrowserTitle } from "ui/hooks/use-browser-title";
import * as AppShell from "../../layouts/AppShell/AppShell";
@@ -46,7 +46,7 @@ export function AuthStrategiesList(props) {
const formOptions = {
keepEmpty: true,
debug: isDebug()
debug: isDebug(),
};
function AuthStrategiesListInternal() {
@@ -57,8 +57,8 @@ function AuthStrategiesListInternal() {
// @ts-ignore
$auth.schema.properties.strategies.additionalProperties.anyOf.map((s) => [
s.properties.type.const,
s
])
s,
]),
);
async function handleSubmit(data: any) {
@@ -72,7 +72,7 @@ function AuthStrategiesListInternal() {
selector={(state) => ({
dirty: state.dirty,
errors: state.errors.length > 0,
submitting: state.submitting
submitting: state.submitting,
})}
>
{({ dirty, errors, submitting }) => (
@@ -127,8 +127,8 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
// @ts-ignore
$auth.schema.properties.strategies.additionalProperties.anyOf.map((s) => [
s.properties.type.const,
s
])
s,
]),
);
const schema = schemas[type];
const [open, setOpen] = useState(false);
@@ -141,7 +141,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
className={twMerge(
"flex flex-col border border-muted rounded bg-background",
unavailable && "opacity-20 pointer-events-none cursor-not-allowed",
errors.length > 0 && "border-red-500"
errors.length > 0 && "border-red-500",
)}
>
<div className="flex flex-row justify-between p-3 gap-3 items-center">
@@ -165,7 +165,7 @@ const Strategy = ({ type, name, unavailable }: StrategyProps) => {
{open && (
<div
className={twMerge(
"flex flex-col border-t border-t-muted px-4 pt-3 pb-4 bg-lightest/50 gap-4"
"flex flex-col border-t border-t-muted px-4 pt-3 pb-4 bg-lightest/50 gap-4",
)}
>
<StrategyForm type={type} />
@@ -216,7 +216,7 @@ const OAUTH_BRANDS = {
x: TbBrandX,
instagram: TbBrandInstagram,
apple: TbBrandAppleFilled,
discord: TbBrandDiscordFilled
discord: TbBrandDiscordFilled,
};
const StrategyForm = ({ type }: Pick<StrategyProps, "type">) => {

View File

@@ -31,16 +31,16 @@ export const AuthRoleForm = forwardRef<
watch,
control,
reset,
getValues
getValues,
} = useForm({
resolver: typeboxResolver(schema),
defaultValues: role
defaultValues: role,
});
useImperativeHandle(ref, () => ({
reset,
getData: () => getValues(),
isValid: () => isValid
isValid: () => isValid,
}));
return (
@@ -82,14 +82,14 @@ export const AuthRoleForm = forwardRef<
const Permissions = ({
control,
permissions
permissions,
}: Omit<UseControllerProps, "name"> & { permissions: string[] }) => {
const {
field: { value, onChange: fieldOnChange, ...field },
fieldState
fieldState,
} = useController<Static<typeof schema>, "permissions">({
name: "permissions",
control
control,
});
const data = value ?? [];
@@ -108,7 +108,7 @@ const Permissions = ({
acc[group].push(permission);
return acc;
},
{} as Record<string, string[]>
{} as Record<string, string[]>,
);
console.log("grouped", grouped);