func (v *SaveView) Render() *vecty.HTML { return elem.ListItem( vecty.ClassMap{ "disabled": !v.App.Files.Changed(), }, elem.Anchor( event.Click(func(e *vecty.Event) { request := &shared.SaveRequest{ Request: shared.Request{ Path: v.App.Env.Path(), Hash: v.App.Env.Hash(), }, } for n, f := range v.App.Files.All() { if f.Changed() { b, err := ke.MarshalIndent(v.Ctx, n.Value, "", "\t") if err != nil { v.App.Fail <- kerr.Wrap("MKHONBVODK", err) } request.Files = append(request.Files, shared.SaveRequestFile{ File: f.Filename, Bytes: b, Hash: f.Hash, }) } } response := &shared.SaveResponse{} done := v.App.Conn.Go(shared.Save, request, response, v.App.Fail) go func() { if err := <-done; err != nil { v.App.Fail <- kerr.Wrap("PVLCRRYIUD", err) return } v.App.Dispatcher.Dispatch(&actions.SaveFileSuccess{Response: response}) }() }).PreventDefault(), prop.Href("#"), vecty.Text("Save"), ), ) }
func TestKego(t *testing.T) { ctx := ke.NewContext(context.Background(), "kego.io/system", nil) _, err := ke.Open(ctx, "") assert.IsError(t, err, "CXIULJCEBE") systemDir, err := packages.GetDirFromPackage(ctx, "kego.io/system") require.NoError(t, err) i, err := ke.Open(ctx, filepath.Join(systemDir, "type.json")) require.NoError(t, err) _, ok := i.(*system.Type) assert.True(t, ok) b, err := ioutil.ReadFile(filepath.Join(systemDir, "type.json")) require.NoError(t, err) var i1 interface{} err = ke.Unmarshal(ctx, b, &i1) require.NoError(t, err) _, ok = i1.(*system.Type) assert.True(t, ok) r := &system.Reference{} err = ke.Unmarshal(ctx, []byte(`"type"`), r) require.NoError(t, err) assert.Equal(t, *system.NewReference("kego.io/system", "type"), *r) b3, err := ke.Marshal(ctx, system.NewReference("kego.io/system", "type")) require.NoError(t, err) assert.Equal(t, "{\"type\":\"reference\",\"value\":\"type\"}", string(b3)) b4, err := ke.MarshalIndent(ctx, &system.Package{Recursive: true}, "", " ") require.NoError(t, err) assert.Equal(t, "{\n \"recursive\": true\n}", string(b4)) }