From 3679e04d44d23354bee00a0b5b663674d891f696 Mon Sep 17 00:00:00 2001 From: Harshil Sharma Date: Mon, 28 Mar 2022 13:41:31 +0530 Subject: [PATCH] Removed the extra getDefaultTemplate API as its not needed --- server/api/api.go | 57 ----------------------------- webapp/src/octoClient.ts | 9 ----- webapp/src/store/globalTemplates.ts | 2 +- 3 files changed, 1 insertion(+), 67 deletions(-) diff --git a/server/api/api.go b/server/api/api.go index 86c14c60d..2707b8b9d 100644 --- a/server/api/api.go +++ b/server/api/api.go @@ -76,7 +76,6 @@ func (a *API) RegisterRoutes(r *mux.Router) { apiv1.HandleFunc("/teams/{teamID}/boards", a.sessionRequired(a.handleGetBoards)).Methods("GET") apiv1.HandleFunc("/teams/{teamID}/boards/search", a.sessionRequired(a.handleSearchBoards)).Methods("GET") apiv1.HandleFunc("/teams/{teamID}/templates", a.sessionRequired(a.handleGetTemplates)).Methods("GET") - apiv1.HandleFunc("/templates", a.sessionRequired(a.handleGetDefaultTemplates)).Methods("GET") apiv1.HandleFunc("/boards", a.sessionRequired(a.handleCreateBoard)).Methods("POST") apiv1.HandleFunc("/boards/{boardID}", a.attachSession(a.handleGetBoard, false)).Methods("GET") apiv1.HandleFunc("/boards/{boardID}", a.sessionRequired(a.handlePatchBoard)).Methods("PATCH") @@ -2211,62 +2210,6 @@ func (a *API) handleGetTemplates(w http.ResponseWriter, r *http.Request) { auditRec.Success() } -func (a *API) handleGetDefaultTemplates(w http.ResponseWriter, r *http.Request) { - // swagger:operation GET /api/v1/templates getDefaultTemplates - // - // Returns default templates - // - // --- - // produces: - // - application/json - // parameters: - // - name: teamID - // in: path - // description: Team ID - // required: true - // type: string - // security: - // - BearerAuth: [] - // responses: - // '200': - // description: success - // schema: - // type: array - // items: - // items: - // "$ref": "#/definitions/Board" - // default: - // description: internal error - // schema: - // "$ref": "#/definitions/ErrorResponse" - - auditRec := a.makeAuditRecord(r, "getDefaultTemplates", audit.Fail) - defer a.audit.LogRecord(audit.LevelRead, auditRec) - - // retrieve boards list - boards, err := a.app.GetDefaultTemplates() - if err != nil { - a.errorResponse(w, r.URL.Path, http.StatusInternalServerError, "", err) - return - } - - a.logger.Debug("GetDefaultTemplates", - mlog.Int("boardsCount", len(boards)), - ) - - data, err := json.Marshal(boards) - if err != nil { - a.errorResponse(w, r.URL.Path, http.StatusInternalServerError, "", err) - return - } - - // response - jsonBytesResponse(w, http.StatusOK, data) - - auditRec.AddMeta("templatesCount", len(boards)) - auditRec.Success() -} - // subscriptions func (a *API) handleCreateSubscription(w http.ResponseWriter, r *http.Request) { diff --git a/webapp/src/octoClient.ts b/webapp/src/octoClient.ts index 5bdaa27e5..f9e47191c 100644 --- a/webapp/src/octoClient.ts +++ b/webapp/src/octoClient.ts @@ -600,15 +600,6 @@ class OctoClient { return this.getBoardsWithPath(path) } - async getDefaultTemplates(): Promise { - const path = '/api/v1/templates' - const response = await fetch(this.getBaseURL() + path, {headers: this.headers()}) - if (response.status !== 200) { - return [] - } - return (await this.getJson(response, [])) as Board[] - } - // Boards // ToDo: . // - goal? make the interface show boards & blocks for boards diff --git a/webapp/src/store/globalTemplates.ts b/webapp/src/store/globalTemplates.ts index 3dc5ead82..b7b0ae2ec 100644 --- a/webapp/src/store/globalTemplates.ts +++ b/webapp/src/store/globalTemplates.ts @@ -13,7 +13,7 @@ import {RootState} from './index' export const fetchGlobalTemplates = createAsyncThunk( 'globalTemplates/fetch', async () => { - const templates = await client.getDefaultTemplates() + const templates = await client.getTeamTemplates('0') return templates.sort((a, b) => a.title.localeCompare(b.title)) }, )