Skip to content
Draft
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
14 changes: 7 additions & 7 deletions brainstorm/src/app_load.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { AzureClient } from "@fluidframework/azure-client";
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { AzureClient } from "@fluidframework/azure-client";
import { OdspClient } from "@fluidframework/odsp-client/beta";
import React from "react";
import type { OdspClient } from "@fluidframework/odsp-client/beta";
import type { IFluidContainer } from "fluid-framework";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import { createRoot } from "react-dom/client";

import { loadFluidData } from "./infra/fluid.js";
import { ReactApp } from "./react/ux.js";
import { Items, appTreeConfiguration } from "./schema/app_schema.js";
import { containerSchema } from "./schema/container_schema.js";
import { sessionTreeConfiguration } from "./schema/session_schema.js";
import { createUndoRedoStacks } from "./utils/undo.js";
import { containerSchema } from "./schema/container_schema.js";
import { loadFluidData } from "./infra/fluid.js";
import { IFluidContainer } from "fluid-framework";

export async function loadApp(
client: AzureClient | OdspClient,
Expand Down Expand Up @@ -39,7 +39,7 @@ export async function loadApp(
// create the root element for React
const app = document.createElement("div");
app.id = "app";
document.body.appendChild(app);
document.body.append(app);
const root = createRoot(app);

// Create undo/redo stacks for the app
Expand Down
8 changes: 5 additions & 3 deletions brainstorm/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
* Licensed under the MIT License.
*/

import { speStart } from "./start/spe_start.js";
import { anonymousAzureStart } from "./start/azure_start.js";
import { speStart } from "./start/spe_start.js";

async function start() {
const client = process.env.FLUID_CLIENT;

switch (client) {
case "spe":
case "spe": {
// Start the app in SPE mode
await speStart();
break;
default:
}
default: {
// Start the app in Azure mode
await anonymousAzureStart();
break;
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions brainstorm/src/infra/azure/azureClientProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type {
AzureLocalConnectionConfig,
ITelemetryBaseLogger,
} from "@fluidframework/azure-client";
import { InsecureTokenProvider } from "./azureTokenProvider.js";
import { AzureFunctionTokenProvider, azureUser, user } from "./azureTokenProvider.js";

import { InsecureTokenProvider, AzureFunctionTokenProvider, azureUser, user } from "./azureTokenProvider.js";

const client = process.env.FLUID_CLIENT;
const local = client === undefined || client === "local";
Expand All @@ -20,12 +20,12 @@ if (local) {

const remoteConnectionConfig: AzureRemoteConnectionConfig = {
type: "remote",
tenantId: process.env.AZURE_TENANT_ID!,
tenantId: process.env.AZURE_TENANT_ID ?? "",
tokenProvider: new AzureFunctionTokenProvider(
process.env.AZURE_FUNCTION_TOKEN_PROVIDER_URL!,
process.env.AZURE_FUNCTION_TOKEN_PROVIDER_URL ?? "",
azureUser,
),
endpoint: process.env.AZURE_ORDERER!,
endpoint: process.env.AZURE_ORDERER ?? "",
};

const localConnectionConfig: AzureLocalConnectionConfig = {
Expand All @@ -34,9 +34,9 @@ const localConnectionConfig: AzureLocalConnectionConfig = {
endpoint: "http://localhost:7070",
};

const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = !local
? remoteConnectionConfig
: localConnectionConfig;
const connectionConfig: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = local
? localConnectionConfig
: remoteConnectionConfig;

export function getClientProps(logger?: ITelemetryBaseLogger): AzureClientProps {
return {
Expand Down
6 changes: 3 additions & 3 deletions brainstorm/src/infra/azure/azureTokenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Licensed under the MIT License.
*/

import { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client";
import type { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client";
import { ScopeType } from "@fluidframework/protocol-definitions";
import axios from "axios";
import { KJUR as jsrsasign } from "jsrsasign";
import { v4 as uuid } from "uuid";
import { uniqueNamesGenerator, names } from "unique-names-generator";
import { v4 as uuid } from "uuid";

/**
* Insecure user definition.
Expand Down Expand Up @@ -154,7 +154,7 @@ export function generateToken(
lifetime: number = 60 * 60,
ver = "1.0",
): string {
let userClaim = user ? user : generateUser();
let userClaim = user ?? generateUser();
if (userClaim.id === "" || userClaim.id === undefined) {
userClaim = generateUser();
}
Expand Down
6 changes: 3 additions & 3 deletions brainstorm/src/infra/fluid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* Licensed under the MIT License.
*/

import type { AzureClient, AzureContainerServices } from "@fluidframework/azure-client";
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { AzureClient, AzureContainerServices } from "@fluidframework/azure-client";
import { ContainerSchema, IFluidContainer } from "fluid-framework";
import { OdspClient, OdspContainerServices } from "@fluidframework/odsp-client/beta";
import type { OdspClient, OdspContainerServices } from "@fluidframework/odsp-client/beta";
import type { ContainerSchema, IFluidContainer } from "fluid-framework";

/**
* This function will create a container if no container ID is passed.
Expand Down
18 changes: 10 additions & 8 deletions brainstorm/src/infra/spe/graphHelper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { PublicClientApplication, InteractionType, AccountInfo } from "@azure/msal-browser";
import type { PublicClientApplication, AccountInfo } from "@azure/msal-browser";
import { InteractionType } from "@azure/msal-browser";
import { Client } from "@microsoft/microsoft-graph-client";
import type {
AuthCodeMSALBrowserAuthenticationProviderOptions} from "@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser/index.js";
import {
AuthCodeMSALBrowserAuthenticationProvider,
AuthCodeMSALBrowserAuthenticationProviderOptions,
AuthCodeMSALBrowserAuthenticationProvider
} from "@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser/index.js";
import { Site } from "@microsoft/microsoft-graph-types";
import type { Site } from "@microsoft/microsoft-graph-types";

export interface FileStorageContainer {
containerTypeId: string;
Expand Down Expand Up @@ -56,19 +58,19 @@ export class GraphHelper {
try {
const response = await this.graphClient
.api("/storage/fileStorage/containers")
.filter("containerTypeId eq " + containerTypeId)
.filter(`containerTypeId eq ${ containerTypeId}`)
.version("beta")
.get();

const fileStorageContainers: FileStorageContainer[] = response.value;

if (fileStorageContainers.length == 0) {
if (fileStorageContainers.length === 0) {
throw new Error("TEST: no fileStorageContainers");
}

return fileStorageContainers[0].id;
} catch (error) {
console.error("Error while fetching file storage container ID: ", error);
console.error("Error while fetching file storage container ID:", error);
throw error; // re-throw the error if you want it to propagate
}
}
Expand Down Expand Up @@ -97,7 +99,7 @@ export class GraphHelper {
.api(`/drives/${driveId}/items/${id}/createLink`)
.post(permission);

console.log("createSharingLink response: ", response.link);
console.log("createSharingLink response:", response.link);

return response.shareId as string;
}
Expand Down
8 changes: 4 additions & 4 deletions brainstorm/src/infra/spe/speClientProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
import { IOdspTokenProvider, OdspClientProps } from "@fluidframework/odsp-client/beta";
import type { IOdspTokenProvider, OdspClientProps } from "@fluidframework/odsp-client/beta";

// Create the client props for the Fluid client
export const getClientProps = (
Expand All @@ -9,9 +9,9 @@ export const getClientProps = (
logger?: ITelemetryBaseLogger,
): OdspClientProps => {
const connectionConfig = {
tokenProvider: tokenProvider,
siteUrl: siteUrl,
driveId: driveId,
tokenProvider,
siteUrl,
driveId,
filePath: "",
};

Expand Down
11 changes: 6 additions & 5 deletions brainstorm/src/infra/spe/speTokenProvider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
import type {
AuthenticationResult,
InteractionRequiredAuthError,
PublicClientApplication,
PublicClientApplication} from "@azure/msal-browser";
import {
InteractionRequiredAuthError
} from "@azure/msal-browser";
import { IOdspTokenProvider, TokenResponse } from "@fluidframework/odsp-client/beta";
import type { IOdspTokenProvider, TokenResponse } from "@fluidframework/odsp-client/beta";

// Sample implementation of the IOdspTokenProvider interface
// This class is used to provide the token for the Fluid container and
Expand Down Expand Up @@ -48,7 +49,7 @@ export class SampleOdspTokenProvider implements IOdspTokenProvider {
scopes: scope,
});
} else {
throw new Error(`MSAL error: ${error}`);
throw new TypeError(`MSAL error: ${error}`);
}
}
return response.accessToken;
Expand Down
4 changes: 2 additions & 2 deletions brainstorm/src/infra/tokenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client";
import type { AzureMember, ITokenProvider, ITokenResponse, IUser } from "@fluidframework/azure-client";
import { ScopeType } from "@fluidframework/protocol-definitions";
import axios from "axios";
import { KJUR as jsrsasign } from "jsrsasign";
Expand Down Expand Up @@ -153,7 +153,7 @@ export function generateToken(
lifetime: number = 60 * 60,
ver = "1.0",
): string {
let userClaim = user ? user : generateUser();
let userClaim = user ?? generateUser();
if (userClaim.id === "" || userClaim.id === undefined) {
userClaim = generateUser();
}
Expand Down
28 changes: 14 additions & 14 deletions brainstorm/src/react/buttonux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* Licensed under the MIT License.
*/

import React, { JSX } from "react";
import { Items, Note } from "../schema/app_schema.js";
import { moveItem, findNote } from "../utils/app_helpers.js";
import {
ThumbLikeFilled,
DismissFilled,
Expand All @@ -15,9 +12,16 @@ import {
ArrowUndoFilled,
ArrowRedoFilled,
} from "@fluentui/react-icons";
import { Session } from "../schema/session_schema.js";
import { getSelectedNotes } from "../utils/session_helpers.js";
import { Tree } from "fluid-framework";
import type { JSX } from "react";
import type React from "react";

import type { Items} from "../schema/app_schema.js";
import { Note } from "../schema/app_schema.js";
import type { Session } from "../schema/session_schema.js";
import { moveItem, findNote } from "../utils/app_helpers.js";
import { getSelectedNotes } from "../utils/session_helpers.js";


export function NewGroupButton(props: {
items: Items;
Expand Down Expand Up @@ -159,10 +163,10 @@ export function IconButton(props: {
return (
<button
className={
props.color +
" " +
props.background +
" hover:bg-gray-600 hover:text-white font-bold px-2 py-1 rounded inline-flex items-center h-6 grow"
`${props.color
} ${
props.background
} hover:bg-gray-600 hover:text-white font-bold px-2 py-1 rounded inline-flex items-center h-6 grow`
}
onClick={(e) => handleClick(e)}
>
Expand All @@ -178,11 +182,7 @@ IconButton.defaultProps = {
};

function IconButtonText(props: { children: React.ReactNode }): JSX.Element {
if (props.children == undefined) {
return <span></span>;
} else {
return <span className="text-sm pl-2 leading-none">{props.children}</span>;
}
return props.children === undefined ? <span></span> : <span className="text-sm pl-2 leading-none">{props.children}</span>;
}

function MiniX(): JSX.Element {
Expand Down
Loading
Loading