aminghadersohi commented on code in PR #37973:
URL: https://github.com/apache/superset/pull/37973#discussion_r2822670373
##########
requirements/base.txt:
##########
@@ -120,7 +120,7 @@ flask==2.3.3
# flask-session
# flask-sqlalchemy
# flask-wtf
-flask-appbuilder==5.0.2
+flask-appbuilder @
git+https://github.com/aminghadersohi/Flask-AppBuilder@amin/ch99414/api-key-auth
Review Comment:
Thanks for the review! Yes, absolutely — the FAB PR
(https://github.com/dpgaspar/Flask-AppBuilder/pull/2431) will be merged and
released first. Once it lands on PyPI, this will be reverted to a standard
version pin. The git reference is just for development/CI while both PRs are in
flight.
##########
superset-frontend/src/features/apiKeys/ApiKeyList.tsx:
##########
@@ -0,0 +1,226 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useCallback, useEffect, useState } from 'react';
+import { SupersetClient } from '@superset-ui/core';
+import { t } from '@apache-superset/core';
+import { css, useTheme } from '@apache-superset/core/ui';
+import {
+ Button,
+ Table,
+ Modal,
+ Tag,
+ Tooltip,
+} from '@superset-ui/core/components';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { ApiKeyCreateModal } from './ApiKeyCreateModal';
+
+export interface ApiKey {
+ uuid: string;
+ name: string;
+ key_prefix: string;
+ active: boolean;
+ created_on: string;
+ expires_on: string | null;
+ revoked_on: string | null;
+ last_used_on: string | null;
+ scopes: string | null;
+}
+
+export function ApiKeyList() {
+ const theme = useTheme();
+ const { addDangerToast, addSuccessToast } = useToasts();
+ const [apiKeys, setApiKeys] = useState<ApiKey[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [showCreateModal, setShowCreateModal] = useState(false);
+
+ const fetchApiKeys = useCallback(async () => {
+ setLoading(true);
+ try {
+ const response = await SupersetClient.get({
+ endpoint: '/api/v1/security/api_keys/',
+ });
+ setApiKeys(response.json.result || []);
+ } catch (error) {
+ addDangerToast(t('Failed to fetch API keys'));
+ } finally {
+ setLoading(false);
+ }
+ }, [addDangerToast]);
+
+ useEffect(() => {
+ fetchApiKeys();
+ }, [fetchApiKeys]);
Review Comment:
Good question\! Yes, the `useEffect` is needed here — it triggers the
initial data fetch when the component mounts. Without it, the API keys list
would never load. Since `fetchApiKeys` is an async side effect (API call), it
can't be called directly during render — `useEffect` is the standard React
pattern for this. The `fetchApiKeys` callback is stable (wrapped in
`useCallback`), so this effectively just fires once on mount.
##########
requirements/development.txt:
##########
@@ -262,7 +262,7 @@ flask==2.3.3
# flask-sqlalchemy
# flask-testing
# flask-wtf
-flask-appbuilder==5.0.2
+flask-appbuilder @
git+https://github.com/aminghadersohi/Flask-AppBuilder@amin/ch99414/api-key-auth
Review Comment:
Good call — pinned to commit `84e017b` for reproducible builds.
--
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]