Skip to content
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

feat(platform): Add workspace slug for projects in url #683

Merged
merged 7 commits into from
Feb 12, 2025
8 changes: 2 additions & 6 deletions apps/api/src/secret/secret.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ describe('Secret Controller Tests', () => {
const messages = response.json().message

expect(messages).toHaveLength(1)
expect(messages[0]).toEqual(
'name should not be empty'
)
expect(messages[0]).toEqual('name should not be empty')
})

it('should not be able to create a secret with a non-existing environment', async () => {
Expand Down Expand Up @@ -370,9 +368,7 @@ describe('Secret Controller Tests', () => {
const messages = response.json().message

expect(messages).toHaveLength(1)
expect(messages[0]).toEqual(
'name should not be empty'
)
expect(messages[0]).toEqual('name should not be empty')
})

it('should be able to update the secret name and note without creating a new version', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/src/components/common/slug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Slug({ text }: SlugProps): React.JSX.Element {

return (
<button
className={`${roboto.className} flex cursor-copy gap-2 rounded-lg whitespace-nowrap bg-white/10 px-3 py-2 font-mono text-sm text-white/50 hover:bg-white/15`}
className={`${roboto.className} flex cursor-copy gap-2 whitespace-nowrap rounded-lg bg-white/10 px-3 py-2 font-mono text-sm text-white/50 hover:bg-white/15`}
onClick={copyToClipboard}
type="button"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function EnvironmentCard({
<ContextMenuTrigger className="w-full">
<div className="flex h-fit flex-col rounded-xl border-[1px] border-white/20 bg-white/[2%] transition-all duration-150 ease-in hover:bg-white/[5%]">
<div className="flex flex-col gap-y-2 px-6 py-4">
<div className="flex flex-wrap w-full flex-row items-center justify-between gap-4">
<div className="flex w-full flex-row flex-wrap items-center justify-between gap-4">
<div className="text-2xl">{environment.name}</div>
<Slug text={environment.slug} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
InternalSVG
} from '@public/svg/dashboard'
import type { ProjectWithCount } from '@keyshade/schema'
import { useSetAtom } from 'jotai'
import { useAtomValue, useSetAtom } from 'jotai'
import {
ContextMenu,
ContextMenuContent,
Expand All @@ -21,7 +21,8 @@ import {
import {
deleteProjectOpenAtom,
editProjectOpenAtom,
selectedProjectAtom
selectedProjectAtom,
selectedWorkspaceAtom
} from '@/store'
import { copyToClipboard } from '@/lib/clipboard'

Expand All @@ -46,6 +47,7 @@ export default function ProjectCard({
const setIsEditProjectSheetOpen = useSetAtom(editProjectOpenAtom)
const setIsDeleteProjectOpen = useSetAtom(deleteProjectOpenAtom)
const setSelectedProject = useSetAtom(selectedProjectAtom)
const selectedWorkspace = useAtomValue(selectedWorkspaceAtom)

const handleEditProject = () => {
setSelectedProject(project)
Expand Down Expand Up @@ -75,7 +77,7 @@ export default function ProjectCard({
<ContextMenuTrigger className="flex h-[7rem]">
<Link
className="flex h-[7rem] w-full justify-between rounded-xl bg-white/5 px-5 py-4 shadow-lg hover:bg-white/10"
href={`/project/${slug}?tab=secret`}
href={`${selectedWorkspace?.slug}/${slug}?tab=secret`}
key={id}
>
<div className="flex items-center gap-x-5">
Expand Down Expand Up @@ -110,10 +112,14 @@ export default function ProjectCard({
</Link>
</ContextMenuTrigger>
<ContextMenuContent className="w-64">
<Link href={`/project/${slug}`}>
<Link href={`/${selectedWorkspace?.slug}/${slug}?tab=secret`}>
<ContextMenuItem inset>Open</ContextMenuItem>
</Link>
<a href={`/project/${slug}`} rel="noopener noreferrer" target="_blank">
<a
href={`/${selectedWorkspace?.slug}/${slug}?tab=secret`}
rel="noopener noreferrer"
target="_blank"
>
<ContextMenuItem inset>Open in new tab</ContextMenuItem>
</a>
<ContextMenuSeparator className="bg-white/15" />
Expand Down
26 changes: 15 additions & 11 deletions apps/platform/src/components/shared/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePathname } from 'next/navigation'
import Link from 'next/link'
import { DropdownSVG } from '@public/svg/shared'
import { SecretSVG, VariableSVG, EnvironmentSVG } from '@public/svg/dashboard'
import type { User } from '@keyshade/schema'
import { useAtomValue } from 'jotai'
import SearchModel from './searchModel'
import {
Expand All @@ -18,12 +19,14 @@ import {
} from '@/components/ui/dropdown-menu'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import LineTab from '@/components/ui/line-tab'
import { selectedProjectAtom } from '@/store'
import { userAtom } from '@/store'

function Navbar(): React.JSX.Element {
const [isOpen, setIsOpen] = useState<boolean>(false)
const [isApple, setIsApple] = useState<boolean>(false)
const user = useAtomValue(userAtom)
const selectedProject = useAtomValue(selectedProjectAtom)

const pathname = usePathname()

Expand Down Expand Up @@ -154,17 +157,18 @@ function Navbar(): React.JSX.Element {
</DropdownMenu>
</div>
<div className="px-4">
{(pathname === '/settings' ||
pathname.split('/')[1] === 'project') && (
<LineTab
customID="linetab"
tabs={
pathname.split('/')[1] === 'project'
? projectTabs
: settingsTabs
}
/>
)}
{pathname !== '/' &&
(pathname === '/settings' ||
pathname.split('/')[2] === selectedProject?.slug) && (
<LineTab
customID="linetab"
tabs={
pathname.split('/')[2] === selectedProject?.slug
? projectTabs
: settingsTabs
}
/>
)}
</div>
</nav>
<SearchModel isOpen={isOpen} setIsOpen={setIsOpen} />
Expand Down
Loading