Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #278 from statelyai/farskid/sta-630-show-the-compl…
Browse files Browse the repository at this point in the history
…ete-url-in-the-embed-code

Farskid/sta 630 Show the complete url in the embed code
  • Loading branch information
farskid committed Sep 27, 2021
2 parents 7588433 + 8e0b2de commit cd128a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/EmbedPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ const EmbedPreviewContent: React.FC = () => {
makeEmbedUrlAndCode: assign((ctx) => {
const url = makeEmbedUrl(
router.query.sourceFileId as string,
window.location.origin,
ctx.params,
);

Expand All @@ -221,6 +222,7 @@ const EmbedPreviewContent: React.FC = () => {
makePreviewUrl: assign((ctx) => {
const url = makeEmbedUrl(
router.query.sourceFileId as string,
window.location.origin,
ctx.params,
);
return {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('utils', () => {
describe('makeEmbedUrl', () => {
it('makes a valid url with booleans turned to numbers', () => {
expect(
utils.makeEmbedUrl('source_id', {
utils.makeEmbedUrl('source_id', 'https://stately.ai', {
mode: EmbedMode.Panels,
panel: EmbedPanel.Events,
readOnly: false,
Expand All @@ -15,7 +15,7 @@ describe('utils', () => {
controls: true,
}),
).toBe(
'/viz/embed/source_id?mode=panels&panel=events&readOnly=0&pan=0&zoom=1&showOriginalLink=0&controls=1',
'https://stately.ai/viz/embed/source_id?mode=panels&panel=events&readOnly=0&pan=0&zoom=1&showOriginalLink=0&controls=1',
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export function paramsToRecord(
);
}

export function makeEmbedUrl(id: string, params: ParsedEmbed) {
export function makeEmbedUrl(id: string, baseUrl: string, params: ParsedEmbed) {
const paramsWithNumberValues = Object.entries(params).reduce(
(result, current) => {
return {
Expand All @@ -332,7 +332,7 @@ export function makeEmbedUrl(id: string, params: ParsedEmbed) {
{},
);
const query = new URLSearchParams(paramsWithNumberValues as any);
return `/viz/embed/${id}?${query.toString()}`;
return `${baseUrl}/viz/embed/${id}?${query.toString()}`;
}
// unsure if this should include button-like input elements
export const hasRoleButton = (el: HTMLElement): boolean => {
Expand Down

0 comments on commit cd128a1

Please sign in to comment.