Skip to content

Commit

Permalink
Hide the 'create agent' button when there are no keys / Remove the ca…
Browse files Browse the repository at this point in the history
…llout when invalidating a key
  • Loading branch information
gbamparop committed Dec 6, 2021
1 parent de2585e commit 2d30f02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { ConfirmDeleteModal } from './confirm_delete_modal';

interface Props {
agentKeys: ApiKey[];
refetchAgentKeys: () => void;
onKeyDelete: () => void;
}

export function AgentKeysTable({ agentKeys, refetchAgentKeys }: Props) {
export function AgentKeysTable({ agentKeys, onKeyDelete }: Props) {
const [agentKeyToBeDeleted, setAgentKeyToBeDeleted] = useState<ApiKey>();

const columns: Array<EuiBasicTableColumn<ApiKey>> = [
Expand Down Expand Up @@ -159,7 +159,7 @@ export function AgentKeysTable({ agentKeys, refetchAgentKeys }: Props) {
agentKey={agentKeyToBeDeleted}
onConfirm={() => {
setAgentKeyToBeDeleted(undefined);
refetchAgentKeys();
onKeyDelete();
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export function AgentKeys() {
content = (
<AgentKeysTable
agentKeys={agentKeys ?? []}
refetchAgentKeys={refetchAgentKeys}
onKeyDelete={() => {
setCreatedAgentKey(undefined);
refetchAgentKeys();
}}
/>
);
}
Expand All @@ -182,7 +185,7 @@ export function AgentKeys() {
</h2>
</EuiTitle>
</EuiFlexItem>
{areApiKeysEnabled && canManage && (
{areApiKeysEnabled && canManage && !isEmpty(agentKeys) && (
<EuiFlexItem grow={false}>
<EuiButton
onClick={() => setIsFlyoutVisible(true)}
Expand Down

0 comments on commit 2d30f02

Please sign in to comment.