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

An/teal overquota leased warning #4404

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@

<div ng-switch-when="pay"
class="image-notice image-info__group status cost cost--pay"
style="{{ctrl.stylePercentageLeased(cost)}}"
ng-style="ctrl.stylePercentageLeased(cost, 'red')"
>
{{cost.count}} paid
</div>

<div ng-switch-when="overquota"
class="image-notice image-info__group status cost cost--pay"
style="{{ctrl.stylePercentageLeased(cost)}}"
ng-style="ctrl.stylePercentageLeased(cost, 'red')"
>
{{cost.count}} over quota
</div>

<div ng-switch-when="conditional"
class="image-notice image-info__group cost cost--conditional"
style="{{ctrl.stylePercentageLeased(cost)}}"
ng-style="ctrl.stylePercentageLeased(cost, 'orange')"
>
{{cost.count}} restricted
</div>
Expand Down
20 changes: 6 additions & 14 deletions kahuna/public/js/components/gr-info-panel/gr-info-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,18 @@ export const grInfoPanel = angular.module('grInfoPanel', [
]);

grInfoPanel.controller('GrInfoPanelCtrl', [
'$rootScope',
'$scope',
'$window',
'$q',
'inject$',
'subscribe$',
'mediaApi',
'imageAccessor',
'imageList',
'selectedImagesList$',
'labelService',
'editsService',
function (
$rootScope,
$scope,
$window,
$q,
inject$,
subscribe$,
mediaApi,
imageAccessor,
imageList,
selectedImagesList$,
labelService,
editsService) {

const ctrl = this;
Expand All @@ -70,10 +58,14 @@ grInfoPanel.controller('GrInfoPanelCtrl', [
map(allEditable => allEditable.every(v => v === true));
inject$($scope, selectionIsEditable$, ctrl, 'userCanEdit');

ctrl.stylePercentageLeased = cost => {
ctrl.stylePercentageLeased = (cost, alt) => {
const imageIsOfThisTypeAndIsLeased = (img) => img.data.cost === cost.data && img.data?.leases?.data?.leases?.some(lease => lease.access === 'allow-use' && lease.active);
const countLeased = ctrl.selectedImages.count(imageIsOfThisTypeAndIsLeased);
return `--pct-leased: ${Math.floor(100 * countLeased / cost.count)}`;
const percentageLeased = Math.floor(100 * countLeased / cost.count);

return {
'background-image': `linear-gradient(90deg, teal 0 ${percentageLeased}%, ${alt} ${percentageLeased}% 100%)`
};
};
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div
ng-if="ctrl.showInvalidReasons"
class="image-notice image-info__group validity validity--invalid validity--point-up"
ng-class="{'validity--invalid': ctrl.isStrongWarning, 'validity--warning': !ctrl.isStrongWarning}"
ng-class="{'validity--invalid': ctrl.isStrongWarning, 'validity--warning': !ctrl.isStrongWarning && !ctrl.isOverridden, 'validity--overridden': !ctrl.isStrongWarning && ctrl.isOverridden}"
>
<strong ng-if="!ctrl.isOverridden && !ctrl.isDeleted">{{ctrl.unusableTextHeader}}
<gr-icon title="This image cannot be used in content, a lease is required.">help</gr-icon>
Expand Down Expand Up @@ -38,5 +38,5 @@
{{ctrl.denySyndicationTextHeader}}
</li>
</ul>

</div>
13 changes: 1 addition & 12 deletions kahuna/public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1342,25 +1342,14 @@ textarea.ng-invalid {
.cost--conditional {
background-color: orange;
}
.validity--overridden,
.cost--leased {
background-color: teal;
}
.cost--free {
background-color: green;
}

.image-notice {
--pct-leased: 0;
}

.image-notice.cost--pay {
background-image: linear-gradient(90deg, teal 0 calc(var(--pct-leased) * 1%), red calc(var(--pct-leased) * 1%) 100%);
}

.image-notice.cost--conditional {
background-image: linear-gradient(90deg, teal 0 calc(var(--pct-leased) * 1%), orange calc(var(--pct-leased) * 1%) 100%);
}

.costs li {
display: inline-block;
}
Expand Down
Loading