Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add scopes and resource allow-list to API tokens#20249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ThomasK33 wants to merge1 commit intothomask33/10-09-add_scope_catalog_api
base:thomask33/10-09-add_scope_catalog_api
Choose a base branch
Loading
fromthomask33/10-09-add_token_scope_management
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -536,6 +536,14 @@ class ApiMethods {
return response.data;
};

getToken = async (tokenName: string): Promise<TypesGen.APIKey> => {
const response = await this.axios.get<TypesGen.APIKey>(
`/api/v2/users/me/keys/tokens/${tokenName}`,
);

return response.data;
};

deleteToken = async (keyId: string): Promise<void> => {
await this.axios.delete(`/api/v2/users/me/keys/${keyId}`);
};
Expand All@@ -551,6 +559,18 @@ class ApiMethods {
return response.data;
};

updateToken = async (
tokenName: string,
params: TypesGen.UpdateTokenRequest,
): Promise<TypesGen.APIKey> => {
const response = await this.axios.patch<TypesGen.APIKey>(
`/api/v2/users/me/keys/tokens/${tokenName}`,
params,
);

return response.data;
};

getTokenConfig = async (): Promise<TypesGen.TokenConfig> => {
const response = await this.axios.get(
"/api/v2/users/me/keys/tokens/tokenconfig",
Expand All@@ -559,6 +579,14 @@ class ApiMethods {
return response.data;
};

getScopeCatalog = async (): Promise<TypesGen.ScopeCatalog> => {
const response = await this.axios.get<TypesGen.ScopeCatalog>(
"/api/v2/auth/scopes",
);

return response.data;
};

getUsers = async (
options: TypesGen.UsersRequest,
signal?: AbortSignal,
Expand Down
10 changes: 10 additions & 0 deletionssite/src/api/queries/tokens.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
import { API } from "api/api";
import type { APIKeyWithOwner, TokensFilter } from "api/typesGenerated";
import type { QueryOptions } from "react-query";

export const tokens = (filter: TokensFilter) => {
return {
queryKey: ["tokens", filter.include_all],
queryFn: () => API.getTokens(filter),
} satisfies QueryOptions<APIKeyWithOwner[]>;
};
84 changes: 55 additions & 29 deletionssite/src/components/MultiSelectCombobox/MultiSelectCombobox.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -108,11 +108,15 @@ interface MultiSelectComboboxProps {
"data-testid"?: string;
}

interface MultiSelectComboboxRef {
exportinterface MultiSelectComboboxRef {
selectedValue: Option[];
input: HTMLInputElement;
focus: () => void;
reset: () => void;
setInputValue: (
value: string,
options?: { focus?: boolean; open?: boolean },
) => void;
}

function transitionToGroupOption(options: Option[], groupBy?: string) {
Expand DownExpand Up@@ -211,38 +215,60 @@ export const MultiSelectCombobox = forwardRef<
}: MultiSelectComboboxProps,
ref,
) => {
const inputRef = useRef<HTMLInputElement>(null);
const [open, setOpen] = useState(false);
const [onScrollbar, setOnScrollbar] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
const listRef = useRef<HTMLDivElement>(null);

const [selected, setSelected] = useState<Option[]>(
arrayDefaultOptions ?? [],
);
const [options, setOptions] = useState<GroupOption>(
transitionToGroupOption(arrayDefaultOptions, groupBy),
);
const [inputValue, setInputValue] = useState("");
const debouncedSearchTerm = useDebouncedValue(inputValue, delay || 500);
const inputRef = useRef<HTMLInputElement>(null);
const [open, setOpen] = useState(false);
const [onScrollbar, setOnScrollbar] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
const listRef = useRef<HTMLDivElement>(null);

const [selected, setSelected] = useState<Option[]>(
arrayDefaultOptions ?? [],
);
const [options, setOptions] = useState<GroupOption>(
transitionToGroupOption(arrayDefaultOptions, groupBy),
);
const [inputValue, setInputValueState] = useState("");
const debouncedSearchTerm = useDebouncedValue(inputValue, delay || 500);

const setComboboxInputValue = useCallback(
(value: string, options?: { focus?: boolean; open?: boolean }) => {
setInputValueState(value);
if (options?.open === true) {
setOpen(true);
} else if (options?.open === false) {
setOpen(false);
} else if (value !== "" && !open) {
setOpen(true);
}
if (options?.focus) {
setTimeout(() => {
inputRef.current?.focus();
}, 0);
}
},
[open],
);

const [previousValue, setPreviousValue] = useState<Option[]>(value || []);
if (value && value !== previousValue) {
setPreviousValue(value);
setSelected(value);
}

useImperativeHandle(
ref,
() => ({
selectedValue: [...selected],
input: inputRef.current as HTMLInputElement,
focus: () => inputRef?.current?.focus(),
reset: () => setSelected([]),
}),
[selected],
);
useImperativeHandle(
ref,
() => ({
selectedValue: [...selected],
input: inputRef.current as HTMLInputElement,
focus: () => inputRef?.current?.focus(),
reset: () => setSelected([]),
setInputValue: (value: string, options?: { focus?: boolean; open?: boolean }) => {
setComboboxInputValue(value, options);
},
}),
[selected, setComboboxInputValue],
);

const handleUnselect = useCallback(
(option: Option) => {
Expand DownExpand Up@@ -398,7 +424,7 @@ export const MultiSelectCombobox = forwardRef<
onMaxSelected?.(selected.length);
return;
}
setInputValue("");
setComboboxInputValue("");
const newOptions = [...selected, { value, label: value }];
setSelected(newOptions);
onChange?.(newOptions);
Expand DownExpand Up@@ -554,7 +580,7 @@ export const MultiSelectCombobox = forwardRef<
value={inputValue}
disabled={disabled}
onValueChange={(value) => {
setInputValue(value);
setInputValueState(value);
inputProps?.onValueChange?.(value);
}}
onBlur={(event) => {
Expand DownExpand Up@@ -663,7 +689,7 @@ export const MultiSelectCombobox = forwardRef<
onMaxSelected?.(selected.length);
return;
}
setInputValue("");
setComboboxInputValue("");
const newOptions = [...selected, option];
setSelected(newOptions);
onChange?.(newOptions);
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp