Use the correct endpoint for exporting all boards on a team
This commit is contained in:
parent
ec39401dc0
commit
9c03838840
7 changed files with 33 additions and 25 deletions
|
@ -184,19 +184,8 @@ func (a *App) writeArchiveFile(zw *zip.Writer, filename string, boardID string,
|
|||
return err
|
||||
}
|
||||
|
||||
// getBoardsForArchive fetches all the specified boards, or all boards in the workspace/team
|
||||
// if `boardIDs` is empty.
|
||||
// getBoardsForArchive fetches all the specified boards.
|
||||
func (a *App) getBoardsForArchive(boardIDs []string) ([]model.Board, error) {
|
||||
if len(boardIDs) == 0 {
|
||||
// TODO: implement this
|
||||
// boards, err := a.GetAllBoards("", "board")
|
||||
// if err != nil {
|
||||
// return nil, fmt.Errorf("could not fetch all boards: %w", err)
|
||||
// }
|
||||
// return boards, nil
|
||||
return []model.Board{}, nil
|
||||
}
|
||||
|
||||
boards := make([]model.Board, 0, len(boardIDs))
|
||||
|
||||
for _, id := range boardIDs {
|
||||
|
|
|
@ -11,11 +11,11 @@ declare let window: IAppWindow
|
|||
|
||||
class Archiver {
|
||||
static async exportBoardArchive(board: Board): Promise<void> {
|
||||
this.exportArchive(mutator.exportArchive(board.id))
|
||||
this.exportArchive(mutator.exportBoardArchive(board.id))
|
||||
}
|
||||
|
||||
static async exportFullArchive(): Promise<void> {
|
||||
this.exportArchive(mutator.exportArchive())
|
||||
static async exportFullArchive(teamID: string): Promise<void> {
|
||||
this.exportArchive(mutator.exportFullArchive(teamID))
|
||||
}
|
||||
|
||||
private static exportArchive(prom: Promise<Response>): void {
|
||||
|
|
|
@ -76,8 +76,10 @@ const GlobalHeaderSettingsMenu = (props: Props) => {
|
|||
id='export'
|
||||
name={intl.formatMessage({id: 'Sidebar.export-archive', defaultMessage: 'Export archive'})}
|
||||
onClick={async () => {
|
||||
if (currentTeam) {
|
||||
TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.ExportArchive)
|
||||
Archiver.exportFullArchive()
|
||||
Archiver.exportFullArchive(currentTeam.id)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Menu.SubMenu
|
||||
|
|
|
@ -16,8 +16,9 @@ import {
|
|||
} from '../../theme'
|
||||
import Menu from '../../widgets/menu'
|
||||
import MenuWrapper from '../../widgets/menuWrapper'
|
||||
import {useAppDispatch} from '../../store/hooks'
|
||||
import {useAppDispatch, useAppSelector} from '../../store/hooks'
|
||||
import {storeLanguage} from '../../store/language'
|
||||
import {getCurrentTeam, Team} from '../../store/teams'
|
||||
import {UserSettings} from '../../userSettings'
|
||||
|
||||
import './sidebarSettingsMenu.scss'
|
||||
|
@ -33,6 +34,7 @@ type Props = {
|
|||
const SidebarSettingsMenu = (props: Props) => {
|
||||
const intl = useIntl()
|
||||
const dispatch = useAppDispatch()
|
||||
const currentTeam = useAppSelector<Team|null>(getCurrentTeam)
|
||||
|
||||
// we need this as the sidebar doesn't always need to re-render
|
||||
// on theme change. This can cause props and the actual
|
||||
|
@ -114,8 +116,10 @@ const SidebarSettingsMenu = (props: Props) => {
|
|||
id='export'
|
||||
name={intl.formatMessage({id: 'Sidebar.export-archive', defaultMessage: 'Export archive'})}
|
||||
onClick={async () => {
|
||||
if (currentTeam) {
|
||||
TelemetryClient.trackEvent(TelemetryCategory, TelemetryActions.ExportArchive)
|
||||
Archiver.exportFullArchive()
|
||||
Archiver.exportFullArchive(currentTeam.id)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Menu.SubMenu
|
||||
|
|
|
@ -1114,8 +1114,13 @@ class Mutator {
|
|||
// Other methods
|
||||
|
||||
// Not a mutator, but convenient to put here since Mutator wraps OctoClient
|
||||
async exportArchive(boardID?: string): Promise<Response> {
|
||||
return octoClient.exportArchive(boardID)
|
||||
async exportBoardArchive(boardID: string): Promise<Response> {
|
||||
return octoClient.exportBoardArchive(boardID)
|
||||
}
|
||||
|
||||
// Not a mutator, but convenient to put here since Mutator wraps OctoClient
|
||||
async exportFullArchive(teamID: string): Promise<Response> {
|
||||
return octoClient.exportFullArchive(teamID)
|
||||
}
|
||||
|
||||
// Not a mutator, but convenient to put here since Mutator wraps OctoClient
|
||||
|
|
|
@ -24,7 +24,11 @@ test('OctoClient: get blocks', async () => {
|
|||
expect(boards.length).toBe(blocks.length)
|
||||
|
||||
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
||||
const response = await octoClient.exportArchive()
|
||||
let response = await octoClient.exportBoardArchive('board')
|
||||
expect(response.status).toBe(200)
|
||||
|
||||
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
||||
response = await octoClient.exportFullArchive('team')
|
||||
expect(response.status).toBe(200)
|
||||
|
||||
FetchMock.fn.mockReturnValueOnce(FetchMock.jsonResponse(JSON.stringify(blocks)))
|
||||
|
|
|
@ -201,12 +201,16 @@ class OctoClient {
|
|||
return (await this.getJson(response, {})) as Record<string, string>
|
||||
}
|
||||
|
||||
// If no boardID is provided, it will export the entire archive
|
||||
async exportArchive(boardID = ''): Promise<Response> {
|
||||
async exportBoardArchive(boardID: string): Promise<Response> {
|
||||
const path = `/api/v1/boards/${boardID}/archive/export`
|
||||
return fetch(this.getBaseURL() + path, {headers: this.headers()})
|
||||
}
|
||||
|
||||
async exportFullArchive(teamID: string): Promise<Response> {
|
||||
const path = `/api/v1/teams/${teamID}/archive/export`
|
||||
return fetch(this.getBaseURL() + path, {headers: this.headers()})
|
||||
}
|
||||
|
||||
async importFullArchive(file: File): Promise<Response> {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
|
Loading…
Reference in a new issue