Fixed the service token bugs

This commit is contained in:
Vladyslav Matsiiako
2023-01-04 20:22:51 -08:00
parent 9cf28fef5f
commit 8b48205881
4 changed files with 15 additions and 11 deletions
@@ -33,6 +33,8 @@ const AddServiceTokenDialog = ({
closeModal, closeModal,
workspaceId, workspaceId,
workspaceName, workspaceName,
serviceTokens,
setServiceTokens
}) => { }) => {
const [serviceToken, setServiceToken] = useState(""); const [serviceToken, setServiceToken] = useState("");
const [serviceTokenName, setServiceTokenName] = useState(""); const [serviceTokenName, setServiceTokenName] = useState("");
@@ -71,7 +73,8 @@ const AddServiceTokenDialog = ({
tag tag
}); });
setServiceToken(newServiceToken); setServiceTokens(serviceTokens.concat([newServiceToken.serviceTokenData]));
setServiceToken(newServiceToken.serviceToken + "." + randomBytes);
}; };
function copyToClipboard() { function copyToClipboard() {
@@ -211,7 +214,7 @@ const AddServiceTokenDialog = ({
</div> </div>
</div> </div>
<div className="w-full"> <div className="w-full">
<div className="flex justify-end items-center bg-white/[0.07] text-base mt-2 mr-2 rounded-md text-gray-400 w-full h-14"> <div className="flex justify-end items-center bg-white/[0.07] text-base mt-2 mr-2 rounded-md text-gray-400 w-full h-20">
<input <input
type="text" type="text"
value={serviceToken} value={serviceToken}
@@ -30,25 +30,24 @@ interface ServiceTokensProps {
* @returns * @returns
*/ */
const ServiceTokenTable = ({ data, workspaceName, setServiceTokens }: ServiceTokensProps) => { const ServiceTokenTable = ({ data, workspaceName, setServiceTokens }: ServiceTokensProps) => {
console.log(data)
const { createNotification } = useNotificationContext(); const { createNotification } = useNotificationContext();
return ( return (
<div className="table-container w-full bg-bunker rounded-md mb-6 border border-mineshaft-700 relative mt-1"> <div className="table-container w-full bg-bunker rounded-md mb-6 border border-mineshaft-700 relative mt-1">
<div className="absolute rounded-t-md w-full h-12 bg-white/5"></div> <div className="absolute rounded-t-md w-full h-12 bg-white/5"></div>
<table className="w-full my-1"> <table className="w-full my-1">
<thead className="text-bunker-300"> <thead className="text-bunker-300 text-sm font-light">
<tr> <tr>
<th className="text-left pl-6 pt-2.5 pb-2">Token name</th> <th className="text-left pl-6 pt-2.5 pb-2">TOKEN NAME</th>
<th className="text-left pl-6 pt-2.5 pb-2">Project</th> <th className="text-left pl-6 pt-2.5 pb-2">PROJECT</th>
<th className="text-left pl-6 pt-2.5 pb-2">Environment</th> <th className="text-left pl-6 pt-2.5 pb-2">ENVIRONMENT</th>
<th className="text-left pl-6 pt-2.5 pb-2">Valid until</th> <th className="text-left pl-6 pt-2.5 pb-2">VAILD UNTIL</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{data?.length > 0 ? ( {data?.length > 0 ? (
data.map((row) => { data?.map((row) => {
return ( return (
<tr <tr
key={guidGenerator()} key={guidGenerator()}
@@ -88,7 +87,7 @@ const ServiceTokenTable = ({ data, workspaceName, setServiceTokens }: ServiceTok
}) })
) : ( ) : (
<tr> <tr>
<td className="text-center pt-7 pb-4 text-bunker-400 col-span-4"> <td colSpan={4} className="text-center pt-7 pb-5 text-bunker-300 text-sm">
No service tokens yet No service tokens yet
</td> </td>
</tr> </tr>
@@ -47,7 +47,7 @@ const addServiceToken = ({
}) })
}).then(async (res) => { }).then(async (res) => {
if (res && res.status == 200) { if (res && res.status == 200) {
return (await res.json()).serviceToken; return (await res.json());
} else { } else {
console.log('Failed to add service tokens'); console.log('Failed to add service tokens');
} }
+2
View File
@@ -124,6 +124,8 @@ export default function SettingsBasic() {
workspaceId={router.query.id} workspaceId={router.query.id}
closeModal={closeAddServiceTokenModal} closeModal={closeAddServiceTokenModal}
workspaceName={workspaceName} workspaceName={workspaceName}
serviceTokens={serviceTokens}
setServiceTokens={setServiceTokens}
/> />
<div className="flex flex-row mr-6 max-w-5xl"> <div className="flex flex-row mr-6 max-w-5xl">
<div className="w-full max-h-screen pb-2 overflow-y-auto"> <div className="w-full max-h-screen pb-2 overflow-y-auto">