Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Diagram delete #3195

Merged
merged 5 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/branch_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
outputs:
continue: ${{ steps.branch-deploy.outputs.continue }}
ref: ${{ steps.branch-deploy.outputs.ref }}
noop: ${{ steps.branch-deploy.outputs.noop }}
steps:
- uses: github/branch-deploy@v7.3.0
id: branch-deploy
Expand All @@ -28,3 +29,4 @@ jobs:
secrets: inherit
with:
ref: ${{ needs.branch-deploy.outputs.ref }}
noop: ${{ needs.branch-deploy.outputs.noop }}
46 changes: 6 additions & 40 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
ref:
required: true
type: string
noop:
default: "false"
required: false
type: string

jobs:
build:
Expand Down Expand Up @@ -81,6 +85,7 @@ jobs:
name: dist
path: frontend/dist
- uses: FirebaseExtended/action-hosting-deploy@v0
if: ${{ inputs.noop != 'true' }}
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_TEXTUSM }}"
Expand All @@ -94,46 +99,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Deploy backend to render.com
if: ${{ inputs.noop != 'true' }}
run: curl --silent --show-error --fail $RENDER_DEPLOY_HOOK_URL > /dev/null
env:
RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}

create-git-tag:
runs-on: ubuntu-latest
needs: [deploy-frontend, deploy-backend]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: frontend
- name: tag is already existing to GITHUB_ENV
run: |
tag_is_existing=$(
git fetch origin v${{ steps.package-version.outputs.current-version }} &&
echo true ||
echo false
)
echo "TAG_IS_EXISTING=${tag_is_existing}" >> $GITHUB_ENV
- if: env.TAG_IS_EXISTING == 'false'
run: |
git tag v${{ steps.package-version.outputs.current-version }}
git push origin v${{ steps.package-version.outputs.current-version }}
- name: Build Changelog
if: env.TAG_IS_EXISTING == 'false'
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: env.TAG_IS_EXISTING == 'false'
uses: actions/create-release@v1
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
release_name: v${{ steps.package-version.outputs.current-version }}
body: ${{steps.github_release.outputs.changelog}}
allowUpdates: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/create_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
pull_request:
branches:
- master
types: [closed]

jobs:
create-tag:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: frontend
- name: tag is already existing to GITHUB_ENV
run: |
tag_is_existing=$(
git fetch origin v${{ steps.package-version.outputs.current-version }} &&
echo true ||
echo false
)
echo "TAG_IS_EXISTING=${tag_is_existing}" >> $GITHUB_ENV
- if: env.TAG_IS_EXISTING == 'false'
run: |
git tag v${{ steps.package-version.outputs.current-version }}
git push origin v${{ steps.package-version.outputs.current-version }}
- name: Build Changelog
if: env.TAG_IS_EXISTING == 'false'
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
if: env.TAG_IS_EXISTING == 'false'
uses: actions/create-release@v1
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
release_name: v${{ steps.package-version.outputs.current-version }}
body: ${{steps.github_release.outputs.changelog}}
allowUpdates: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion backend/.air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main cmd/main.go"
cmd = "go build -o ./tmp/main cmd/api-server/main.go"
delay = 0
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
Expand Down
9 changes: 6 additions & 3 deletions backend/internal/infra/firebase/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"bytes"
"compress/gzip"
"context"
"fmt"
"errors"
"io"
"strings"

"cloud.google.com/go/storage"
firebaseStorage "firebase.google.com/go/v4/storage"
"github.com/samber/mo"
)
Expand Down Expand Up @@ -102,9 +103,11 @@ func (s *CloudStorage) Delete(ctx context.Context, prefix, uid, itemID string) m
return mo.Err[bool](err)
}

fmt.Println(getObjectName(prefix, uid, itemID))

if err = bucket.Object(getObjectName(prefix, uid, itemID)).Delete(ctx); err != nil {
if ok := errors.Is(err, storage.ErrObjectNotExist); ok {
return mo.Ok(true)
}

return mo.Err[bool](err)
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/elm/Api/Request.elm
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ bookmark idToken itemID isBookmark =
|> Task.mapError toError


delete : Maybe IdToken -> DiagramId -> Bool -> Task RequestError String
delete : Maybe IdToken -> DiagramId -> Bool -> Task RequestError DiagramId
delete idToken itemID isPublic =
Mutation.delete (DiagramId.toString itemID) isPublic
|> Http.mutationRequest graphQLUrl
|> authHeaders idToken
|> Http.toTask
|> Task.map (\(Graphql.Scalar.Id id) -> id)
|> Task.map (\(Graphql.Scalar.Id id) -> DiagramId.fromString id)
|> Task.mapError toError


deleteGist : Maybe IdToken -> AccessToken -> DiagramId -> Task RequestError String
deleteGist : Maybe IdToken -> AccessToken -> DiagramId -> Task RequestError DiagramId
deleteGist idToken accessToken gistId =
GithubRequest.deleteGist accessToken gistId
|> Task.mapError RequestError.fromHttpError
Expand All @@ -91,7 +91,7 @@ deleteGist idToken accessToken gistId =
|> Http.mutationRequest graphQLUrl
|> authHeaders idToken
|> Http.toTask
|> Task.map (\(Graphql.Scalar.Id id) -> id)
|> Task.map (\(Graphql.Scalar.Id id) -> DiagramId.fromString id)
|> Task.mapError toError
)

