EnxDev commented on code in PR #45272:
URL: https://github.com/apache/superset/pull/45272#discussion_r4276227630
##########
superset-frontend/src/features/apiKeys/ApiKeyCreateModal.tsx:
##########
@@ -58,6 +58,18 @@ export function ApiKeyCreateModal({
const [createdKey, setCreatedKey] = useState<string | null>(null);
const [copied, setCopied] = useState(false);
const copyTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+ // Scopes the current user may self-issue; null until loaded (or when the
+ // lookup fails), in which case the full catalog is offered as before.
+ const [allowedScopes, setAllowedScopes] = useState<string[] | null>(null);
Review Comment:
`null` means both "still loading" and "lookup failed", so for the first
moment after opening the Select offers all 32 scopes. A user who picks one
before the fetch lands keeps it in the form even after the options shrink, and
gets the 400 on save.
Could we start from a separate loading state (`undefined`, or a flag passed
to the Select's `loading`) and only fall back to the full catalog on the actual
error?
##########
superset-frontend/src/features/apiKeys/ApiKeyCreateModal.tsx:
##########
@@ -85,7 +97,12 @@ export function ApiKeyCreateModal({
setCreatedKey(key);
addSuccessToast(t('API key created successfully'));
} catch (error) {
- addDangerToast(t('Failed to create API key'));
+ const { message } = await getClientErrorObject(error);
+ addDangerToast(
+ message
+ ? `${t('Failed to create API key')}: ${message}`
+ : t('Failed to create API key'),
+ );
Review Comment:
Gluing the server message onto `t(...)` with a template literal fixes the
word order for translators. The rest of the app uses a `%s` msgid for this,
e.g. `ThemeList` does `t('Failed to set system default theme: %s',
err.message)`.
```suggestion
addDangerToast(
message
? t('Failed to create API key: %s', message)
: t('Failed to create API key'),
);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]