Skip to content

Commit

Permalink
[grid] Respecting page origin for Live View
Browse files Browse the repository at this point in the history
Fixes #9980
  • Loading branch information
diemol committed Nov 5, 2021
1 parent e04552f commit ca9b451
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,23 @@ function createSessionData (
nodeId: string,
nodeUri: string,
sessionDurationMillis: number,
slot: any
slot: any,
hostname: string
): SessionData {
const parsed = JSON.parse(capabilities) as Capabilities
const browserName = parsed.browserName
const browserVersion = parsed.browserVersion ?? parsed.version
const platformName = parsed.platformName ?? parsed.platform
const vnc: string = parsed['se:vnc'] ?? ''
let vnc: string = parsed['se:vnc'] ?? ''
if (vnc.length > 0) {
try {
const url = new URL(vnc)
url.hostname = hostname
vnc = url.href
} catch (error) {
console.log(error)
}
}
const name: string = parsed['se:name'] ?? id
return {
id,
Expand Down Expand Up @@ -242,6 +252,7 @@ const useStyles = (theme: Theme): StyleRules => createStyles(

interface RunningSessionsProps {
sessions: SessionData[]
hostname: string
classes: any
}

Expand Down Expand Up @@ -362,8 +373,16 @@ class RunningSessions extends React.Component<RunningSessionsProps, RunningSessi
}

render (): ReactNode {
const { sessions, classes } = this.props
const { dense, order, orderBy, page, rowOpen, rowLiveViewOpen, rowsPerPage } = this.state
const { sessions, hostname, classes } = this.props
const {
dense,
order,
orderBy,
page,
rowOpen,
rowLiveViewOpen,
rowsPerPage
} = this.state

const rows = sessions.map((session) => {
return createSessionData(
Expand All @@ -374,7 +393,8 @@ class RunningSessions extends React.Component<RunningSessionsProps, RunningSessi
session.nodeId,
session.nodeUri,
session.sessionDurationMillis,
session.slot
session.slot,
hostname
)
})
const emptyRows = rowsPerPage - Math.min(rowsPerPage, rows.length - page * rowsPerPage)
Expand Down
8 changes: 6 additions & 2 deletions javascript/grid-ui/src/screens/Sessions/Sessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ class Sessions extends React.Component<SessionsProps, SessionsState> {

return (
<Grid container spacing={3}>
<RunningSessions sessions={data.sessionsInfo.sessions} />
<QueuedSessions sessionQueueRequests={data.sessionsInfo.sessionQueueRequests} />
<RunningSessions
sessions={data.sessionsInfo.sessions}
hostname={window.location.hostname}
/>
<QueuedSessions
sessionQueueRequests={data.sessionsInfo.sessionQueueRequests}/>
</Grid>
)
}
Expand Down

0 comments on commit ca9b451

Please sign in to comment.