Skip to content

Commit c68e86b

Browse files
committed
fix: issue with layout group having an underscore in their id + mirrored section bug
1 parent 8bead68 commit c68e86b

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

app/frontend/editor/store/getters.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ export default (services) => ({
185185
isMirroredSection: ({ section }) => {
186186
return !isBlank(section.mirrorOf)
187187
},
188-
isMirroredSectionEditable: ({ theme, section, page }, {}) => {
188+
isMirroredSectionEditable: ({ theme, section, page }, { isMirroredSection }) => {
189+
if (!isMirroredSection) return false
189190
if (section.mirrorOf.enabled === false) return true
190191
return theme.mirrorSection === true || (theme.mirrorSection === 'protected' && section.mirrorOf?.pageId === page.id)
191192
}

app/frontend/editor/store/mutations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export default (services) => ({
6161
state.sectionBlocks = { ...state.sectionBlocks, ...entities.blocks }
6262
},
6363
SET_SECTIONS_CONTENT_LOCK_VERSIONS(state, lockVersions) {
64-
for (const layoutGroupId in lockVersions) {
64+
for (const { layoutGroupId, lockVersion } of lockVersions) {
6565
state.layoutGroups[layoutGroupId] = {
6666
...state.layoutGroups[layoutGroupId],
67-
lockVersion: lockVersions[layoutGroupId]
67+
lockVersion
6868
}
6969
}
7070
},

app/services/maglev/get_page_sections.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def fetch_stored_sections(group)
6262
end
6363

6464
def fetch_local_sections(layout_group)
65-
# TODO: potential bug here, why not relying on group['store'] instead of group['id']? what about page related store?
6665
content_group = sections_content.find { |group| group['id'] == layout_group.id }
6766

6867
return [[], 0] if content_group.blank?

app/views/maglev/api/sections_content/update.json.jbuilder

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
json.key_format! camelize: :lower
44
json.deep_format_keys!
55

6-
json.lock_versions(@stores.transform_values(&:lock_version))
6+
json.lock_versions(@stores.transform_values(&:lock_version).to_a.map do |(layout_group_id, lock_version)|
7+
{ layout_group_id: layout_group_id, lock_version: lock_version }
8+
end)

spec/requests/maglev/api/sections_content_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@
6767
expect(response).to have_http_status(:ok)
6868
# rubocop:disable Style/StringHashKeys
6969
expect(json_response).to match({
70-
'lockVersions' => { 'footer' => 0, 'header' => 1, 'main' => 1 }
70+
'lockVersions' => [
71+
{ 'layoutGroupId' => 'header', 'lockVersion' => 1 },
72+
{ 'layoutGroupId' => 'main', 'lockVersion' => 1 },
73+
{ 'layoutGroupId' => 'footer', 'lockVersion' => 0 }
74+
]
7175
})
7276
# rubocop:enable Style/StringHashKeys
7377
end

0 commit comments

Comments
 (0)