-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KLO-117 : Add domain names in router details and listing screen #94
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
263 changes: 153 additions & 110 deletions
263
src/apps/console/components/console-list-components.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,186 @@ | ||
import { ReactNode } from 'react'; | ||
import {ReactNode, useState} from 'react'; | ||
import Tooltip from '~/components/atoms/tooltip'; | ||
import { cn } from '~/components/utils'; | ||
import {cn, titleCase} from '~/components/utils'; | ||
import {CopyrightFill, CopySimple} from "@jengaicons/react"; | ||
import useClipboard from "~/lib/client/hooks/use-clipboard"; | ||
import {toast} from "~/components/molecule/toast"; | ||
|
||
interface IBase { | ||
className?: string; | ||
action?: ReactNode; | ||
className?: string; | ||
action?: ReactNode; | ||
} | ||
|
||
const BaseStyle = 'flex flex-row items-center gap-xl'; | ||
|
||
const ListSecondary = ({ | ||
className, | ||
action, | ||
title, | ||
avatar, | ||
subtitle, | ||
}: { | ||
className?: string; | ||
action?: ReactNode; | ||
title?: ReactNode; | ||
subtitle?: ReactNode; | ||
avatar?: ReactNode; | ||
className, | ||
action, | ||
title, | ||
avatar, | ||
subtitle, | ||
}: { | ||
className?: string; | ||
action?: ReactNode; | ||
title?: ReactNode; | ||
subtitle?: ReactNode; | ||
avatar?: ReactNode; | ||
}) => { | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-row items-center gap-xl flex-1 truncate"> | ||
{avatar} | ||
<div className="flex flex-col gap-sm flex-1 truncate"> | ||
{title && ( | ||
<div className="bodySm truncate text-text-soft pulsable"> | ||
{title} | ||
</div> | ||
)} | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-row items-center gap-xl flex-1 truncate"> | ||
{avatar} | ||
<div className="flex flex-col gap-sm flex-1 truncate"> | ||
{title && ( | ||
<div className="bodySm truncate text-text-soft pulsable"> | ||
{title} | ||
</div> | ||
)} | ||
|
||
{subtitle && ( | ||
<div className="bodyMd-medium truncate pulsable">{subtitle}</div> | ||
)} | ||
{subtitle && ( | ||
<div className="bodyMd-medium truncate pulsable">{subtitle}</div> | ||
)} | ||
</div> | ||
</div> | ||
{action} | ||
</div> | ||
</div> | ||
{action} | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
const ListBody = ({ | ||
data, | ||
className = '', | ||
action, | ||
}: { | ||
data: ReactNode; | ||
data, | ||
className = '', | ||
action, | ||
}: { | ||
data: ReactNode; | ||
} & IBase) => { | ||
return ( | ||
<div | ||
className={cn('bodyMd text-text-strong truncate', BaseStyle, className)} | ||
> | ||
<div className="flex-1 truncate pulsable">{data}</div> | ||
{action} | ||
</div> | ||
); | ||
return ( | ||
<div | ||
className={cn('bodyMd text-text-strong truncate', BaseStyle, className)} | ||
> | ||
<div className="flex-1 truncate pulsable">{data}</div> | ||
{action} | ||
</div> | ||
); | ||
}; | ||
|
||
const ListItem = ({ | ||
data, | ||
subtitle, | ||
className = '', | ||
action, | ||
}: { | ||
data?: ReactNode; | ||
subtitle?: ReactNode; | ||
data, | ||
subtitle, | ||
className = '', | ||
action, | ||
}: { | ||
data?: ReactNode; | ||
subtitle?: ReactNode; | ||
} & IBase) => { | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-col flex-1 truncate"> | ||
{data && ( | ||
<div className="flex-1 bodyMd-medium text-text-strong truncate pulsable"> | ||
{data} | ||
</div> | ||
)} | ||
{subtitle && ( | ||
<div className="pulsable bodyMd text-text-soft truncate"> | ||
{subtitle} | ||
</div> | ||
)} | ||
</div> | ||
{action} | ||
</div> | ||
); | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-col flex-1 truncate"> | ||
{data && ( | ||
<div className="flex-1 bodyMd-medium text-text-strong truncate pulsable"> | ||
{data} | ||
</div> | ||
)} | ||
{subtitle && ( | ||
<div className="pulsable bodyMd text-text-soft truncate"> | ||
{subtitle} | ||
</div> | ||
)} | ||
</div> | ||
{action} | ||
</div> | ||
); | ||
}; | ||
|
||
const ListTitle = ({ | ||
className, | ||
action, | ||
title, | ||
avatar, | ||
subtitle, | ||
}: { | ||
className?: string; | ||
action?: ReactNode; | ||
title?: ReactNode; | ||
subtitle?: ReactNode; | ||
avatar?: ReactNode; | ||
className, | ||
action, | ||
title, | ||
avatar, | ||
subtitle, | ||
}: { | ||
className?: string; | ||
action?: ReactNode; | ||
title?: ReactNode; | ||
subtitle?: ReactNode; | ||
avatar?: ReactNode; | ||
}) => { | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-row items-center gap-xl flex-1 truncate"> | ||
{avatar} | ||
<div className="flex flex-col gap-sm flex-1 truncate"> | ||
{title && ( | ||
<div className="bodyMd-semibold text-text-default truncate pulsable"> | ||
<Tooltip.Root | ||
className="!w-fit !max-w-fit" | ||
side="top" | ||
content={<div className="bodySm text-text-strong">{title}</div>} | ||
> | ||
<span className="w-fit">{title}</span> | ||
</Tooltip.Root> | ||
return ( | ||
<div className={cn(BaseStyle, className)}> | ||
<div className="flex flex-row items-center gap-xl flex-1 truncate"> | ||
{avatar} | ||
<div className="flex flex-col gap-sm flex-1 truncate"> | ||
{title && ( | ||
<div className="bodyMd-semibold text-text-default truncate pulsable"> | ||
<Tooltip.Root | ||
className="!w-fit !max-w-fit" | ||
side="top" | ||
content={<div className="bodySm text-text-strong">{title}</div>} | ||
> | ||
<span className="w-fit">{title}</span> | ||
</Tooltip.Root> | ||
</div> | ||
)} | ||
|
||
{subtitle && ( | ||
<div className="bodySm text-text-soft truncate pulsable"> | ||
{subtitle} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
)} | ||
{action} | ||
</div> | ||
); | ||
}; | ||
|
||
const ListDomainItem = ({ | ||
data, | ||
value, | ||
}: { | ||
data: ReactNode; | ||
value: string; | ||
}) => { | ||
const [_, setCopyIcon] = useState(<CopySimple/>); | ||
const {copy} = useClipboard({ | ||
onSuccess: () => { | ||
setTimeout(() => { | ||
setCopyIcon(<CopyrightFill/>); | ||
toast.success(`${titleCase("domain name")} copied successfully`); | ||
}, 1000); | ||
// toast.success('Copied to clipboard'); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (llm): It appears there's a commented-out line of code left in the changes. If this line is no longer needed, it's best to remove it to keep the codebase clean and maintainable. |
||
}); | ||
|
||
{subtitle && ( | ||
<div className="bodySm text-text-soft truncate pulsable"> | ||
{subtitle} | ||
return ( | ||
<div | ||
onClick={(event) => { | ||
event.preventDefault() | ||
copy(value); | ||
}} | ||
className="flex flex-row gap-md items-center select-none group cursor-pointer" | ||
> | ||
<div className="flex flex-col flex-1"> | ||
{data && ( | ||
<div className="bodyMd-medium text-text-soft truncate pulsable"> | ||
{data} | ||
</div> | ||
)} | ||
</div> | ||
)} | ||
<span className="invisible group-hover:visible"> | ||
<CopySimple size={10}/> | ||
</span> | ||
</div> | ||
</div> | ||
{action} | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
const listFlex = ({ key }: { key: string }) => ({ | ||
key, | ||
className: 'basis-full', | ||
render: () => <div />, | ||
const listFlex = ({key}: { key: string }) => ({ | ||
key, | ||
className: 'basis-full', | ||
render: () => <div/>, | ||
}); | ||
|
||
const listClass = { | ||
title: 'w-[180px] min-w-[180px] max-w-[180px] mr-2xl', | ||
author: 'w-[180px] min-w-[180px] max-w-[180px]', | ||
title: 'w-[180px] min-w-[180px] max-w-[180px] mr-2xl', | ||
author: 'w-[180px] min-w-[180px] max-w-[180px]', | ||
}; | ||
export { ListBody, ListItem, ListTitle, ListSecondary, listFlex, listClass }; | ||
export {ListBody, ListItem, ListTitle, ListSecondary, listFlex, ListDomainItem, listClass}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (llm): Using an underscore as a variable name for the state variable returned from
useState
is unconventional when the variable is actually used. Consider using a more descriptive name for the state variable that holds the current icon.