Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to itwin3 #142

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion packages/apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@itwin/delete-imodel-react": "^2.0.0",
"@itwin/delete-itwin-react": "^2.0.0",
"@itwin/imodel-browser-react": "~2.3.1",
"@itwin/itwinui-react": "^2.12.18",
"@itwin/itwinui-react": "^3.16.0",
"@itwin/manage-versions-react": "~2.0.0",
"@itwin/storybook-auth-addon": "^0.1.0",
"@storybook/addon-actions": "^6.5.16",
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/create-imodel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clean": "rimraf cjs esm"
},
"dependencies": {
"@itwin/itwinui-react": "^2.12.18"
"@itwin/itwinui-react": "^3.16.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~17.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { toaster } from "@itwin/itwinui-react";
import { useToaster } from "@itwin/itwinui-react";
import { act, fireEvent, render } from "@testing-library/react";
import React from "react";

Expand All @@ -28,7 +28,7 @@ describe("CreateIModel", () => {

it("should create an iModel", async () => {
const successMock = jest.fn();
toaster.positive = jest.fn();
useToaster().positive = jest.fn();

const { getByText, container } = render(
<CreateIModel
Expand Down Expand Up @@ -64,7 +64,7 @@ describe("CreateIModel", () => {
}
);
expect(successMock).toHaveBeenCalledWith(mockedimodel);
expect(toaster.positive).toHaveBeenCalledWith(
expect(useToaster().positive).toHaveBeenCalledWith(
"iModel created successfully.",
{
hasCloseButton: true,
Expand All @@ -76,7 +76,7 @@ describe("CreateIModel", () => {
const errorMock = jest.fn();
const error = new Error("Fail");
fetchMock.mockImplementationOnce(() => Promise.reject(error));
toaster.negative = jest.fn();
useToaster().negative = jest.fn();

const { getByText, container } = render(
<CreateIModel
Expand Down Expand Up @@ -120,7 +120,7 @@ describe("CreateIModel", () => {
}
);
expect(errorMock).toHaveBeenCalledWith(error);
expect(toaster.negative).toHaveBeenCalledWith(
expect(useToaster().negative).toHaveBeenCalledWith(
"Could not create an iModel. Please try again later.",
{ hasCloseButton: true }
);
Expand All @@ -130,7 +130,7 @@ describe("CreateIModel", () => {
const errorMock = jest.fn();
const error = { error: { code: "iModelExists" } };
fetchMock.mockImplementationOnce(() => Promise.reject(error));
toaster.negative = jest.fn();
useToaster().negative = jest.fn();

const { getByText, container } = render(
<CreateIModel
Expand Down Expand Up @@ -166,7 +166,7 @@ describe("CreateIModel", () => {
}
);
expect(errorMock).toHaveBeenCalledWith(error);
expect(toaster.negative).toHaveBeenCalledWith(
expect(useToaster().negative).toHaveBeenCalledWith(
"iModel with the same name already exists within the iTwin.",
{ hasCloseButton: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { toaster } from "@itwin/itwinui-react";
import { useToaster } from "@itwin/itwinui-react";
import React from "react";

import { iModelExtent, IModelFull } from "../../types";
Expand Down Expand Up @@ -145,7 +145,7 @@ export function CreateIModel(props: CreateIModelProps) {
});
}
setIsLoading(false);
toaster.positive(updatedStrings.successMessage, {
useToaster().positive(updatedStrings.successMessage, {
hasCloseButton: true,
});
onSuccess?.(createdimodel);
Expand All @@ -163,7 +163,7 @@ export function CreateIModel(props: CreateIModelProps) {
error?.error?.code === "iModelExists"
? updatedStrings.errorMessageIModelExists
: updatedStrings.errorMessage;
toaster.negative(errorString, { hasCloseButton: true });
useToaster().negative(errorString, { hasCloseButton: true });
onError?.(error);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function IModelName() {

return (
<LabeledInput
setFocus
autoFocus
label={nameString ?? "Name"}
name="name"
required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { toaster } from "@itwin/itwinui-react";
import { useToaster } from "@itwin/itwinui-react";
import { act, fireEvent, render } from "@testing-library/react";
import React from "react";

Expand All @@ -29,7 +29,7 @@ describe("UpdateIModel", () => {

it("should update an iModel", async () => {
const successMock = jest.fn();
toaster.positive = jest.fn();
useToaster().positive = jest.fn();

const { getByText, container } = render(
<UpdateIModel
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("UpdateIModel", () => {
}
);
expect(successMock).toHaveBeenCalledWith(mockedimodel);
expect(toaster.positive).toHaveBeenCalledWith(
expect(useToaster().positive).toHaveBeenCalledWith(
"iModel updated successfully.",
{
hasCloseButton: true,
Expand All @@ -86,7 +86,7 @@ describe("UpdateIModel", () => {

it("should enable update when extent is removed", async () => {
const successMock = jest.fn();
toaster.positive = jest.fn();
useToaster().positive = jest.fn();

const { getByText, rerender } = render(
<UpdateIModel
Expand Down Expand Up @@ -147,7 +147,7 @@ describe("UpdateIModel", () => {
}
);
expect(successMock).toHaveBeenCalledWith(mockedimodel);
expect(toaster.positive).toHaveBeenCalledWith(
expect(useToaster().positive).toHaveBeenCalledWith(
"iModel updated successfully.",
{
hasCloseButton: true,
Expand All @@ -159,7 +159,7 @@ describe("UpdateIModel", () => {
const errorMock = jest.fn();
const error = new Error("Fail");
fetchMock.mockImplementationOnce(() => Promise.reject(error));
toaster.negative = jest.fn();
useToaster().negative = jest.fn();

const { getByText, container } = render(
<UpdateIModel
Expand Down Expand Up @@ -198,7 +198,7 @@ describe("UpdateIModel", () => {
}
);
expect(errorMock).toHaveBeenCalledWith(error);
expect(toaster.negative).toHaveBeenCalledWith(
expect(useToaster().negative).toHaveBeenCalledWith(
"Could not update an iModel. Please try again later.",
{ hasCloseButton: true }
);
Expand All @@ -208,7 +208,7 @@ describe("UpdateIModel", () => {
const errorMock = jest.fn();
const error = { error: { code: "iModelExists" } };
fetchMock.mockImplementationOnce(() => Promise.reject(error));
toaster.negative = jest.fn();
useToaster().negative = jest.fn();

const { getByText, container } = render(
<UpdateIModel
Expand Down Expand Up @@ -247,7 +247,7 @@ describe("UpdateIModel", () => {
}
);
expect(errorMock).toHaveBeenCalledWith(error);
expect(toaster.negative).toHaveBeenCalledWith(
expect(useToaster().negative).toHaveBeenCalledWith(
"iModel with the same name already exists within the iTwin.",
{ hasCloseButton: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { toaster } from "@itwin/itwinui-react";
import { useToaster } from "@itwin/itwinui-react";
import React from "react";

import { BaseIModel, iModelExtent, IModelFull } from "../../types";
Expand Down Expand Up @@ -149,7 +149,7 @@ export function UpdateIModel(props: UpdateIModelProps) {
});
}
setIsLoading(false);
toaster.positive(updatedStrings.successMessage, {
useToaster().positive(updatedStrings.successMessage, {
hasCloseButton: true,
});
onSuccess?.(updatedimodel);
Expand All @@ -167,7 +167,7 @@ export function UpdateIModel(props: UpdateIModelProps) {
error?.error?.code === "iModelExists"
? updatedStrings.errorMessageIModelExists
: updatedStrings.errorMessage;
toaster.negative(errorString, { hasCloseButton: true });
useToaster().negative(errorString, { hasCloseButton: true });
onError?.(error);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import "./UploadImage.scss";

import { FileUpload, FileUploadTemplate, toaster } from "@itwin/itwinui-react";
import { FileUpload, FileUploadTemplate, useToaster } from "@itwin/itwinui-react";
import React from "react";

import { useIModelContext } from "../context/imodel-context";
Expand Down Expand Up @@ -72,7 +72,7 @@ export function UploadImage({
const file: File = files[0];
const error = ImageHelper.validateImage(file);
if (!!error) {
toaster.negative(updatedStrings[error], {
useToaster().negative(updatedStrings[error], {
hasCloseButton: true,
});
return;
Expand All @@ -81,7 +81,7 @@ export function UploadImage({
const reader = new FileReader();
reader.onloadend = () => {
if (reader.error) {
toaster.negative(error, {
useToaster().negative(error, {
hasCloseButton: true,
});
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/delete-imodel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@itwin/itwinui-icons-react": "^2.2.0",
"@itwin/itwinui-react": "^2.12.18"
"@itwin/itwinui-react": "^3.16.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~17.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ModalContent,
ProgressRadial,
ThemeProvider,
toaster,
useToaster,
} from "@itwin/itwinui-react";
import React from "react";

Expand Down Expand Up @@ -79,7 +79,7 @@ export function DeleteIModel(props: DeleteIModelProps) {
throw new Error(response.statusText);
} else {
setIsLoading(false);
toaster.positive(
useToaster().positive(
stringsOverrides?.successMessage ?? "iModel deleted successfully."
);
onSuccess?.();
Expand All @@ -93,7 +93,7 @@ export function DeleteIModel(props: DeleteIModelProps) {

const error = (error: Error) => {
setIsLoading(false);
toaster.negative(
useToaster().negative(
stringsOverrides?.errorMessage ??
"Could not delete an iModel. Please try again later."
);
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/delete-itwin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@itwin/itwinui-icons-react": "^2.2.0",
"@itwin/itwinui-react": "^2.12.18"
"@itwin/itwinui-react": "^3.16.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~17.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ModalButtonBar,
ProgressRadial,
ThemeProvider,
toaster,
useToaster,
} from "@itwin/itwinui-react";
import React from "react";

Expand Down Expand Up @@ -72,7 +72,7 @@ export const DeleteITwin = (props: DeleteITwinProps) => {
throw new Error(response.statusText);
} else {
setIsLoading(false);
toaster.positive(
useToaster().positive(
stringsOverrides?.successMessage ?? "iTwin deleted successfully."
);
onSuccess?.();
Expand All @@ -86,7 +86,7 @@ export const DeleteITwin = (props: DeleteITwinProps) => {

const error = (error: Error) => {
setIsLoading(false);
toaster.negative(
useToaster().negative(
stringsOverrides?.errorMessage ??
"Could not delete an iTwin. Please try again later."
);
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/imodel-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
],
"dependencies": {
"@itwin/itwinui-icons-react": "^2.2.0",
"@itwin/itwinui-react": "^2.12.18",
"@itwin/itwinui-react": "^3.16.0",
"classnames": "^2.2.6",
"react-intersection-observer": "^8.31.1"
},
Expand Down Expand Up @@ -74,6 +74,7 @@
"rollup": "^2.42.4",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.36.0",
"stylelint": "^13.6.1",
"stylelint-config-prettier": "^8.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/modules/manage-versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
],
"dependencies": {
"@itwin/itwinui-icons-react": "^2.2.0",
"@itwin/itwinui-react": "^2.12.18",
"@itwin/itwinui-react": "^3.16.0",
"classnames": "^2.2.6"
},
"devDependencies": {
"@rollup/plugin-commonjs": "~17.1.0",
"@rollup/plugin-image": "^2.0.6",
"@testing-library/react": "^11.1.0",
"@types/jest": "^27.5.1",
"@types/react": "^18.3.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { toaster } from "@itwin/itwinui-react";
import { useToaster } from "@itwin/itwinui-react";
import {
fireEvent,
render,
Expand Down Expand Up @@ -45,6 +45,7 @@ const renderComponent = (initialProps?: Partial<CreateVersionModalProps>) => {
};

describe("CreateVersionModal", () => {
const toaster = useToaster();
const mockCreateVersion = jest.spyOn(NamedVersionClient.prototype, "create");
const mockPositiveToast = jest.spyOn(toaster, "positive");
const mockNegativeToast = jest.spyOn(toaster, "negative");
Expand Down
Loading
Loading