diff --git a/web/src/AppContext.tsx b/web/src/AppContext.tsx index 763b1ee5e..d11cbebce 100644 --- a/web/src/AppContext.tsx +++ b/web/src/AppContext.tsx @@ -1,4 +1,5 @@ -import React, { useState, useContext, useEffect } from 'react' +import React, { useState, useContext, useEffect, useMemo } from 'react' +import { matchPath } from 'react-router-dom' import { noop } from 'lodash-es' import { useGet } from 'restful-react' import type { AppProps } from 'AppProps' @@ -33,8 +34,13 @@ export const AppContextProvider: React.FC<{ value: AppProps }> = React.memo(func value: initialValue, children }) { + const lazy = useMemo( + () => initialValue.standalone && !!matchPath(location.pathname, { path: '/(signin|register)' }), + [initialValue.standalone] + ) const { data: currentUser = defaultCurrentUser } = useGet({ - path: '/api/v1/user' + path: '/api/v1/user', + lazy }) const [appStates, setAppStates] = useState(initialValue) diff --git a/web/src/RouteDestinations.tsx b/web/src/RouteDestinations.tsx index a30325981..d7cef09bb 100644 --- a/web/src/RouteDestinations.tsx +++ b/web/src/RouteDestinations.tsx @@ -36,7 +36,6 @@ import NewPipeline from 'pages/NewPipeline/NewPipeline' export const RouteDestinations: React.FC = React.memo(function RouteDestinations() { const { getString } = useStrings() const repoPath = `${pathProps.space}/${pathProps.repoName}` - const { OPEN_SOURCE_PIPELINES, OPEN_SOURCE_SECRETS } = useFeatureFlag() return ( diff --git a/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx b/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx index 08a065234..7eb3c4cdd 100644 --- a/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx +++ b/web/src/pages/Repository/RepositoryContent/FileContent/FileContent.tsx @@ -31,6 +31,7 @@ import { useAppContext } from 'AppContext' import { LatestCommitForFile } from 'components/LatestCommit/LatestCommit' import { useCommitModal } from 'components/CommitModalButton/CommitModalButton' import { useStrings } from 'framework/strings' +import { getConfig } from 'services/config' import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton' import { PlainButton } from 'components/PlainButton/PlainButton' import { CommitsView } from 'components/CommitsView/CommitsView' @@ -57,7 +58,6 @@ export function FileContent({ useFileContentViewerDecision({ repoMetadata, gitRef, resourcePath, resourceContent }) const history = useHistory() const [activeTab, setActiveTab] = React.useState(FileSection.CONTENT) - const content = useMemo( () => decodeGitContent((resourceContent?.content as RepoFileContent)?.data), [resourceContent?.content] @@ -199,13 +199,18 @@ export function FileContent({ style={{ padding: '5px' }} width="145px" items={[ - // { - // hasIcon: true, - // iconName: 'arrow-right', - // text: getString('viewRaw'), - // onClick: () => window.open(rawURL, '_blank') // TODO: This is still not working due to token is not stored in cookies - // }, - // '-', + { + hasIcon: true, + iconName: 'arrow-right', + text: getString('viewRaw'), + onClick: () => { + const url = standalone + ? rawURL.replace(/^\/code/, '') + : getConfig(rawURL).replace('//', '/') + window.open(url, '_blank') + } + }, + '-', { hasIcon: true, iconName: 'cloud-download', @@ -243,6 +248,7 @@ export function FileContent({
+ rawURL: {rawURL} {