Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/account-security/DeviceActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const DeviceActivity = () => {

const signOutSession = async (
session: SessionRepresentation,
device: DeviceRepresentation
device: DeviceRepresentation,
) => {
try {
await deleteSession(session.id);
Expand Down Expand Up @@ -233,7 +233,7 @@ const DeviceActivity = () => {
</Grid>
</DataListContent>
</DataListItemRow>
))
)),
)}
</DataListItem>
</DataList>
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/account-security/LinkedAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const LinkedAccounts = () => {

const linkedAccounts = useMemo(
() => accounts.filter((account) => account.connected),
[accounts]
[accounts],
);

const unLinkedAccounts = useMemo(
() => accounts.filter((account) => !account.connected),
[accounts]
[accounts],
);

return (
Expand Down
8 changes: 4 additions & 4 deletions js/apps/account-ui/src/account-security/SigningIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const SigningIn = () => {
usePromise((signal) => getCredentials({ signal }), setCredentials, [key]);

const credentialRowCells = (
credMetadata: CredentialMetadataRepresentation
credMetadata: CredentialMetadataRepresentation,
) => {
const credential = credMetadata.credential;
const maxWidth = { "--pf-u-max-width--MaxWidth": "300px" } as CSSProperties;
Expand All @@ -98,7 +98,7 @@ const SigningIn = () => {
<strong className="pf-u-mr-md"></strong>
{{ date: formatDate(new Date(credential.createdDate)) }}
</Trans>
</DataListCell>
</DataListCell>,
);
}
return items;
Expand Down Expand Up @@ -188,15 +188,15 @@ const SigningIn = () => {
addAlert(
t("successRemovedMessage", {
userLabel: label(meta.credential),
})
}),
);
refresh();
} catch (error) {
addError(
t("errorRemovedMessage", {
userLabel: label(meta.credential),
error,
}).toString()
}).toString(),
);
}
}}
Expand Down
18 changes: 9 additions & 9 deletions js/apps/account-ui/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { joinPath } from "./utils/joinPath";
export const fetchResources = async (
params: RequestInit,
requestParams: Record<string, string>,
shared: boolean | undefined = false
shared: boolean | undefined = false,
): Promise<{ data: Resource[]; links: Links }> => {
const response = await get(
`/resources${shared ? "/shared-with-me?" : "?"}${new URLSearchParams(
requestParams
requestParams,
)}`,
params
params,
);

let links: Links;
Expand All @@ -32,19 +32,19 @@ export const fetchResources = async (

export const fetchPermission = async (
params: RequestInit,
resourceId: string
resourceId: string,
): Promise<Permission[]> => {
const response = await request<Permission[]>(
`/resources/${resourceId}/permissions`,
params
params,
);
return checkResponse(response);
};

export const updateRequest = (
resourceId: string,
username: string,
scopes: Scope[] | string[]
scopes: Scope[] | string[],
) =>
request(`/resources/${resourceId}/permissions`, {
method: "put",
Expand All @@ -53,7 +53,7 @@ export const updateRequest = (

export const updatePermissions = (
resourceId: string,
permissions: Permission[]
permissions: Permission[],
) =>
request(`/resources/${resourceId}/permissions`, {
method: "put",
Expand All @@ -71,7 +71,7 @@ async function get(path: string, params: RequestInit): Promise<Response> {
"realms",
environment.realm,
"account",
path
path,
);

const response = await fetch(url, {
Expand All @@ -90,7 +90,7 @@ async function get(path: string, params: RequestInit): Promise<Response> {

async function request<T>(
path: string,
params: RequestInit
params: RequestInit,
): Promise<T | undefined> {
const response = await get(path, params);
if (response.status !== 204) return response.json();
Expand Down
8 changes: 4 additions & 4 deletions js/apps/account-ui/src/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function getSupportedLocales({
}

export async function savePersonalInfo(
info: UserRepresentation
info: UserRepresentation,
): Promise<void> {
const response = await request("/", { body: info, method: "POST" });
if (!response.ok) {
Expand All @@ -49,11 +49,11 @@ export async function savePersonalInfo(

export async function getPermissionRequests(
resourceId: string,
{ signal }: CallOptions = {}
{ signal }: CallOptions = {},
): Promise<Permission[]> {
const response = await request(
`/resources/${resourceId}/permissions/requests`,
{ signal }
{ signal },
);

return parseResponse<Permission[]>(response);
Expand Down Expand Up @@ -110,7 +110,7 @@ export async function unLinkAccount(account: LinkedAccountRepresentation) {

export async function linkAccount(account: LinkedAccountRepresentation) {
const redirectUri = encodeURIComponent(
joinPath(environment.authUrl, "realms", environment.realm, "account")
joinPath(environment.authUrl, "realms", environment.realm, "account"),
);
const response = await request("/linked-accounts/" + account.providerName, {
searchParams: { providerId: account.providerName, redirectUri },
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/api/parse-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function parseResponse<T>(response: Response): Promise<T> {

if (!isJSON) {
throw new Error(
`Expected response to have a JSON content type, got '${contentType}' instead.`
`Expected response to have a JSON content type, got '${contentType}' instead.`,
);
}

Expand Down Expand Up @@ -48,6 +48,6 @@ function getErrorMessage(data: unknown): string {
}

throw new Error(
"Unable to retrieve error message from response, no matching key found."
"Unable to retrieve error message from response, no matching key found.",
);
}
6 changes: 3 additions & 3 deletions js/apps/account-ui/src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export type RequestOptions = {

export async function request(
path: string,
{ signal, method, searchParams, body }: RequestOptions = {}
{ signal, method, searchParams, body }: RequestOptions = {},
): Promise<Response> {
const url = new URL(
joinPath(environment.authUrl, "realms", environment.realm, "account", path)
joinPath(environment.authUrl, "realms", environment.realm, "account", path),
);

if (searchParams) {
Object.entries(searchParams).forEach(([key, value]) =>
url.searchParams.set(key, value)
url.searchParams.set(key, value),
);
}

Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/applications/Applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const Applications = () => {
usePromise(
(signal) => getApplications({ signal }),
(clients) => setApplications(clients.map((c) => ({ ...c, open: false }))),
[key]
[key],
);

const toggleOpen = (clientId: string) => {
setApplications([
...applications!.map((a) =>
a.clientId === clientId ? { ...a, open: !a.open } : a
a.clientId === clientId ? { ...a, open: !a.open } : a,
),
]);
};
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/components/format/format-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export default function useFormatter() {
return {
formatDate: function (
date: Date,
options: Intl.DateTimeFormatOptions | undefined = DATE_AND_TIME_FORMAT
options: Intl.DateTimeFormatOptions | undefined = DATE_AND_TIME_FORMAT,
) {
return date.toLocaleString("en", options);
},
formatTime: function (
time: number,
options: Intl.DateTimeFormatOptions | undefined = TIME_FORMAT
options: Intl.DateTimeFormatOptions | undefined = TIME_FORMAT,
) {
return new Intl.DateTimeFormat("en", options).format(time);
},
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/components/formatter/format-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export default function useFormatter() {
return {
formatDate: function (
date: Date,
options: Intl.DateTimeFormatOptions | undefined = DATE_AND_TIME_FORMAT
options: Intl.DateTimeFormatOptions | undefined = DATE_AND_TIME_FORMAT,
) {
return date.toLocaleString("en", options);
},
formatTime: function (
time: number,
options: Intl.DateTimeFormatOptions | undefined = TIME_FORMAT
options: Intl.DateTimeFormatOptions | undefined = TIME_FORMAT,
) {
return new Intl.DateTimeFormat("en", options).format(time);
},
Expand Down
6 changes: 3 additions & 3 deletions js/apps/account-ui/src/groups/Groups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const Groups = () => {
getParents(
el,
groups,
groups.map(({ path }) => path)
)
groups.map(({ path }) => path),
),
);
}
setGroups(groups);
},
[directMembership]
[directMembership],
);

const getParents = (el: Group, groups: Group[], groupsPaths: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion js/apps/account-ui/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ const root = createRoot(container!);
root.render(
<StrictMode>
<RouterProvider router={router} />
</StrictMode>
</StrictMode>,
);
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/personal-info/LocaleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const LocaleSelector = () => {
locales.map<SelectControlOption>((locale) => ({
key: locale,
value: localeToDisplayName(locale) || "",
}))
)
})),
),
);

return (
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/personal-info/PersonalInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const PersonalInfo = () => {
(personalInfo) => {
setUserProfileMetadata(personalInfo.userProfileMetadata);
reset(personalInfo);
}
},
);

const onSubmit = async (user: UserRepresentation) => {
Expand All @@ -61,7 +61,7 @@ const PersonalInfo = () => {
(error as FieldError[]).forEach((e) => {
const params = Object.assign(
{},
e.params.map((p) => (isBundleKey(p) ? unWrap(p) : p))
e.params.map((p) => (isBundleKey(p) ? unWrap(p) : p)),
);
setError(fieldName(e.field) as keyof UserRepresentation, {
message: t(e.errorMessage as TFuncKey, {
Expand Down
4 changes: 2 additions & 2 deletions js/apps/account-ui/src/resources/EditTheResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const EditTheResource = ({
try {
await Promise.all(
permissions.map((permission) =>
updatePermissions(resource._id, [permission])
)
updatePermissions(resource._id, [permission]),
),
);
addAlert(t("updateSuccess"));
onClose();
Expand Down
6 changes: 3 additions & 3 deletions js/apps/account-ui/src/resources/PermissionRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ export const PermissionRequest = ({

const approveDeny = async (
shareRequest: Permission,
approve: boolean = false
approve: boolean = false,
) => {
try {
const permissions = await fetchPermission({}, resource._id);
const { scopes, username } = permissions.find(
(p) => p.username === shareRequest.username
(p) => p.username === shareRequest.username,
)!;

await updateRequest(
resource._id,
username,
approve
? [...(scopes as string[]), ...(shareRequest.scopes as string[])]
: scopes
: scopes,
);
addAlert(t("shareSuccess"));
toggle();
Expand Down
12 changes: 6 additions & 6 deletions js/apps/account-ui/src/resources/ResourcesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ export const ResourcesTab = () => {
await Promise.all(
result.data.map(
async (r) =>
(r.shareRequests = await getPermissionRequests(r._id, { signal }))
)
(r.shareRequests = await getPermissionRequests(r._id, { signal })),
),
);
return result;
},
({ data, links }) => {
setResources(data);
setLinks(links);
},
[params, key]
[params, key],
);

if (!resources) {
Expand All @@ -102,7 +102,7 @@ export const ResourcesTab = () => {
({
username,
scopes: [],
} as Permission)
}) as Permission,
)!;
await updatePermissions(resource._id, permissions);
setDetails({});
Expand All @@ -115,7 +115,7 @@ export const ResourcesTab = () => {
const toggleOpen = async (
id: string,
field: keyof PermissionDetail,
open: boolean
open: boolean,
) => {
const permissions = await fetchPermissions(id);

Expand Down Expand Up @@ -162,7 +162,7 @@ export const ResourcesTab = () => {
toggleOpen(
resource._id,
"rowOpen",
!details[resource._id]?.rowOpen
!details[resource._id]?.rowOpen,
),
}}
/>
Expand Down
Loading