Skip to content

Commit 76ed039

Browse files
authored
Merge pull request guardian#4343 from guardian/only-display-crop-gutters-via-url-param
add a `shouldShowCropGuttersIfApplicable` query param
2 parents bdc53c3 + 2ac4d87 commit 76ed039

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

kahuna/public/js/crop/controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ crop.controller('ImageCropCtrl', [
182182

183183
const maybeCropRatioIfStandard = cropOptions.find(_ => _.key === ctrl.cropType)?.ratioString;
184184
ctrl.shouldShowVerticalWarningGutters =
185-
getFeatureSwitchActive("show-cropping-gutters-switch")
186-
&& window._clientConfig.staffPhotographerOrganisation === "GNM"
185+
window._clientConfig.staffPhotographerOrganisation === "GNM"
186+
&& cropSettings.shouldShowCropGuttersIfApplicable()
187+
&& getFeatureSwitchActive("show-cropping-gutters-switch")
187188
&& maybeCropRatioIfStandard === "5:3";
188189

189190
if (isCropTypeDisabled) {

kahuna/public/js/crop/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ crop.config(['$stateProvider',
1818
function($stateProvider) {
1919

2020
$stateProvider.state('crop', {
21-
url: '/images/:imageId/crop?cropType&customRatio',
21+
url: '/images/:imageId/crop?cropType&customRatio&shouldShowCropGuttersIfApplicable',
2222
template: cropTemplate,
2323
controller: 'ImageCropCtrl',
2424
controllerAs: 'ctrl',

kahuna/public/js/image/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ image.config(['$stateProvider',
2323
function($stateProvider) {
2424

2525
$stateProvider.state('image', {
26-
url: '/images/:imageId?crop?cropType&customRatio',
26+
url: '/images/:imageId?crop?cropType&customRatio&shouldShowCropGuttersIfApplicable',
2727
template: imageTemplate,
2828
controller: 'ImageCtrl',
2929
controllerAs: 'ctrl',

kahuna/public/js/search/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ search.config(['$stateProvider', '$urlMatcherFactoryProvider',
7373
$stateProvider.state('search', {
7474
// FIXME [1]: This state should be abstract, but then we can't navigate to
7575
// it, which we need to do to access it's deeper / remembered chile state
76-
url: '/?cropType&customRatio',
76+
url: '/?cropType&customRatio&shouldShowCropGuttersIfApplicable',
7777
template: searchTemplate,
7878
deepStateRedirect: {
7979
// Inject a transient $stateParams for the results state

kahuna/public/js/util/crop.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { landscape, portrait, video, square, freeform, cropOptions } from './con
44

55
const CROP_TYPE_STORAGE_KEY = 'cropType';
66
const CUSTOM_CROP_STORAGE_KEY = 'customCrop';
7+
const SHOULD_SHOW_CROP_GUTTERS_IF_APPLICABLE_STORAGE_KEY = 'shouldShowCropGuttersIfApplicable';
78

89
const customCrop = (label, xRatio, yRatio) => {
910
return { key:label, ratio: xRatio / yRatio, ratioString: `${xRatio}:${yRatio}`};
@@ -61,7 +62,15 @@ cropUtil.factory('cropSettings', ['storage', function(storage) {
6162
}
6263
};
6364

64-
function set({cropType, customRatio}) {
65+
const setShouldShowCropGuttersIfApplicable = shouldShowCropGuttersIfApplicableStr => {
66+
storage.setJs(
67+
SHOULD_SHOW_CROP_GUTTERS_IF_APPLICABLE_STORAGE_KEY,
68+
shouldShowCropGuttersIfApplicableStr === "true",
69+
true
70+
);
71+
};
72+
73+
function set({cropType, customRatio, shouldShowCropGuttersIfApplicable}) {
6574
// set customRatio first in case cropType relies on a custom crop
6675
if (customRatio) {
6776
setCustomCrop(customRatio);
@@ -71,6 +80,10 @@ cropUtil.factory('cropSettings', ['storage', function(storage) {
7180
setCropType(cropType);
7281
}
7382

83+
if (shouldShowCropGuttersIfApplicable) {
84+
setShouldShowCropGuttersIfApplicable(shouldShowCropGuttersIfApplicable);
85+
}
86+
7487
}
7588

7689
function getCropType() {
@@ -81,7 +94,11 @@ cropUtil.factory('cropSettings', ['storage', function(storage) {
8194
}
8295
}
8396

84-
return { set, getCropType, getCropOptions };
97+
function shouldShowCropGuttersIfApplicable() {
98+
return storage.getJs(SHOULD_SHOW_CROP_GUTTERS_IF_APPLICABLE_STORAGE_KEY, true);
99+
}
100+
101+
return { set, getCropType, getCropOptions, shouldShowCropGuttersIfApplicable };
85102
}]);
86103

87104
cropUtil.filter('asCropType', function() {

0 commit comments

Comments
 (0)