mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 07:28:09 -05:00
Fixed minor bugs during code cleaning
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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.');
|
||||
|
||||
@@ -94,7 +94,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
|
||||
<div className="text-gray-400 text-xs font-semibold mb-2 w-60">ENVIRONMENT</div>
|
||||
<ListBox
|
||||
data={!integration.isActive ? ['Development', 'Preview', 'Production'] : null}
|
||||
selected={integrationTarget}
|
||||
isSelected={integrationTarget}
|
||||
onChange={setIntegrationTarget}
|
||||
isFull
|
||||
/>
|
||||
@@ -110,7 +110,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
|
||||
? ['Production', 'Deploy previews', 'Branch deploys', 'Local development']
|
||||
: null
|
||||
}
|
||||
selected={integrationContext}
|
||||
isSelected={integrationContext}
|
||||
onChange={setIntegrationContext}
|
||||
/>
|
||||
</div>
|
||||
@@ -134,7 +134,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
|
||||
<p className="text-gray-400 text-xs font-semibold mb-2">ENVIRONMENT</p>
|
||||
<ListBox
|
||||
data={!integration.isActive ? environments.map(({ name }) => name) : null}
|
||||
selected={integrationEnvironment.name}
|
||||
isSelected={integrationEnvironment.name}
|
||||
onChange={(envName) =>
|
||||
setIntegrationEnvironment(
|
||||
environments.find(({ name }) => envName === name) || {
|
||||
@@ -159,7 +159,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
|
||||
<div className="text-gray-400 text-xs font-semibold mb-2">APP</div>
|
||||
<ListBox
|
||||
data={!integration.isActive ? apps.map((app) => app.name) : null}
|
||||
selected={integrationApp}
|
||||
isSelected={integrationApp}
|
||||
onChange={(app) => {
|
||||
setIntegrationApp(app);
|
||||
}}
|
||||
|
||||
@@ -204,7 +204,11 @@ const attemptLogin = async (
|
||||
}
|
||||
|
||||
if (isLogin) {
|
||||
router.push(`/dashboard/${localStorage.getItem('projectData.id')}`);
|
||||
if (localStorage.getItem('projectData.id') !== "undefined") {
|
||||
router.push(`/dashboard/${localStorage.getItem('projectData.id')}`);
|
||||
} else {
|
||||
router.push("/noprojects");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
@@ -564,7 +564,7 @@ export default function Dashboard() {
|
||||
</div>
|
||||
{!snapshotData && data?.length === 0 && (
|
||||
<ListBox
|
||||
selected={selectedEnv.name}
|
||||
isSelected={selectedEnv.name}
|
||||
data={workspaceEnvs.map(({ name }) => name)}
|
||||
onChange={(envName) =>
|
||||
setSelectedEnv(
|
||||
@@ -644,7 +644,7 @@ export default function Dashboard() {
|
||||
<>
|
||||
{!snapshotData ? (
|
||||
<ListBox
|
||||
selected={selectedEnv.name}
|
||||
isSelected={selectedEnv.name}
|
||||
data={workspaceEnvs.map(({ name }) => name)}
|
||||
onChange={(envName) =>
|
||||
setSelectedEnv(
|
||||
@@ -657,7 +657,7 @@ export default function Dashboard() {
|
||||
/>
|
||||
) : (
|
||||
<ListBox
|
||||
selected={selectedSnapshotEnv?.name || ''}
|
||||
isSelected={selectedSnapshotEnv?.name || ''}
|
||||
data={workspaceEnvs.map(({ name }) => name)}
|
||||
onChange={(envName) =>
|
||||
setSelectedSnapshotEnv(
|
||||
|
||||
@@ -151,7 +151,7 @@ export default function Login() {
|
||||
<div className="absolute right-4 top-0 mt-4 flex items-center justify-center">
|
||||
<div className="w-48 mx-auto">
|
||||
<ListBox
|
||||
selected={lang}
|
||||
isSelected={lang}
|
||||
onChange={setLanguage}
|
||||
data={['en', 'ko', 'fr', 'pt-BR']}
|
||||
isFull
|
||||
|
||||
@@ -31,7 +31,7 @@ export default function NoProjects() {
|
||||
</div>
|
||||
<div className="px-4 rounded-md bg-bunker-500 mb-8 text-bunker-300 shadow-xl py-6">
|
||||
<div className="max-w-md">
|
||||
You are not part of any projects in this organization yet. When you do, they will appear
|
||||
You are not part of any projects in this organization yet. When you are, they will appear
|
||||
here.
|
||||
</div>
|
||||
<div className="max-w-md mt-4">
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function SettingsOrg() {
|
||||
key: guidGenerator(),
|
||||
firstName: orgUser.user?.firstName,
|
||||
lastName: orgUser.user?.lastName,
|
||||
email: orgUser.user?.email === null ? orgUser.inviteEmail : orgUser.user?.email,
|
||||
email: orgUser.user?.email == null ? orgUser.inviteEmail : orgUser.user?.email,
|
||||
role: orgUser?.role,
|
||||
status: orgUser?.status,
|
||||
userId: orgUser.user?._id,
|
||||
@@ -115,7 +115,7 @@ export default function SettingsOrg() {
|
||||
};
|
||||
|
||||
const submitAddUserModal = async (newUserEmail: string) => {
|
||||
await addUserToOrg(email, localStorage.getItem('orgData.id') as string);
|
||||
await addUserToOrg(newUserEmail, localStorage.getItem('orgData.id') as string);
|
||||
setEmail('');
|
||||
setIsAddUserOpen(false);
|
||||
router.reload();
|
||||
|
||||
@@ -93,7 +93,7 @@ export default function PersonalSettings() {
|
||||
</p>
|
||||
<div className="max-h-28 w-ful mt-4">
|
||||
<ListBox
|
||||
selected={lang}
|
||||
isSelected={lang}
|
||||
onChange={setLanguage}
|
||||
data={['en', 'ko', 'fr']}
|
||||
text={`${t('common:language')}: `}
|
||||
|
||||
Reference in New Issue
Block a user