Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Assets/IconV2/ic-new-chat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 29 additions & 2 deletions src/Common/API/CoreAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { API_STATUS_CODES, FALLBACK_REQUEST_TIMEOUT, Host } from '@Common/Constants'
import { API_STATUS_CODES, FALLBACK_REQUEST_TIMEOUT, Host, SERVICE_PATHS } from '@Common/Constants'
import { noop } from '@Common/Helper'
import { ServerErrors } from '@Common/ServerError'
import { APIOptions, ResponseType } from '@Common/Types'
Expand All @@ -40,6 +40,30 @@
this.handleRedirectToLicenseActivation = handleRedirectToLicenseActivation || noop
}

/**
* Constructs the final URL by detecting service paths and applying appropriate routing
* @param url - The endpoint URL
* @returns The final URL with correct base path
*/
private constructUrl = (url: string): string => {
// Check if URL starts with a known service path
const isServicePath = Object.values(SERVICE_PATHS).some(
(servicePath) => url.startsWith(`${servicePath}/`) || url.startsWith(`/${servicePath}/`),
)

// Check if it's a non-orchestrator service path
const isNonOrchestratorService =
isServicePath && !url.startsWith('orchestrator/') && !url.startsWith('/orchestrator/')

if (isNonOrchestratorService) {
// For service paths like 'athena/', use as-is but ensure single leading slash
return url.startsWith('/') ? url : `/${url}`
}
// For orchestrator paths or relative paths, add Host prefix
const cleanUrl = url.startsWith('/') ? url.slice(1) : url
return `${this.host}/${cleanUrl}`
}

private fetchAPI = async <K = object>({
url,
type,
Expand All @@ -49,17 +73,20 @@
preventLicenseRedirect = false,
shouldParseServerErrorForUnauthorizedUser = false,
isMultipartRequest,
isProxyHost = false,

Check failure on line 76 in src/Common/API/CoreAPI.ts

View workflow job for this annotation

GitHub Actions / ci

'isProxyHost' is assigned a value but never used
}: FetchAPIParamsType<K>): Promise<ResponseType> => {
const options: RequestInit = {
method: type,
signal,
body: data ? JSON.stringify(data) : undefined,
headers: {
'Content-Type': 'application/json',
},
}
// eslint-disable-next-line dot-notation
options['credentials'] = 'include' as RequestCredentials
return fetch(
`${isProxyHost ? '/proxy' : this.host}/${url}`,
this.constructUrl(url),
!isMultipartRequest
? options
: ({
Expand Down
7 changes: 7 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import { BackupAndScheduleListViewEnum, BackupLocationsTypes } from '@PagesDevtr
export const FALLBACK_REQUEST_TIMEOUT = 60000
export const Host = window?.__ORCHESTRATOR_ROOT__ ?? '/orchestrator'

// Service path constants for API routing
export const SERVICE_PATHS = {
ATHENA: 'athena',
ORCHESTRATOR: 'orchestrator',
// Add other service paths as needed in the future
} as const

export const DOCUMENTATION_HOME_PAGE = 'https://docs.devtron.ai'
export const DEVTRON_HOME_PAGE = 'https://devtron.ai/'
export const DOCUMENTATION_VERSION = '/devtron/v1.7'
Expand Down
4 changes: 4 additions & 0 deletions src/Common/Markdown/MarkDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const MarkDown = ({
`

renderer.heading = ({ text, depth }: Tokens.Heading) => {
// Alternative debugging - add to window object
if (typeof window !== 'undefined') {
;(window as any).debugHeadingText = text
}
const escapedText = disableEscapedText ? '' : text.toLowerCase().replace(/[^\w]+/g, '-')

return `
Expand Down
55 changes: 55 additions & 0 deletions src/Common/Markdown/markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,59 @@
a.anchor {
color: var(--N900);
}
h1, h2, h3, h4, h5, h6 .header-link {
color: #000a14 !important;
font-size: 15px !important;
font-family: Open Sans !important;
font-weight: 600 !important;
line-height: 20px !important;
word-wrap: break-word !important;
}
}

// custom styles
.markdown {
// Title styles
h1, h2, h3, h4, h5, h6 {
&.header-link {
color: #000a14 !important;
font-size: 15px !important;
font-family: Open Sans !important;
font-weight: 600 !important;
line-height: 20px !important;
word-wrap: break-word !important;
}
}

// Description styles
.md-description {
font-size: 14px;
line-height: 1.6;
color: var(--N700);
margin-bottom: 20px;
}

// List styles
ul.md-list {
margin: 12px 0;
padding-left: 24px;

li {
color: var(--neutral-N900, #F8F8F9);
font-size: 13px;
font-family: Open Sans;
font-weight: 400;
line-height: 20px;
word-wrap: break-word;

&::marker {
color: var(--N400);
}
}
}

// Nested list styles
ul.md-list ul {
margin: 8px 0;
}
}
2 changes: 2 additions & 0 deletions src/Shared/Components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ import { ReactComponent as ICMonitoring } from '@IconsV2/ic-monitoring.svg'
import { ReactComponent as ICMoreVertical } from '@IconsV2/ic-more-vertical.svg'
import { ReactComponent as ICNamespace } from '@IconsV2/ic-namespace.svg'
import { ReactComponent as ICNew } from '@IconsV2/ic-new.svg'
import { ReactComponent as ICNewChat } from '@IconsV2/ic-new-chat.svg'
import { ReactComponent as ICNodeScript } from '@IconsV2/ic-node-script.svg'
import { ReactComponent as ICOidc } from '@IconsV2/ic-oidc.svg'
import { ReactComponent as ICOpenBox } from '@IconsV2/ic-open-box.svg'
Expand Down Expand Up @@ -474,6 +475,7 @@ export const iconMap = {
'ic-monitoring': ICMonitoring,
'ic-more-vertical': ICMoreVertical,
'ic-namespace': ICNamespace,
'ic-new-chat': ICNewChat,
'ic-new': ICNew,
'ic-node-script': ICNodeScript,
'ic-oidc': ICOidc,
Expand Down
1 change: 1 addition & 0 deletions src/Shared/Providers/MainContextProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface SidePanelConfig {
/** URL to documentation that should be displayed in the panel */
docLink: string | null
aiSessionId?: string
isExpandedView?: boolean
}

type AIAgentContextType = {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ declare global {
interface Window {
__BASE_URL__: string
__ORCHESTRATOR_ROOT__: string
__ATHENA_ROOT__: string
_env_: customEnv
}
}
Expand Down
Loading