Skip to content

Commit

Permalink
Fix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-c-martin committed Jan 20, 2025
1 parent 1f2b8e1 commit ba02ef6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 52 deletions.
70 changes: 36 additions & 34 deletions src/playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.18.0",
"@types/node": "^22.10.5",
"@types/node": "^22.10.7",
"@types/pako": "^2.0.3",
"@types/react": "^19.0.5",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"eslint": "^9.17.0",
"eslint": "^9.18.0",
"eslint-plugin-jest": "^28.11.0",
"eslint-plugin-notice": "^1.0.0",
"globals": "^15.14.0",
"html-webpack-plugin": "^5.6.3",
"monaco-editor-webpack-plugin": "^7.1.0",
"nerdbank-gitversioning": "^3.7.112",
"nerdbank-gitversioning": "^3.7.115",
"style-loader": "^4.0.0",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
Expand Down
16 changes: 7 additions & 9 deletions src/playground/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { Container, Row, Spinner } from 'react-bootstrap';
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import 'bootstrap/dist/css/bootstrap.min.css';
Expand All @@ -10,15 +10,15 @@ import './index.css';
import { initializeInterop } from './lspInterop';
import { Playground } from './playground';

ReactDOM.render(

const root = createRoot(document.getElementById('root'));
root.render(
// Loading spinner while we initialize Blazor
<Container className="d-flex vh-100">
<Row className="m-auto align-self-center">
<Spinner animation="border" variant="light" />
</Row>
</Container>,
document.getElementById('root')
);
</Container>);

async function initialize() {
const insights = new ApplicationInsights({
Expand All @@ -32,12 +32,10 @@ async function initialize() {

await initializeInterop(self);

ReactDOM.render(
root.render(
<div className="app-container">
<Playground insights={insights} />
</div>,
document.getElementById('root')
);
</div>);
}

initialize();
5 changes: 3 additions & 2 deletions src/playground/src/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Button, ButtonGroup, Col, Container, Dropdown, FormControl, Nav, Navbar
import './playground.css';
import { JsonEditor } from './jsonEditor';
import { BicepEditor } from './bicepEditor';
import { copyShareLinkToClipboard, handleShareLink } from './utils';
import { getShareLink, handleShareLink } from './utils';
import { quickstartsPaths, getQuickstartsLink } from './examples';
import { decompile } from './lspInterop';
import { IApplicationInsights } from '@microsoft/applicationinsights-web';
Expand Down Expand Up @@ -69,7 +69,8 @@ export const Playground : React.FC<Props> = (props) => {
insights.trackEvent({ name: 'copySharedLink' });
setCopied(true);
setTimeout(() => setCopied(false), 2000);
copyShareLinkToClipboard(bicepContent);
const shareLink = getShareLink(bicepContent);
navigator.clipboard.writeText(shareLink);
}

const handleDecompileClick = (file: File) => {
Expand Down
11 changes: 8 additions & 3 deletions src/playground/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ export function handleShareLink(onContents: (contents : string | null) => void):
}
}

export function copyShareLinkToClipboard(content: string): void {
export function getShareLink(content: string) {
const contentHash = encodeHash(content);
const shareLink = `https://aka.ms/bicepdemo#${contentHash}`;
navigator.clipboard.writeText(shareLink);
let href = document.location.href;
if (href === 'https://azure.github.io/bicep/') {
// use aka.ms for the official site
href = 'https://aka.ms/bicepdemo';
}

return `${href}#${contentHash}`;
}

function encodeHash(content: string): string {
Expand Down

0 comments on commit ba02ef6

Please sign in to comment.