Skip to content

Commit 56d4428

Browse files
committed
Publish map button
- add slot to project view buttons - add publish method to projectStore - add post call to project Api
1 parent 846a396 commit 56d4428

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

web-app/packages/lib/src/modules/project/projectApi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,11 @@ export const ProjectApi = {
344344
return ProjectModule.httpService.get(
345345
`/v2/projects/${projectId}/collaborators`
346346
)
347+
},
348+
349+
async publishMap(projectId: string) {
350+
return ProjectModule.httpService.post(
351+
`/app/projects/${projectId}/map-links`
352+
)
347353
}
348354
}

web-app/packages/lib/src/modules/project/store.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,28 @@ export const useProjectStore = defineStore('projectModule', {
980980
await notificationStore.error({
981981
text: getErrorMessage(err, 'Failed to push changes')
982982
})
983+
},
984+
985+
/**
986+
* Publishes the map of the latest project version.
987+
*/
988+
async publishMap() {
989+
const notificationStore = useNotificationStore()
990+
991+
try {
992+
const response = await ProjectApi.publishMap(this.project.id)
993+
const hash = response.data.map_link
994+
const url = `${window.location.origin}/${hash}`
995+
navigator.clipboard.writeText(url)
996+
notificationStore.show({
997+
text: 'Link to public map copied to your clipboard.',
998+
severity: 'success'
999+
})
1000+
} catch {
1001+
notificationStore.error({
1002+
text: `Failed to publish map`
1003+
})
1004+
}
9831005
}
9841006
}
9851007
})

web-app/packages/lib/src/modules/project/views/ProjectViewTemplate.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
1212
>
1313
<!-- Z indexes based on minus margin, its not possible to add additional buttons to tab view -->
1414
<div class="relative z-1">
15+
<slot name="publish.button" />
1516
<PButton
1617
severity="secondary"
1718
@click="downloadArchive({ url: downloadUrl })"

0 commit comments

Comments
 (0)