Expand Down
10 changes: 10 additions & 0 deletions frontend/src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ subscriptions model =
, Ports.loadSettingsFromLocalCompleted M.LoadSettingsFromLocal
, Ports.startDownload M.StartDownload
, Ports.gotLocalDiagramsJson (\json -> M.UpdateDiagramList (DiagramList.GotLocalDiagramsJson json))
, Ports.removedLocalDiagram (\idString -> (Ok <| DiagramId.fromString idString) |> DiagramList.Removed |> M.UpdateDiagramList)
, Ports.reload (\_ -> M.UpdateDiagramList DiagramList.Reload)
, onVisibilityChange M.HandleVisibilityChange
, onResize (\width height -> M.UpdateDiagram (DiagramModel.Resize width height))
Expand Down Expand Up @@ -1391,6 +1392,15 @@ processDiagramListMsg msg =
DiagramList.GotExportDiagrams (Err e) ->
showErrorMessage <| RequestError.toMessage e

DiagramList.Removed (Ok diagramId) ->
Return.map <|
\m ->
if (m.currentDiagram.id |> Maybe.withDefault (DiagramId.fromString "")) == diagramId then
{ m | currentDiagram = DiagramItem.new DiagramType.UserStoryMap }

else
m

DiagramList.Removed (Err _) ->
showErrorMessage Message.messagEerrorOccurred

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/elm/Page/List.elm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import Json.Encode as E
import List.Extra as ListEx
import Message exposing (Lang)
import Models.Color as Color
import Models.Diagram.Id as DiagramId
import Models.Diagram.Id as DiagramId exposing (DiagramId)
import Models.Diagram.Item as DiagramItem exposing (DiagramItem)
import Models.Diagram.Location as DiagramLocation
import Models.Dialog as Dialog
Expand Down Expand Up @@ -128,7 +128,7 @@ type Msg
| Reload
| Remove DiagramItem
| RemoveRemote D.Value
| Removed (Result RequestError String)
| Removed (Result RequestError DiagramId)
| Bookmarked (Result RequestError ())
| GotTimeZone Zone
| GetDiagrams
Expand Down Expand Up @@ -213,7 +213,7 @@ load : { session : Session, isOnline : Bool } -> Return.ReturnF Msg Model
load { session, isOnline } =
Return.andThen <|
\m ->
Return.singleton { m | session = session, isOnline = isOnline }
Return.singleton { m | session = session, isOnline = isOnline, diagramList = DiagramList.notAsked }
|> Return.command (getDiagrams ())


Expand Down
5 changes: 4 additions & 1 deletion frontend/src/elm/Ports.elm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ port module Ports exposing
, closeLocalFile
, copyText
, downloadCompleted
, reload
, focusEditor
, fullscreen
, getDiagram
Expand All @@ -27,7 +28,7 @@ port module Ports exposing
, openedLocalFile
, progress
, refreshToken
, reload
, removedLocalDiagram
, removeRemoteDiagram
, saveDiagram
, saveLocalFile
Expand Down Expand Up @@ -128,6 +129,8 @@ port progress : (Bool -> msg) -> Sub msg
port refreshToken : () -> Cmd msg


port removedLocalDiagram : (String -> msg) -> Sub msg

port reload : (String -> msg) -> Sub msg


Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const initDB = (app: ElmApp): void => {
app.ports.removeRemoteDiagram.send(diagram);
} else {
await db.diagrams.delete(id);
app.ports.reload.send('');
app.ports.removedLocalDiagram.send(id);
}
});

Expand Down
1 change: 1 addition & 0 deletions frontend/src/ts/elm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type ElmApp = {
saveToLocalCompleted: Send<DiagramItem>;
removeRemoteDiagram: Send<Diagram>;
reload: Send<string>;
removedLocalDiagram: Send<string>;
gotLocalDiagramJson: Send<DiagramItem>;
gotLocalDiagramJsonForCopy: Send<DiagramItem>;
gotLocalDiagramsJson: Send<DiagramItem[]>;
Expand Down
Loading