Skip to content

Commit 35df5eb

Browse files
committed
FIX: revert bug
1 parent cdd7e95 commit 35df5eb

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

app/assets/javascripts/admin/addon/components/admin-config-areas/color-palettes.gjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ export default class AdminConfigAreasColorPalettes extends Component {
3535
@action
3636
async newColorPaletteWithBase(baseKey) {
3737
let base;
38+
let base_scheme_id;
3839
if (baseKey && /^\d+$/.test(baseKey)) {
3940
base = this.allColorPalettes.findBy("id", baseKey);
41+
base_scheme_id = -1;
4042
} else {
4143
base = this.allColorPalettes.find(
4244
(palette) => palette.base_scheme_id === baseKey
4345
);
46+
base_scheme_id = base.get("base_scheme_id");
4447
}
4548
const newPalette = base.copy();
4649
newPalette.setProperties({
4750
name: i18n("admin.customize.colors.new_name"),
48-
base_scheme_id: base.get("base_scheme_id"),
51+
base_scheme_id,
4952
});
5053
await newPalette.save();
5154
await this.router.refresh();

app/assets/javascripts/admin/addon/controllers/admin-customize-colors.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,23 @@ export default class AdminCustomizeColorsController extends Controller {
178178
@action
179179
newColorSchemeWithBase(baseKey) {
180180
let base;
181+
let base_scheme_id;
181182
if (baseKey && /^\d+$/.test(baseKey)) {
182183
base = this.model.content.findBy("id", baseKey);
184+
base_scheme_id = -1;
183185
} else {
184186
base = this.allBaseColorSchemes.findBy("base_scheme_id", baseKey);
187+
base_scheme_id = base.get("base_scheme_id");
185188
}
186189

187190
const newColorScheme = base.copy();
188191
newColorScheme.setProperties({
189192
name: i18n("admin.customize.colors.new_name"),
190-
base_scheme_id: base.get("base_scheme_id"),
193+
base_scheme_id,
194+
});
195+
newColorScheme.colors = newColorScheme.colors.map((color) => {
196+
color.default_hex = null;
197+
return color;
191198
});
192199
newColorScheme.save().then(() => {
193200
this.model.pushObject(newColorScheme);

app/assets/javascripts/admin/addon/models/color-scheme-color.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export default class ColorSchemeColor extends EmberObject {
5656
// Whether the saved value is different than Discourse's default color scheme.
5757
@discourseComputed("default_hex", "hex")
5858
savedIsOverriden(defaultHex) {
59+
if (!defaultHex) {
60+
return false;
61+
}
5962
return this.originals.hex !== defaultHex;
6063
}
6164

app/serializers/color_scheme_color_serializer.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ def dark_hex
1212
end
1313

1414
def default_hex
15-
if object.color_scheme
16-
object.color_scheme.base_colors[object.name]
17-
else
18-
# it is a base color so it is already default
15+
# return the hex value of the color when based on custom scheme
16+
# or it is already a base color
17+
if !object.color_scheme || object.color_scheme.base_scheme_id == "-1"
1918
object.hex
19+
else
20+
object.color_scheme.base_colors[object.name]
2021
end
2122
end
2223

0 commit comments

Comments
 (0)