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

[Property grid]: update deps #1090

Merged
merged 15 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "none",
"type": "patch",
"comment": "DevDependency update",
"packageName": "@itwin/property-grid-react",
"email": "[email protected]",
"dependentChangeType": "none"
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion packages/itwin/property-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@itwin/itwinui-icons-react": "^2.8.0",
"@itwin/itwinui-illustrations-react": "^2.1.0",
"@itwin/itwinui-react": "^3.5.0",
"@itwin/itwinui-react": "^3.15.5",
"classnames": "^2.3.1",
"react-error-boundary": "^4.0.10"
},
Expand Down
70 changes: 11 additions & 59 deletions packages/itwin/property-grid/pnpm-lock.yaml

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 21 additions & 7 deletions packages/itwin/property-grid/src/hooks/UseContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import { useState } from "react";
import { useEffect, useState } from "react";
import { DropdownMenu, Flex, MenuItem } from "@itwin/itwinui-react";
import { FavoritePropertiesScope, Presentation } from "@itwin/presentation-frontend";
import { copyToClipboard } from "../api/WebUtilities";
Expand Down Expand Up @@ -92,9 +92,16 @@ export interface FavoritePropertiesContextMenuItemProps extends DefaultContextMe
*/
export function AddFavoritePropertyContextMenuItem({ field, imodel, scope, onSelect }: FavoritePropertiesContextMenuItemProps) {
const currentScope = scope ?? FavoritePropertiesScope.IModel;
if (!field || Presentation.favoriteProperties.has(field, imodel, currentScope)) {
return null;
}
const [hasFavorite, setHasFavorite] = useState(false);

useEffect(() => {
field &&
Presentation.favoriteProperties.hasAsync(field, imodel, currentScope).then((has) => {
return setHasFavorite(!has);
});
}, [currentScope, field, imodel]);

if (!hasFavorite || !field) return null;
MartynasStrazdas marked this conversation as resolved.
Show resolved Hide resolved

const defaultAction = async () => Presentation.favoriteProperties.add(field, imodel, currentScope);

Expand Down Expand Up @@ -122,9 +129,16 @@ export function AddFavoritePropertyContextMenuItem({ field, imodel, scope, onSel
*/
export function RemoveFavoritePropertyContextMenuItem({ field, imodel, scope, onSelect }: FavoritePropertiesContextMenuItemProps) {
const currentScope = scope ?? FavoritePropertiesScope.IModel;
if (!field || !Presentation.favoriteProperties.has(field, imodel, currentScope)) {
return null;
}
const [hasFavorite, setHasFavorite] = useState(false);

useEffect(() => {
field &&
Presentation.favoriteProperties.hasAsync(field, imodel, currentScope).then((has) => {
return setHasFavorite(has);
});
}, [currentScope, field, imodel]);

if (!hasFavorite || !field) return null;
MartynasStrazdas marked this conversation as resolved.
Show resolved Hide resolved

const defaultAction = async () => Presentation.favoriteProperties.remove(field, imodel, currentScope);

Expand Down
Loading