fix a few secrets issues

This commit is contained in:
burnettk 2022-09-29 00:04:17 -04:00
parent fb6bb03716
commit ce3993b11c
4 changed files with 12 additions and 8 deletions

5
src/interfaces.ts Normal file
View File

@ -0,0 +1,5 @@
export interface Secret {
key: string;
value: string;
username: string;
}

View File

@ -1,7 +1,6 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Link, useSearchParams } from 'react-router-dom'; import { Link, useSearchParams } from 'react-router-dom';
import { Button, Table } from 'react-bootstrap'; import { Button, Table } from 'react-bootstrap';
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
import PaginationForTable from '../components/PaginationForTable'; import PaginationForTable from '../components/PaginationForTable';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { getPageInfoFromSearchParams } from '../helpers'; import { getPageInfoFromSearchParams } from '../helpers';
@ -66,7 +65,7 @@ export default function SecretList() {
/> />
); );
} else { } else {
displayText = <p>No Groups To Display</p>; displayText = <p>No Secrets to Display</p>;
} }
return displayText; return displayText;
}; };
@ -74,7 +73,6 @@ export default function SecretList() {
if (pagination) { if (pagination) {
return ( return (
<main style={{ padding: '1rem 0' }}> <main style={{ padding: '1rem 0' }}>
<ProcessBreadcrumb />
<Button href="/admin/secrets/new">Add a secret</Button> <Button href="/admin/secrets/new">Add a secret</Button>
<br /> <br />
<br /> <br />

View File

@ -2,7 +2,6 @@ import { useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import Button from 'react-bootstrap/Button'; import Button from 'react-bootstrap/Button';
import Form from 'react-bootstrap/Form'; import Form from 'react-bootstrap/Form';
import ProcessBreadcrumb from '../components/ProcessBreadcrumb';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
export default function SecretNew() { export default function SecretNew() {
@ -29,7 +28,6 @@ export default function SecretNew() {
return ( return (
<main style={{ padding: '1rem 0' }}> <main style={{ padding: '1rem 0' }}>
<ProcessBreadcrumb />
<h2>Add Secret</h2> <h2>Add Secret</h2>
<Form onSubmit={addSecret}> <Form onSubmit={addSecret}>
<Form.Group className="mb-3" controlId="formDisplayName"> <Form.Group className="mb-3" controlId="formDisplayName">

View File

@ -2,13 +2,14 @@ import { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom'; import { useParams, useNavigate } from 'react-router-dom';
import { Stack, Table } from 'react-bootstrap'; import { Stack, Table } from 'react-bootstrap';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { Secret } from '../interfaces';
import ButtonWithConfirmation from '../components/ButtonWithConfirmation'; import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
export default function SecretShow() { export default function SecretShow() {
const navigate = useNavigate(); const navigate = useNavigate();
const params = useParams(); const params = useParams();
const [secret, setSecret] = useState(null); const [secret, setSecret] = useState<Secret | null>(null);
const navigateToSecrets = (_result: any) => { const navigateToSecrets = (_result: any) => {
navigate(`/admin/secrets`); navigate(`/admin/secrets`);
@ -22,15 +23,17 @@ export default function SecretShow() {
}, [params]); }, [params]);
const deleteSecret = () => { const deleteSecret = () => {
if (secret === null) {
return;
}
HttpService.makeCallToBackend({ HttpService.makeCallToBackend({
path: `/process-models/${params.process_group_id}/${params.process_model_id}/process-instances/${params.process_instance_id}`, path: `/secrets/${secret.key}`,
successCallback: navigateToSecrets, successCallback: navigateToSecrets,
httpMethod: 'DELETE', httpMethod: 'DELETE',
}); });
}; };
if (secret) { if (secret) {
console.log('secret: ', secret);
const secretToUse = secret as any; const secretToUse = secret as any;
return ( return (