Skip to content

Commit 8d617a0

Browse files
committed
feat: Enhance MapCard component to conditionally display footer actions based on report state
1 parent d04d115 commit 8d617a0

2 files changed

Lines changed: 32 additions & 18 deletions

File tree

cypress/e2e/snowflake-s3/fork.cy.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ describe('fork', () => {
2626

2727
// change user
2828
cy.setCookie('dekart-dev-claim-email', 'test2@gmail.com')
29-
cy.reload()
29+
cy.visit('/')
30+
cy.get('span').contains('Shared Maps').click()
31+
cy.contains('.dekart-map-card', 'Untitled', { timeout: 20000 }).as('sharedMapCard')
32+
cy.get('@sharedMapCard').find('[data-testid="map-card-divider"]').should('not.exist')
33+
cy.get('@sharedMapCard').find('[data-testid="map-card-footer-actions"]').should('not.exist')
34+
cy.get('@sharedMapCard').click()
3035

3136
// fork report
3237
cy.get('button#dekart-fork-button').click()

src/client/HomePage.jsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ function MapCard ({ report, reportFilter, archived, authEnabled }) {
385385

386386
const { previewUrl, previewLoading, previewError, setPreviewLoading, setPreviewError } = useMapPreview(report, isVisible)
387387
const centerCoordinates = getMapCenterCoordinates(report.mapConfig)
388+
const showArchiveAction = reportFilter === 'my'
389+
const showEditAction = report.canWrite && !report.archived
390+
const showFooterActions = showArchiveAction || showEditAction
388391

389392
const handleEdit = (e) => {
390393
e.stopPropagation()
@@ -452,23 +455,29 @@ function MapCard ({ report, reportFilter, archived, authEnabled }) {
452455
{getRelativeTime(modifiedDate)}
453456
</div>
454457
</div>
455-
<div className={styles.mapCardDivider} />
456-
<div className={styles.mapFooterActions}>
457-
{reportFilter === 'my' ? <ArchiveReportButton report={report} /> : <span />}
458-
{report.canWrite && !report.archived
459-
? (
460-
<Button
461-
type='default'
462-
size='small'
463-
icon={<EditOutlined />}
464-
onClick={handleEdit}
465-
className={styles.mapActionButton}
466-
title='Edit'
467-
>Edit
468-
</Button>
469-
)
470-
: null}
471-
</div>
458+
{showFooterActions
459+
? (
460+
<>
461+
<div className={styles.mapCardDivider} data-testid='map-card-divider' />
462+
<div className={styles.mapFooterActions} data-testid='map-card-footer-actions'>
463+
{showArchiveAction ? <ArchiveReportButton report={report} /> : null}
464+
{showEditAction
465+
? (
466+
<Button
467+
type='default'
468+
size='small'
469+
icon={<EditOutlined />}
470+
onClick={handleEdit}
471+
className={styles.mapActionButton}
472+
title='Edit'
473+
>Edit
474+
</Button>
475+
)
476+
: null}
477+
</div>
478+
</>
479+
)
480+
: null}
472481
</div>
473482
</div>
474483
</div>

0 commit comments

Comments
 (0)