Skip to content

Commit

Permalink
[TASK] Render asset usage counter inside inspector action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
soee committed Nov 5, 2023
1 parent 7947e65 commit ea2342c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
width: 100%;
margin-top: var(--theme-spacing-Full);
line-height: 1.5;
border-collapse: separate;
border-spacing: 0;
}

.usageTable th {
Expand All @@ -18,17 +20,13 @@

.usageTable td,
.usageTable th {
padding: var(--theme-spacing-Quarter);
padding: 0 var(--theme-spacing-Half);
height: var(--theme-unit);
}

.usageTable td:first-child,
.usageTable th:first-child {
padding-left: 0;
}

.usageTable td:last-child,
.usageTable th:last-child {
padding-right: 0;
.usageTable td {
border-top: 1px solid var(--theme-colors-ContrastDarker);
background-color: var(--theme-colors-ContrastNeutral);
}

/* This is for specificity; otherwise `.neos.neos-module a` would override this link style in the backend module */
Expand Down
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,43 @@
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(

Check warning on line 16 in Resources/Private/JavaScript/asset-usage/src/components/AssetUsagesToggleButton.tsx

View workflow job for this annotation

GitHub Actions / lint

'loading' is assigned a value but never used
asset ? { assetId: asset.id, assetSourceId: asset.assetSource.id } : null
);
const [assetUsagesModalOpen, setAssetUsagesModalOpen] = useRecoilState(assetUsageDetailsModalState);
const { translate } = useIntl();
const badgeTheme = { badge: 'primary'}

Check warning on line 21 in Resources/Private/JavaScript/asset-usage/src/components/AssetUsagesToggleButton.tsx

View workflow job for this annotation

GitHub Actions / lint

'badgeTheme' is assigned a value but never used

Check failure on line 21 in Resources/Private/JavaScript/asset-usage/src/components/AssetUsagesToggleButton.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `}` with `·};`

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

Check failure on line 34 in Resources/Private/JavaScript/asset-usage/src/components/AssetUsagesToggleButton.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····················label={assetUsageDetails[0].usages.length}⏎····················className={classes.assetUsageBadge}⏎···············` with `·label={assetUsageDetails[0].usages.length}·className={classes.assetUsageBadge}`
label={assetUsageDetails[0].usages.length}
className={classes.assetUsageBadge}
/>
) : (
<></>
)}
</Button>
);
};
Expand Down

0 comments on commit ea2342c

Please sign in to comment.