Skip to content

Commit f7eeec0

Browse files
committed
handle failed export, show pattern actions for non-hover
1 parent 853a1dc commit f7eeec0

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/components/design-library-list/editor.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@
6868
display: flex;
6969
gap: 24px;
7070
visibility: hidden;
71+
@media (hover: none) {
72+
opacity: 1;
73+
}
7174

7275
.ugb-button-component {
7376
width: 100%;
7477
justify-content: center;
7578
pointer-events: none;
79+
@media (hover: none) {
80+
pointer-events: auto;
81+
}
7682
}
7783
}
7884
&:hover {

src/welcome/import-export/index.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,30 @@ const getExportFileName = () => {
140140
return `stackable-export-${ y }${ m }${ d }-${ h }${ min }${ s }.json`
141141
}
142142

143-
const ExportSettings = ( { settings, onClose } ) => {
143+
const ExportSettings = ( {
144+
settings, onClose, setNotice,
145+
} ) => {
144146
const [ exportedSettings, setExportedSettings ] = useState( {} )
145147

146148
const handleExport = () => {
147-
const dataStr = JSON.stringify( exportedSettings, null, 4 )
148-
const blob = new Blob( [ dataStr ], { type: 'application/json' } )
149-
const url = URL.createObjectURL( blob )
150-
const a = document.createElement( 'a' )
151-
a.href = url
152-
153-
a.download = getExportFileName()
154-
document.body.appendChild( a )
155-
a.click()
156-
document.body.removeChild( a )
157-
URL.revokeObjectURL( url )
158-
onClose()
149+
try {
150+
const dataStr = JSON.stringify( exportedSettings, null, 4 )
151+
const blob = new Blob( [ dataStr ], { type: 'application/json' } )
152+
const url = URL.createObjectURL( blob )
153+
const a = document.createElement( 'a' )
154+
a.href = url
155+
156+
a.download = getExportFileName()
157+
document.body.appendChild( a )
158+
a.click()
159+
document.body.removeChild( a )
160+
URL.revokeObjectURL( url )
161+
onClose()
162+
} catch ( e ) {
163+
setNotice( __( 'Failed to export settings.', i18n ) )
164+
// eslint-disable-next-line no-console
165+
console.error( sprintf( __( 'Stackable: Export error - %s', i18n ), e ) )
166+
}
159167
}
160168

161169
const AllExportSettings = useMemo( () => applyFilters( 'stackable.admin-settings.export-settings', Fragment ), [] )

0 commit comments

Comments
 (0)