Skip to content

Commit

Permalink
Fixing UI, UX, and bugs in the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vmatsiiako committed Apr 9, 2023
1 parent ecb182a commit 1247813
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 51 deletions.
11 changes: 11 additions & 0 deletions frontend/src/components/v2/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const buttonVariants = cva(
solid: '',
outline: ['bg-transparent', 'border-2', 'border-solid'],
plain: '',
selected: '',
// a constant color not in use on hover or click goes colorSchema color
star: 'text-bunker-200 bg-mineshaft-500'
},
Expand Down Expand Up @@ -61,6 +62,16 @@ const buttonVariants = cva(
variant: 'star',
className: 'hover:bg-primary hover:text-black'
},
{
colorSchema: 'primary',
variant: 'selected',
className: 'bg-primary/10 border border-primary/50 text-bunker-200'
},
{
colorSchema: 'secondary',
variant: 'star',
className: 'bg-mineshaft-700 border border-mineshaft-600 hover:bg-mineshaft hover:text-white'
},
{
colorSchema: 'danger',
variant: 'star',
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/views/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,16 @@ export const DashboardPage = () => {
handleSubmit,
getValues,
setValue,
formState: { isDirty, isSubmitting, dirtyFields },
formState: { isSubmitting, dirtyFields },
reset
} = method;
console.log(122, method)
console.log(123, isDirty, Object.keys(dirtyFields))
const formSecrets = useWatch({ control, name: 'secrets' });
const { fields, prepend, append, remove, update } = useFieldArray({ control, name: 'secrets' });

const isRollbackMode = Boolean(snapshotId);
const isReadOnly = selectedEnv?.isWriteDenied;
const isAddOnly = selectedEnv?.isReadDenied && !selectedEnv?.isWriteDenied;
const canDoRollback = !isReadOnly && !isAddOnly;
console.log(123, !isRollbackMode, !isAddOnly, !isDirty)
const isSubmitDisabled =
isReadOnly ||
// on add only mode the formstate becomes dirty due to secrets missing some items
Expand Down Expand Up @@ -415,7 +412,7 @@ export const DashboardPage = () => {
);

return (
<div className="container mx-auto w-full px-6 text-mineshaft-50 dark:[color-scheme:dark]">
<div className="container mx-auto max-w-full px-6 text-mineshaft-50 dark:[color-scheme:dark]">
<FormProvider {...method}>
<form autoComplete="off">
{/* breadcrumb row */}
Expand Down Expand Up @@ -529,15 +526,15 @@ export const DashboardPage = () => {
</IconButton>
</Tooltip>
</div>
<Button
{!isReadOnly && !isRollbackMode && <Button
leftIcon={<FontAwesomeIcon icon={faPlus} />}
onClick={() => prepend(DEFAULT_SECRET_VALUE, { shouldFocus: false })}
isDisabled={isReadOnly || isRollbackMode}
variant="star"
className="h-10"
>
Add Secret
</Button>
</Button>}
</div>
</div>
<div className={`${isSecretEmpty ? "flex flex-col items-center justify-center" : ""} mt-4 h-[calc(100vh-270px)] overflow-y-scroll overflow-x-hidden no-scrollbar no-scrollbar::-webkit-scrollbar`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ export const PitDrawer = ({
key={_id}
className="py-3 px-4 text-sm"
isFullWidth
colorSchema={
(i === 0 && index === 0 && snapshotId === null) || snapshotId === _id
? 'primary'
: 'secondary'
}
variant={
(i === 0 && index === 0 && snapshotId === null) || snapshotId === _id
? 'solid'
? 'selected'
: 'star'
}
onClick={() => onSelectSnapshot(_id)}
Expand All @@ -65,6 +70,7 @@ export const PitDrawer = ({
<Button
className="mt-8 py-3 px-4 text-sm"
isFullWidth
variant="star"
isLoading={isFetchingNextPage}
isDisabled={isFetchingNextPage || !hasNextPage}
onClick={fetchNextPage}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Controller } from 'react-hook-form';
import { faArrowDown, faArrowUp, faCodeBranch, faInfoCircle } from '@fortawesome/free-solid-svg-icons';
import { faArrowDown, faArrowUp } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@radix-ui/react-hover-card';
import { twMerge } from 'tailwind-merge';

import { IconButton } from '@app/components/v2';

Expand All @@ -23,47 +21,20 @@ export const SecretTableHeader = ({
<Controller
defaultValue=""
name="na"
render={({ fieldState: { error } }) => (
<HoverCard openDelay={0} open={error?.message ? undefined : false}>
<HoverCardTrigger asChild>
<td className='flex items-center'>
<div className="min-w-[220px] lg:min-w-[240px] xl:min-w-[280px] relative flex items-center justify-start pl-2.5 w-full">
<div className="inline-flex items-end text-md font-medium">
Key
<IconButton variant="plain" className="ml-2" ariaLabel="sort" onClick={onSort}>
<FontAwesomeIcon icon={sortDir === 'asc' ? faArrowDown : faArrowUp} />
</IconButton>
</div>
<div className="w-max flex flex-row items-center justify-end">
<div className="w-5 overflow-hidden group-hover:w-5 mt-1"/>
{!true && (
<IconButton
variant="plain"
className={twMerge(
'w-0 overflow-hidden p-0 group-hover:w-6 group-hover:ml-1',
true && 'w-6 text-primary ml-1'
)}
size="md"
ariaLabel="info"
>
<div className="flex items-center space-x-1">
<FontAwesomeIcon icon={faCodeBranch} className="text-base" />
</div>
</IconButton>
)}
</div>
</div>
</td>
</HoverCardTrigger>
<HoverCardContent className="w-auto py-2 pt-2">
<div className="flex items-center space-x-2">
<div>
<FontAwesomeIcon icon={faInfoCircle} className="text-red" />
</div>
<div className="text-sm">{error?.message}</div>
render={() => (
<td className='flex items-center'>
<div className="min-w-[220px] lg:min-w-[240px] xl:min-w-[280px] relative flex items-center justify-start pl-2.5 w-full">
<div className="inline-flex items-end text-md font-medium">
Key
<IconButton variant="plain" className="ml-2" ariaLabel="sort" onClick={onSort}>
<FontAwesomeIcon icon={sortDir === 'asc' ? faArrowDown : faArrowUp} />
</IconButton>
</div>
</HoverCardContent>
</HoverCard>
<div className="w-max flex flex-row items-center justify-end">
<div className="w-5 overflow-hidden group-hover:w-5 mt-1"/>
</div>
</div>
</td>
)}
/>
<th className="flex flex-row w-full"><div className="text-sm font-medium">Value</div></th>
Expand Down

0 comments on commit 1247813

Please sign in to comment.