mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-30 14:22:05 +00:00
Add Session Id (#2263)
* adding sessionId to UserContext * add session id * add session id to settings pane and fix npm run compile * Add conditional for Portal * set default session id on userContext init * fix tests --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
This commit is contained in:
@@ -5,6 +5,12 @@ import { updateUserContext } from "../../../UserContext";
|
||||
import { SettingsPane } from "./SettingsPane";
|
||||
|
||||
describe("Settings Pane", () => {
|
||||
beforeEach(() => {
|
||||
updateUserContext({
|
||||
sessionId: "1234-5678",
|
||||
});
|
||||
});
|
||||
|
||||
it("should render Default properly", () => {
|
||||
const wrapper = shallow(<SettingsPane explorer={null} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
@@ -212,6 +212,7 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
const styles = useStyles();
|
||||
|
||||
const explorerVersion = configContext.gitSha;
|
||||
const sessionId: string = userContext.sessionId;
|
||||
const isEmulator = configContext.platform === Platform.Emulator;
|
||||
const shouldShowQueryPageOptions = userContext.apiType === "SQL";
|
||||
const showRetrySettings =
|
||||
@@ -1227,6 +1228,12 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
||||
<div>{explorerVersion}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="settingsSection">
|
||||
<div className="settingsSectionPart">
|
||||
<div className="settingsSectionLabel">Session ID</div>
|
||||
<div>{sessionId}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</RightPaneForm>
|
||||
);
|
||||
|
||||
@@ -649,6 +649,22 @@ exports[`Settings Pane should render Default properly 1`] = `
|
||||
<div />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="settingsSection"
|
||||
>
|
||||
<div
|
||||
className="settingsSectionPart"
|
||||
>
|
||||
<div
|
||||
className="settingsSectionLabel"
|
||||
>
|
||||
Session ID
|
||||
</div>
|
||||
<div>
|
||||
1234-5678
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</RightPaneForm>
|
||||
`;
|
||||
@@ -958,6 +974,22 @@ exports[`Settings Pane should render Gremlin properly 1`] = `
|
||||
<div />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="settingsSection"
|
||||
>
|
||||
<div
|
||||
className="settingsSectionPart"
|
||||
>
|
||||
<div
|
||||
className="settingsSectionLabel"
|
||||
>
|
||||
Session ID
|
||||
</div>
|
||||
<div>
|
||||
1234-5678
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</RightPaneForm>
|
||||
`;
|
||||
|
||||
@@ -286,7 +286,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
query,
|
||||
paginationToken,
|
||||
}),
|
||||
beforeSend: this.setAuthorizationHeader as any,
|
||||
beforeSend: this.setCommonHeaders as any,
|
||||
cache: false,
|
||||
});
|
||||
shouldNotify &&
|
||||
@@ -440,7 +440,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
keyspaceId: collection.databaseId,
|
||||
tableId: collection.id(),
|
||||
}),
|
||||
beforeSend: this.setAuthorizationHeader as any,
|
||||
beforeSend: this.setCommonHeaders as any,
|
||||
cache: false,
|
||||
})
|
||||
.then(
|
||||
@@ -482,7 +482,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
keyspaceId: collection.databaseId,
|
||||
tableId: collection.id(),
|
||||
}),
|
||||
beforeSend: this.setAuthorizationHeader as any,
|
||||
beforeSend: this.setCommonHeaders as any,
|
||||
cache: false,
|
||||
})
|
||||
.then(
|
||||
@@ -518,7 +518,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
resourceId: resourceId,
|
||||
query: query,
|
||||
}),
|
||||
beforeSend: this.setAuthorizationHeader as any,
|
||||
beforeSend: this.setCommonHeaders as any,
|
||||
cache: false,
|
||||
}).then(
|
||||
(data: any) => {
|
||||
@@ -547,7 +547,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
return cassandraEndpoint;
|
||||
}
|
||||
|
||||
private setAuthorizationHeader: (xhr: XMLHttpRequest) => boolean = (xhr: XMLHttpRequest): boolean => {
|
||||
private setCommonHeaders: (xhr: XMLHttpRequest) => boolean = (xhr: XMLHttpRequest): boolean => {
|
||||
const authorizationHeaderMetadata: ViewModels.AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||
xhr.setRequestHeader(authorizationHeaderMetadata.header, authorizationHeaderMetadata.token);
|
||||
|
||||
@@ -555,6 +555,7 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
xhr.setRequestHeader(Constants.HttpHeaders.entraIdToken, userContext.aadToken);
|
||||
}
|
||||
|
||||
xhr.setRequestHeader(Constants.HttpHeaders.sessionId, userContext.sessionId);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user