Fixed minor bugs during code cleaning

This commit is contained in:
Vladyslav Matsiiako
2023-01-17 19:03:43 -08:00
parent 7ae73d1b62
commit 18fbe82535
13 changed files with 38 additions and 33 deletions
+3 -2
View File
@@ -190,7 +190,8 @@ const Layout = ({ children }: LayoutProps) => {
userWorkspaces.length === 0 &&
router.asPath !== '/noprojects' &&
!router.asPath.includes('home') &&
!router.asPath.includes('settings')
!router.asPath.includes('settings') ||
router.asPath === '/dashboard/undefined'
) {
router.push('/noprojects');
} else if (router.asPath !== '/noprojects') {
@@ -259,7 +260,7 @@ const Layout = ({ children }: LayoutProps) => {
</div>
{Object.keys(workspaceMapping).length > 0 ? (
<Listbox
selected={workspaceSelected}
isSelected={workspaceSelected}
onChange={setWorkspaceSelected}
data={Object.keys(workspaceMapping)}
buttonAction={openModal}
+12 -12
View File
@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Listbox, Transition } from '@headlessui/react';
interface ListBoxProps {
selected: string;
isSelected: string;
onChange: (arg: string) => void;
data: string[] | null;
text?: string;
@@ -15,7 +15,7 @@ interface ListBoxProps {
/**
* This is the component that we use for drop down lists.
* @param {object} obj
* @param {string} obj.selected - the item that is currently selected
* @param {string} obj.isSelected - the item that is currently selected
* @param {function} obj.onChange - what happends if you select the item inside a list
* @param {string[]} obj.data - all the options available
* @param {string} obj.text - the text that shows us in front of the select option
@@ -23,7 +23,7 @@ interface ListBoxProps {
* @returns
*/
const ListBox = ({
selected,
isSelected,
onChange,
data,
text,
@@ -31,7 +31,7 @@ const ListBox = ({
isFull
}: ListBoxProps): JSX.Element => {
return (
<Listbox value={selected} onChange={onChange}>
<Listbox value={isSelected} onChange={onChange}>
<div className="relative">
<Listbox.Button
className={`text-gray-400 relative ${
@@ -40,9 +40,9 @@ const ListBox = ({
>
<div className="flex flex-row">
{text}
<span className="ml-1 cursor-pointer block truncate font-semibold text-gray-300 capitalize">
<span className="ml-1 cursor-pointer block truncate font-semibold text-gray-300">
{' '}
{selected}
{isSelected}
</span>
</div>
{data && (
@@ -62,22 +62,22 @@ const ListBox = ({
{data.map((person, personIdx) => (
<Listbox.Option
key={`${person}.${personIdx + 1}`}
className={({ active, selected: isSelected }) =>
`my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md capitalize ${
isSelected ? 'bg-white/10 text-gray-400 font-bold' : ''
className={({ active, selected }) =>
`my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md ${
selected ? 'bg-white/10 text-gray-400 font-bold' : ''
} ${
active && !isSelected
active && !selected
? 'bg-white/5 text-mineshaft-200 cursor-pointer'
: 'text-gray-400'
} `
}
value={person}
>
{({ selected: isSelected }) => (
{({ selected }) => (
<>
<span
className={`block truncate text-primary${
isSelected ? 'font-medium' : 'font-normal'
selected ? 'font-medium' : 'font-normal'
}`}
>
{person}
@@ -126,7 +126,7 @@ const AddApiKeyDialog = ({
</div>
<div className='max-h-28'>
<ListBox
selected={apiKeyExpiresIn}
isSelected={apiKeyExpiresIn}
onChange={setApiKeyExpiresIn}
data={[
'1 day',
@@ -107,7 +107,7 @@ const AddProjectMemberDialog = ({
</div>
<div className="max-h-28">
{data?.length > 0 && (
<ListBox selected={email || data[0]} onChange={setEmail} data={data} isFull />
<ListBox isSelected={email || data[0]} onChange={setEmail} data={data} isFull />
)}
</div>
<div className="max-w-max">
@@ -170,7 +170,7 @@ const AddServiceTokenDialog = ({
</div>
<div className='max-h-28 mb-2'>
<ListBox
selected={
isSelected={
selectedServiceTokenEnv?.name
? selectedServiceTokenEnv?.name
: environments[0]?.name
@@ -192,7 +192,7 @@ const AddServiceTokenDialog = ({
</div>
<div className='max-h-28'>
<ListBox
selected={serviceTokenExpiresIn}
isSelected={serviceTokenExpiresIn}
onChange={setServiceTokenExpiresIn}
data={[
'1 day',
@@ -152,7 +152,7 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg }
((myRole === 'admin' && row.role !== 'owner') || myRole === 'owner') &&
myUser !== row.email ? (
<Listbox
selected={row.role}
isSelected={row.role}
onChange={(e) => handleRoleUpdate(index, e)}
data={
myRole === 'owner' ? ['owner', 'admin', 'member'] : ['admin', 'member']
@@ -163,7 +163,7 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg }
row.status !== 'invited' &&
row.status !== 'verified' && (
<Listbox
selected={row.role}
isSelected={row.role}
text="Role: "
onChange={() => {
throw new Error('Function not implemented.');