-
Notifications
You must be signed in to change notification settings - Fork 266
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
ui: use route location instead of window.location (PROJQUAY-5392) #1844
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,13 @@ import { | |
Tbody, | ||
Td, | ||
} from '@patternfly/react-table'; | ||
import {useRecoilState, useRecoilValue} from 'recoil'; | ||
import {useRecoilState} from 'recoil'; | ||
import {IRepository} from 'src/resources/RepositoryResource'; | ||
import {ReactElement, useState} from 'react'; | ||
import {Link, useLocation} from 'react-router-dom'; | ||
import CreateRepositoryModalTemplate from 'src/components/modals/CreateRepoModalTemplate'; | ||
import {getRepoDetailPath} from 'src/routes/NavigationPath'; | ||
import {selectedReposState, searchRepoState} from 'src/atoms/RepositoryState'; | ||
import {selectedReposState} from 'src/atoms/RepositoryState'; | ||
import {formatDate, formatSize} from 'src/libs/utils'; | ||
import {BulkDeleteModalTemplate} from 'src/components/modals/BulkDeleteModalTemplate'; | ||
import {RepositoryToolBar} from 'src/routes/RepositoriesList/RepositoryToolBar'; | ||
|
@@ -69,6 +69,9 @@ export default function RepositoriesList(props: RepositoriesListProps) { | |
const [makePublicModalOpen, setmakePublicModal] = useState(false); | ||
const [makePrivateModalOpen, setmakePrivateModal] = useState(false); | ||
const [err, setErr] = useState<string[]>(); | ||
const location = useLocation(); | ||
|
||
console.log('current route location', location.pathname); | ||
|
||
const quayConfig = useQuayConfig(); | ||
const {user} = useCurrentUser(); | ||
|
@@ -363,11 +366,23 @@ export default function RepositoriesList(props: RepositoriesListProps) { | |
/> | ||
<Td dataLabel={RepositoryListColumnNames.name}> | ||
{currentOrg == null ? ( | ||
<Link to={getRepoDetailPath(repo.namespace, repo.name)}> | ||
<Link | ||
to={getRepoDetailPath( | ||
location.pathname, | ||
repo.namespace, | ||
repo.name, | ||
)} | ||
> | ||
{repo.namespace}/{repo.name} | ||
</Link> | ||
) : ( | ||
<Link to={getRepoDetailPath(repo.namespace, repo.name)}> | ||
<Link | ||
to={getRepoDetailPath( | ||
location.pathname, | ||
repo.namespace, | ||
repo.name, | ||
)} | ||
> | ||
{repo.name} | ||
</Link> | ||
)} | ||
|
@@ -414,3 +429,7 @@ interface RepoListTableItem { | |
size: number; | ||
last_modified: number; | ||
} | ||
|
||
interface RepositoriesListProps { | ||
organizationName: string; | ||
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. Is there a reason for adding the props here? I don't see the 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. I see |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {Tabs, Tab, TabTitleText} from '@patternfly/react-core'; | ||
import {useSearchParams, useNavigate} from 'react-router-dom'; | ||
import {useSearchParams, useNavigate, useLocation} from 'react-router-dom'; | ||
import {useState} from 'react'; | ||
import Details from './Details/Details'; | ||
import SecurityReport from './SecurityReport/SecurityReport'; | ||
|
@@ -20,6 +20,7 @@ function getTabIndex(tab: string) { | |
export default function TagTabs(props: TagTabsProps) { | ||
const [activeTabKey, setActiveTabKey] = useState<TabIndex>(TabIndex.Details); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
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.
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. it's used in |
||
|
||
// Navigate to the correct tab | ||
const [searchParams] = useSearchParams(); | ||
|
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.
Can you remove the console.log
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.
removed