-
Notifications
You must be signed in to change notification settings - Fork 17
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
[TASK] Render asset usage counter inside inspector action buttons #221
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.assetUsageBadge { | ||
color: var(--theme-blue); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import React from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
|
||
import { Button, Icon } from '@neos-project/react-ui-components'; | ||
import { Badge, Button, Icon } from '@neos-project/react-ui-components'; | ||
|
||
import { useIntl } from '@media-ui/core'; | ||
import { useSelectedAsset } from '@media-ui/core/src/hooks'; | ||
|
||
import assetUsageDetailsModalState from '../state/assetUsageDetailsModalState'; | ||
import useAssetUsagesQuery from '@media-ui/feature-asset-usage/src/hooks/useAssetUsages'; | ||
|
||
import classes from './AssetUsagesToggleButton.module.css'; | ||
|
||
const AssetUsagesToggleButton: React.FC = () => { | ||
const { isInUse } = useSelectedAsset(); | ||
const asset = useSelectedAsset(); | ||
const { assetUsageDetails, loading } = useAssetUsagesQuery( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I intentionally didn't do this due to performance reasons with the default usage strategy implementation. You could do it though if you check for the feature flag |
||
asset ? { assetId: asset.id, assetSourceId: asset.assetSource.id } : null | ||
); | ||
const [assetUsagesModalOpen, setAssetUsagesModalOpen] = useRecoilState(assetUsageDetailsModalState); | ||
const { translate } = useIntl(); | ||
|
||
return ( | ||
<Button | ||
disabled={isInUse === false} | ||
disabled={asset.isInUse === false} | ||
size="regular" | ||
style={assetUsagesModalOpen ? 'brand' : 'lighter'} | ||
hoverStyle="brand" | ||
onClick={() => setAssetUsagesModalOpen(true)} | ||
> | ||
<Icon icon="link" /> | ||
{translate('assetUsageList.toggle', 'Show usages')} | ||
{assetUsageDetails?.[0]?.usages ? ( | ||
<Badge label={assetUsageDetails[0].usages.length} className={classes.assetUsageBadge} /> | ||
) : ( | ||
<></> | ||
)} | ||
</Button> | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the blue on white for the badge fits well with the rest of the module.
I would rather use white on one of our grey colors.