author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
259,868 | 02.02.2023 14:22:45 | 28,800 | 4dee08f3d28ec30209f10c4c448e957d43f96366 | Remove `net` from list of banned gVisor packages.
`net` no longer requires `cgo`:
The `runsc` `go_binary` specifies `pure = True`, which would prevent it
from compiling if it required cgo. | [
{
"change_type": "MODIFY",
"old_path": "CONTRIBUTING.md",
"new_path": "CONTRIBUTING.md",
"diff": "@@ -66,8 +66,6 @@ Rules:\n* Itself.\n* Go standard library.\n- * Except (transitively) package \"net\", which would result in a cgo\n- binary. Use `//pkg/unet` instead.\n* `@org_golang_x_sys//unix:go_default_library` (Go import\n`golang.org/x/sys/unix`).\n* `@org_golang_x_time//rate:go_default_library` (Go import\n@@ -86,6 +84,8 @@ Rules:\n* `@com_github_opencontainers_runtime_spec//specs_go:go_default_library`\n(Go import `github.com/opencontainers/runtime-spec/specs_go`).\n+* For performance reasons, `runsc boot` may not run the `netpoller` goroutine.\n+\n### Code reviews\nBefore sending code reviews, run `bazel test ...` to ensure tests are passing.\n"
}
] | Go | Apache License 2.0 | google/gvisor | Remove `net` from list of banned gVisor packages.
`net` no longer requires `cgo`: https://pkg.go.dev/net#hdr-Name_Resolution
The `runsc` `go_binary` specifies `pure = True`, which would prevent it
from compiling if it required cgo.
PiperOrigin-RevId: 506722374 |
259,891 | 03.02.2023 10:01:36 | 28,800 | 533d4435ff215cc06324ea0c229cf52df85fd1e8 | tests: bump timeout to address flakiness
This test flakes on Linux in BuildKite -- see whether it's a timeout problem. | [
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/socket_inet_loopback.cc",
"new_path": "test/syscalls/linux/socket_inet_loopback.cc",
"diff": "@@ -736,7 +736,7 @@ TEST_P(SocketInetLoopbackTest, TCPNonBlockingConnectClose) {\n.events = POLLIN | POLLRDHUP,\n};\n// Use a large timeout to accomodate for retransmitted FINs.\n- constexpr int kTimeout = 30000;\n+ constexpr int kTimeout = 120000;\nint n = poll(&pfd, 1, kTimeout);\nASSERT_GE(n, 0) << strerror(errno);\nASSERT_EQ(n, 1);\n"
}
] | Go | Apache License 2.0 | google/gvisor | tests: bump timeout to address flakiness
This test flakes on Linux in BuildKite -- see whether it's a timeout problem.
PiperOrigin-RevId: 506929923 |
259,975 | 03.02.2023 10:33:42 | 28,800 | 13c7e55e598130398789033402c44013a2a17e45 | Ensure only Upload/Download iperf tests run on buildkite.
The addition of the "Parameterized" version of iperf requires a filter
so that only the original tests run. Otherwise, we get test timeouts. | [
{
"change_type": "MODIFY",
"old_path": ".buildkite/pipeline.yaml",
"new_path": ".buildkite/pipeline.yaml",
"diff": "@@ -485,7 +485,7 @@ steps:\ncommand: make -i benchmark-platforms BENCHMARKS_FILTER=\"Continuous\" BENCHMARKS_SUITE=httpd BENCHMARKS_TARGETS=test/benchmarks/network:httpd_test\n- <<: *benchmarks\nlabel: \":piedpiper: iperf benchmarks\"\n- command: make -i benchmark-platforms BENCHMARKS_SUITE=iperf BENCHMARKS_TARGETS=test/benchmarks/network:iperf_test\n+ command: make -i benchmark-platforms BENCHMARKS_SUITE=iperf BENCHMARKS_TARGETS=test/benchmarks/network:iperf_test BENCHMARKS_FILTER=BenchmarkIperf$\n- <<: *benchmarks\nlabel: \":nginx: nginx benchmarks\"\ncommand: make -i benchmark-platforms BENCHMARKS_FILTER=\"Continuous\" BENCHMARKS_SUITE=nginx BENCHMARKS_TARGETS=test/benchmarks/network:nginx_test\n"
},
{
"change_type": "MODIFY",
"old_path": "test/benchmarks/network/iperf_test.go",
"new_path": "test/benchmarks/network/iperf_test.go",
"diff": "@@ -72,7 +72,7 @@ func BenchmarkIperf(b *testing.B) {\nclient := bm.clientFunc(ctx, b)\ndefer client.CleanUp(ctx)\n- // iperf serves on port 5001 by default.\n+ // iperf server listens on port 5001 by default.\nport := 5001\n// Start the server.\n@@ -234,7 +234,7 @@ func BenchmarkIperfParameterized(b *testing.B) {\nclient := bm.clientFunc(ctx, b)\ndefer client.CleanUp(ctx)\n- // iperf serves on port 5001 by default.\n+ // iperf server listens on port 5001 by default.\nport := 5001\n// Start the server.\n"
}
] | Go | Apache License 2.0 | google/gvisor | Ensure only Upload/Download iperf tests run on buildkite.
The addition of the "Parameterized" version of iperf requires a filter
so that only the original tests run. Otherwise, we get test timeouts.
PiperOrigin-RevId: 506938451 |
259,891 | 03.02.2023 11:10:48 | 28,800 | af99fcb280aad1ce9452a20b420890176bc65725 | eventfd: more detailed error message | [
{
"change_type": "MODIFY",
"old_path": "pkg/eventfd/eventfd.go",
"new_path": "pkg/eventfd/eventfd.go",
"diff": "@@ -78,8 +78,8 @@ func (ev Eventfd) Write(val uint64) error {\nif err == unix.EINTR {\ncontinue\n}\n- if n != sizeofUint64 {\n- panic(fmt.Sprintf(\"short write to eventfd: got %d bytes, wanted %d\", n, sizeofUint64))\n+ if err != nil || n != sizeofUint64 {\n+ panic(fmt.Sprintf(\"bad write to eventfd: got %d bytes, wanted %d with error %v\", n, sizeofUint64, err))\n}\nreturn err\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | eventfd: more detailed error message
PiperOrigin-RevId: 506948082 |
259,909 | 03.02.2023 14:57:23 | 28,800 | fc52a6d9ccfa4c523b4ddda05c864e43bc695581 | Give FUSE hard link capabilities and enable the link syscall test. | [
{
"change_type": "MODIFY",
"old_path": "pkg/abi/linux/fuse.go",
"new_path": "pkg/abi/linux/fuse.go",
"diff": "@@ -755,6 +755,32 @@ func (r *FUSESymlinkIn) SizeBytes() int {\nreturn r.Name.SizeBytes() + r.Target.SizeBytes()\n}\n+// FUSELinkIn is the request sent by the kernel to create a hard link.\n+//\n+// +marshal dynamic\n+type FUSELinkIn struct {\n+ // OldNodeID is the ID of the inode that is being linked to.\n+ OldNodeID primitive.Uint64\n+ // Name of the new hard link to create.\n+ Name CString\n+}\n+\n+// MarshalBytes implements marshal.Marshallable.MarshalBytes.\n+func (r *FUSELinkIn) MarshalBytes(buf []byte) []byte {\n+ buf = r.OldNodeID.MarshalBytes(buf)\n+ return r.Name.MarshalBytes(buf)\n+}\n+\n+// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.\n+func (r *FUSELinkIn) UnmarshalBytes(buf []byte) []byte {\n+ panic(\"Unimplemented, FUSELinkIn is never unmarshalled\")\n+}\n+\n+// SizeBytes implements marshal.Marshallable.SizeBytes.\n+func (r *FUSELinkIn) SizeBytes() int {\n+ return r.OldNodeID.SizeBytes() + r.Name.SizeBytes()\n+}\n+\n// FUSEEmptyIn is used by operations without request body.\n//\n// +marshal dynamic\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/fusefs.go",
"new_path": "pkg/sentry/fsimpl/fuse/fusefs.go",
"diff": "@@ -291,7 +291,7 @@ func (fs *filesystem) MountOptions() string {\nfunc (fs *filesystem) newRoot(ctx context.Context, creds *auth.Credentials, mode linux.FileMode) *kernfs.Dentry {\ni := &inode{fs: fs, nodeID: 1}\ni.attrMu.Lock()\n- i.init(creds, linux.UNNAMED_MAJOR, fs.devMinor, 1, linux.ModeDirectory|0755)\n+ i.init(creds, linux.UNNAMED_MAJOR, fs.devMinor, 1, linux.ModeDirectory|0755, 2)\ni.attrMu.Unlock()\ni.OrderedChildren.Init(kernfs.OrderedChildrenOptions{})\ni.InitRefs()\n@@ -305,7 +305,7 @@ func (fs *filesystem) newInode(ctx context.Context, nodeID uint64, attr linux.FU\ni := &inode{fs: fs, nodeID: nodeID}\ncreds := auth.Credentials{EffectiveKGID: auth.KGID(attr.UID), EffectiveKUID: auth.KUID(attr.UID)}\ni.attrMu.Lock()\n- i.init(&creds, linux.UNNAMED_MAJOR, fs.devMinor, fs.NextIno(), linux.FileMode(attr.Mode))\n+ i.init(&creds, linux.UNNAMED_MAJOR, fs.devMinor, nodeID, linux.FileMode(attr.Mode), attr.Nlink)\ni.size.Store(attr.Size)\ni.attrMu.Unlock()\ni.OrderedChildren.Init(kernfs.OrderedChildrenOptions{})\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/inode.go",
"new_path": "pkg/sentry/fsimpl/fuse/inode.go",
"diff": "@@ -45,7 +45,6 @@ type fileHandle struct {\ntype inode struct {\ninodeRefs\nkernfs.InodeAlwaysValid\n- kernfs.InodeDirectoryNoNewChildren\nkernfs.InodeNotSymlink\nkernfs.InodeWatches\nkernfs.OrderedChildren\n@@ -110,6 +109,18 @@ func (i *inode) Mode() linux.FileMode {\nreturn i.filemode()\n}\n+func (i *inode) UID() auth.KUID {\n+ i.attrMu.Lock()\n+ defer i.attrMu.Unlock()\n+ return auth.KUID(i.uid.Load())\n+}\n+\n+func (i *inode) GID() auth.KGID {\n+ i.attrMu.Lock()\n+ defer i.attrMu.Unlock()\n+ return auth.KGID(i.gid.Load())\n+}\n+\n// +checklocks:i.attrMu\nfunc (i *inode) filemode() linux.FileMode {\nreturn linux.FileMode(i.mode.Load())\n@@ -132,15 +143,11 @@ func (i *inode) touchAtime() {\n}\n// +checklocks:i.attrMu\n-func (i *inode) init(creds *auth.Credentials, devMajor, devMinor uint32, nodeid uint64, mode linux.FileMode) {\n+func (i *inode) init(creds *auth.Credentials, devMajor, devMinor uint32, nodeid uint64, mode linux.FileMode, nlink uint32) {\nif mode.FileType() == 0 {\npanic(fmt.Sprintf(\"No file type specified in 'mode' for InodeAttrs.Init(): mode=0%o\", mode))\n}\n- nlink := uint32(1)\n- if mode.FileType() == linux.ModeDirectory {\n- nlink = 2\n- }\ni.nodeID = nodeid\ni.ino.Store(nodeid)\ni.mode.Store(uint32(mode))\n@@ -399,6 +406,16 @@ func (i *inode) NewSymlink(ctx context.Context, name, target string) (kernfs.Ino\nreturn i.newEntry(ctx, name, linux.S_IFLNK, linux.FUSE_SYMLINK, &in)\n}\n+// NewLink implements kernfs.Inode.NewLink.\n+func (i *inode) NewLink(ctx context.Context, name string, target kernfs.Inode) (kernfs.Inode, error) {\n+ targetInode := target.(*inode)\n+ in := linux.FUSELinkIn{\n+ OldNodeID: primitive.Uint64(targetInode.nodeID),\n+ Name: linux.CString(name),\n+ }\n+ return i.newEntry(ctx, name, targetInode.Mode().FileType(), linux.FUSE_LINK, &in)\n+}\n+\n// Unlink implements kernfs.Inode.Unlink.\nfunc (i *inode) Unlink(ctx context.Context, name string, child kernfs.Inode) error {\nkernelTask := kernel.TaskFromContext(ctx)\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/request_response.go",
"new_path": "pkg/sentry/fsimpl/fuse/request_response.go",
"diff": "@@ -108,9 +108,8 @@ func (conn *connection) NewRequest(creds *auth.Credentials, pid uint32, ino uint\ndefer conn.fd.mu.Unlock()\nconn.fd.nextOpID += linux.FUSEOpID(reqIDStep)\n- hdrLen := (*linux.FUSEHeaderIn)(nil).SizeBytes()\nhdr := linux.FUSEHeaderIn{\n- Len: uint32(hdrLen + payload.SizeBytes()),\n+ Len: linux.SizeOfFUSEHeaderIn + uint32(payload.SizeBytes()),\nOpcode: opcode,\nUnique: conn.fd.nextOpID,\nNodeID: ino,\n@@ -121,8 +120,8 @@ func (conn *connection) NewRequest(creds *auth.Credentials, pid uint32, ino uint\nbuf := make([]byte, hdr.Len)\n- hdr.MarshalUnsafe(buf[:hdrLen])\n- payload.MarshalUnsafe(buf[hdrLen:])\n+ hdr.MarshalUnsafe(buf[:linux.SizeOfFUSEHeaderIn])\n+ payload.MarshalUnsafe(buf[linux.SizeOfFUSEHeaderIn:])\nreturn &Request{\nid: hdr.Unique,\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/host/host.go",
"new_path": "pkg/sentry/fsimpl/host/host.go",
"diff": "@@ -346,6 +346,16 @@ func (i *inode) Mode() linux.FileMode {\nreturn linux.FileMode(s.Mode)\n}\n+// Mode implements kernfs.Inode.UID\n+func (i *inode) UID() auth.KUID {\n+ return auth.KUID(i.virtualOwner.uid.Load())\n+}\n+\n+// Mode implements kernfs.Inode.GID\n+func (i *inode) GID() auth.KGID {\n+ return auth.KGID(i.virtualOwner.gid.Load())\n+}\n+\n// Stat implements kernfs.Inode.Stat.\nfunc (i *inode) Stat(ctx context.Context, vfsfs *vfs.Filesystem, opts vfs.StatOptions) (linux.Statx, error) {\nif opts.Mask&linux.STATX__RESERVED != 0 {\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"new_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"diff": "@@ -364,6 +364,13 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nparent.dirMu.Lock()\ndefer parent.dirMu.Unlock()\n+ inode := vd.Dentry().Impl().(*Dentry).Inode()\n+ if inode.Mode().IsDir() {\n+ return linuxerr.EPERM\n+ }\n+ if err := vfs.MayLink(rp.Credentials(), inode.Mode(), inode.UID(), inode.GID()); err != nil {\n+ return err\n+ }\npc := rp.Component()\nif err := checkCreateLocked(ctx, rp.Credentials(), pc, parent); err != nil {\nreturn err\n@@ -379,17 +386,12 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\n}\ndefer rp.Mount().EndWrite()\n- d := vd.Dentry().Impl().(*Dentry)\n- if d.isDir() {\n- return linuxerr.EPERM\n- }\n-\n- childI, err := parent.inode.NewLink(ctx, pc, d.inode)\n+ childI, err := parent.inode.NewLink(ctx, pc, inode)\nif err != nil {\nreturn err\n}\nparent.inode.Watches().Notify(ctx, pc, linux.IN_CREATE, 0, vfs.InodeEvent, false /* unlinked */)\n- d.inode.Watches().Notify(ctx, \"\", linux.IN_ATTRIB, 0, vfs.InodeEvent, false /* unlinked */)\n+ inode.Watches().Notify(ctx, \"\", linux.IN_ATTRIB, 0, vfs.InodeEvent, false /* unlinked */)\nvar child Dentry\nchild.Init(fs, childI)\nparent.insertChildLocked(pc, &child)\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/inode_impl_util.go",
"new_path": "pkg/sentry/fsimpl/kernfs/inode_impl_util.go",
"diff": "@@ -228,6 +228,16 @@ func (a *InodeAttrs) Ino() uint64 {\nreturn a.ino.Load()\n}\n+// UID implements Inode.UID.\n+func (a *InodeAttrs) UID() auth.KUID {\n+ return auth.KUID(a.uid.Load())\n+}\n+\n+// GID implements Inode.GID.\n+func (a *InodeAttrs) GID() auth.KGID {\n+ return auth.KGID(a.gid.Load())\n+}\n+\n// Mode implements Inode.Mode.\nfunc (a *InodeAttrs) Mode() linux.FileMode {\nreturn linux.FileMode(a.mode.Load())\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/kernfs.go",
"new_path": "pkg/sentry/fsimpl/kernfs/kernfs.go",
"diff": "@@ -722,6 +722,14 @@ type inodeMetadata interface {\n// separated from Stat for performance.\nMode() linux.FileMode\n+ // UID returns the (struct stat)::st_uid value for this inode. This is\n+ // separated from Stat for performance.\n+ UID() auth.KUID\n+\n+ // GID returns the (struct stat)::st_gid value for this inode. This is\n+ // separated from Stat for performance.\n+ GID() auth.KGID\n+\n// Stat returns the metadata for this inode. This corresponds to\n// vfs.FilesystemImpl.StatAt.\nStat(ctx context.Context, fs *vfs.Filesystem, opts vfs.StatOptions) (linux.Statx, error)\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/pipefs/pipefs.go",
"new_path": "pkg/sentry/fsimpl/pipefs/pipefs.go",
"diff": "@@ -127,6 +127,16 @@ func (i *inode) Mode() linux.FileMode {\nreturn pipeMode\n}\n+// UID implements kernfs.Inode.UID.\n+func (i *inode) UID() auth.KUID {\n+ return auth.KUID(i.uid)\n+}\n+\n+// GID implements kernfs.Inode.GID.\n+func (i *inode) GID() auth.KGID {\n+ return auth.KGID(i.gid)\n+}\n+\n// Stat implements kernfs.Inode.Stat.\nfunc (i *inode) Stat(_ context.Context, vfsfs *vfs.Filesystem, opts vfs.StatOptions) (linux.Statx, error) {\nts := linux.NsecToStatxTimestamp(i.ctime.Nanoseconds())\n"
},
{
"change_type": "MODIFY",
"old_path": "test/runner/fuse/fuse.go",
"new_path": "test/runner/fuse/fuse.go",
"diff": "@@ -34,7 +34,7 @@ func main() {\nlog.Warningf(\"could not create loopback root: %v\", err)\nos.Exit(1)\n}\n- opts := &fuse.MountOptions{DirectMount: true, Debug: true, Options: []string{\"default_permissions\"}}\n+ opts := &fuse.MountOptions{DirectMount: true, Debug: true, AllowOther: true, Options: []string{\"default_permissions\"}}\nrawFS := fs.NewNodeFS(loopbackRoot, &fs.Options{NullPermissions: true, Logger: golog.Default()})\nserver, err := fuse.NewServer(rawFS, \"/tmp\", opts)\nif err != nil {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/BUILD",
"new_path": "test/syscalls/BUILD",
"diff": "@@ -293,6 +293,7 @@ syscall_test(\n)\nsyscall_test(\n+ add_fusefs = True,\nadd_overlay = True,\ntest = \"//test/syscalls/linux:link_test\",\nuse_tmpfs = True, # gofer needs CAP_DAC_READ_SEARCH to use AT_EMPTY_PATH with linkat(2)\n"
}
] | Go | Apache License 2.0 | google/gvisor | Give FUSE hard link capabilities and enable the link syscall test.
PiperOrigin-RevId: 507001947 |
259,909 | 03.02.2023 15:48:09 | 28,800 | e9471a18ff19bef82761f57725322a89015bc9cd | Enable FUSE rename test.
This adds some permissions checks to kernfs RenameAt that were
missing. | [
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/inode.go",
"new_path": "pkg/sentry/fsimpl/fuse/inode.go",
"diff": "@@ -461,21 +461,20 @@ func (i *inode) RmDir(ctx context.Context, name string, child kernfs.Inode) erro\n// Rename implements kernfs.Inode.Rename.\nfunc (i *inode) Rename(ctx context.Context, oldname, newname string, child, dstDir kernfs.Inode) error {\n- fusefs := i.fs\n- task, creds := kernel.TaskFromContext(ctx), auth.CredentialsFromContext(ctx)\n-\n- dstDirInode, ok := dstDir.(*inode)\n- if !ok {\n- return linuxerr.EXDEV\n+ kernelTask := kernel.TaskFromContext(ctx)\n+ if kernelTask == nil {\n+ log.Warningf(\"fusefs.Inode.newEntry: couldn't get kernel task from context\", i.nodeID)\n+ return linuxerr.EINVAL\n}\n+ dstDirInode := dstDir.(*inode)\nin := linux.FUSERenameIn{\nNewdir: primitive.Uint64(dstDirInode.nodeID),\nOldname: linux.CString(oldname),\nNewname: linux.CString(newname),\n}\n- req := fusefs.conn.NewRequest(creds, uint32(task.ThreadID()), i.nodeID, linux.FUSE_RENAME, &in)\n- res, err := i.fs.conn.Call(task, req)\n+ req := i.fs.conn.NewRequest(auth.CredentialsFromContext(ctx), uint32(kernelTask.ThreadID()), i.nodeID, linux.FUSE_RENAME, &in)\n+ res, err := i.fs.conn.Call(kernelTask, req)\nif err != nil {\nreturn err\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"new_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"diff": "@@ -681,6 +681,13 @@ func (fs *Filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa\nreturn err\n}\ndefer mnt.EndWrite()\n+ oldParentDir := oldParentVD.Dentry().Impl().(*Dentry).Inode()\n+ if err := oldParentDir.CheckPermissions(ctx, rp.Credentials(), vfs.MayWrite|vfs.MayExec); err != nil {\n+ return err\n+ }\n+ if err := dstDir.inode.CheckPermissions(ctx, rp.Credentials(), vfs.MayWrite|vfs.MayExec); err != nil {\n+ return err\n+ }\nsrcDirVFSD := oldParentVD.Dentry()\nsrcDir := srcDirVFSD.Impl().(*Dentry)\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/BUILD",
"new_path": "test/syscalls/BUILD",
"diff": "@@ -566,6 +566,7 @@ syscall_test(\nsyscall_test(\nsize = \"medium\",\n+ add_fusefs = True,\nadd_overlay = True,\ntest = \"//test/syscalls/linux:rename_test\",\n)\n"
}
] | Go | Apache License 2.0 | google/gvisor | Enable FUSE rename test.
This adds some permissions checks to kernfs RenameAt that were
missing.
PiperOrigin-RevId: 507013151 |
259,907 | 05.02.2023 19:33:33 | 28,800 | 09459b203a532c24fbb76cc88484d533356b8b91 | Hide root overlay filestore from container using whiteout. | [
{
"change_type": "MODIFY",
"old_path": "g3doc/user_guide/filesystem.md",
"new_path": "g3doc/user_guide/filesystem.md",
"diff": "@@ -48,11 +48,11 @@ layer (tmpfs) be backed by a host file, so all file data is stored on disk.\nThe newer `--overlay2` flag allows you to achieve these. You can specify\n`--overlay2=root:self` in `runtimeArgs`. The overlay backing host file will be\n-created in the container's root filesystem. Placing the host file in the\n-container's root filesystem is important because k8s scans the container's root\n-filesystem from the host to enforce local ephemeral storage limits. You can also\n-place the overlay host file in another directory using\n-`--overlay2=root:/path/dir`.\n+created in the container's root filesystem. This file will be hidden from the\n+containerized application. Placing the host file in the container's root\n+filesystem is important because k8s scans the container's root filesystem from\n+the host to enforce local ephemeral storage limits. You can also place the\n+overlay host file in another directory using `--overlay2=root:/path/dir`.\n## Shared root filesystem\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/overlay/filesystem.go",
"new_path": "pkg/sentry/fsimpl/overlay/filesystem.go",
"diff": "@@ -562,16 +562,19 @@ func (fs *filesystem) doCreateAt(ctx context.Context, rp *vfs.ResolvingPath, ct\nreturn nil\n}\n+// CreateWhiteout creates a whiteout at pop. Whiteouts are created with\n+// character devices with device ID = 0.\n+//\n// Preconditions: pop's parent directory has been copied up.\n-func (fs *filesystem) createWhiteout(ctx context.Context, vfsObj *vfs.VirtualFilesystem, pop *vfs.PathOperation) error {\n- return vfsObj.MknodAt(ctx, fs.creds, pop, &vfs.MknodOptions{\n+func CreateWhiteout(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth.Credentials, pop *vfs.PathOperation) error {\n+ return vfsObj.MknodAt(ctx, creds, pop, &vfs.MknodOptions{\nMode: linux.S_IFCHR, // permissions == include/linux/fs.h:WHITEOUT_MODE == 0\n// DevMajor == DevMinor == 0, from include/linux/fs.h:WHITEOUT_DEV\n})\n}\nfunc (fs *filesystem) cleanupRecreateWhiteout(ctx context.Context, vfsObj *vfs.VirtualFilesystem, pop *vfs.PathOperation) {\n- if err := fs.createWhiteout(ctx, vfsObj, pop); err != nil {\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, pop); err != nil {\npanic(fmt.Sprintf(\"unrecoverable overlayfs inconsistency: failed to recreate whiteout after failed file creation: %v\", err))\n}\n}\n@@ -1237,7 +1240,7 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa\nif !whiteoutUpper {\ncontinue\n}\n- if err := fs.createWhiteout(ctx, vfsObj, &vfs.PathOperation{\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, &vfs.PathOperation{\nRoot: replaced.upperVD,\nStart: replaced.upperVD,\nPath: fspath.Parse(whiteoutName),\n@@ -1320,7 +1323,7 @@ func (fs *filesystem) RenameAt(ctx context.Context, rp *vfs.ResolvingPath, oldPa\nnewParent.children[newName] = renamed\noldParent.dirents = nil\n- if err := fs.createWhiteout(ctx, vfsObj, &oldpop); err != nil {\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, &oldpop); err != nil {\npanic(fmt.Sprintf(\"unrecoverable overlayfs inconsistency: failed to create whiteout at origin after RenameAt: %v\", err))\n}\nif renamed.isDir() {\n@@ -1410,7 +1413,7 @@ func (fs *filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error\nif !whiteoutUpper {\ncontinue\n}\n- if err := fs.createWhiteout(ctx, vfsObj, &vfs.PathOperation{\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, &vfs.PathOperation{\nRoot: child.upperVD,\nStart: child.upperVD,\nPath: fspath.Parse(whiteoutName),\n@@ -1441,7 +1444,7 @@ func (fs *filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error\nreturn err\n}\n}\n- if err := fs.createWhiteout(ctx, vfsObj, &pop); err != nil {\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, &pop); err != nil {\nvfsObj.AbortDeleteDentry(&child.vfsd)\nif child.upperVD.Ok() {\n// Don't attempt to recover from this: the original directory is\n@@ -1655,7 +1658,7 @@ func (fs *filesystem) UnlinkAt(ctx context.Context, rp *vfs.ResolvingPath) error\nreturn err\n}\n}\n- if err := fs.createWhiteout(ctx, vfsObj, &pop); err != nil {\n+ if err := CreateWhiteout(ctx, vfsObj, fs.creds, &pop); err != nil {\nvfsObj.AbortDeleteDentry(&child.vfsd)\nif childLayer == lookupLayerUpper {\npanic(fmt.Sprintf(\"unrecoverable overlayfs inconsistency: failed to create whiteout after unlinking upper layer file during UnlinkAt: %v\", err))\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/boot/controller.go",
"new_path": "runsc/boot/controller.go",
"diff": "@@ -438,7 +438,7 @@ func (cm *containerManager) Restore(o *RestoreOpts, _ *struct{}) error {\n// Set up the restore environment.\nctx := k.SupervisorContext()\n- mntr := newContainerMounter(&cm.l.root, cm.l.k, cm.l.mountHints, cm.l.productName)\n+ mntr := newContainerMounter(&cm.l.root, cm.l.k, cm.l.mountHints, cm.l.productName, o.SandboxID)\nctx, err = mntr.configureRestore(ctx)\nif err != nil {\nreturn fmt.Errorf(\"configuring filesystem restore: %v\", err)\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/boot/loader.go",
"new_path": "runsc/boot/loader.go",
"diff": "@@ -822,7 +822,7 @@ func (l *Loader) createContainerProcess(root bool, cid string, info *containerIn\n}\nl.startGoferMonitor(cid, int32(info.goferFDs[0].FD()))\n- mntr := newContainerMounter(info, l.k, l.mountHints, l.productName)\n+ mntr := newContainerMounter(info, l.k, l.mountHints, l.productName, cid)\nif root {\nif err := mntr.processHints(info.conf, info.procArgs.Credentials); err != nil {\nreturn nil, nil, err\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/boot/loader_test.go",
"new_path": "runsc/boot/loader_test.go",
"diff": "@@ -417,7 +417,7 @@ func TestCreateMountNamespace(t *testing.T) {\ndefer l.Destroy()\ndefer loaderCleanup()\n- mntr := newContainerMounter(&l.root, l.k, l.mountHints, \"\")\n+ mntr := newContainerMounter(&l.root, l.k, l.mountHints, \"\", l.sandboxID)\nif err := mntr.processHints(l.root.conf, l.root.procArgs.Credentials); err != nil {\nt.Fatalf(\"failed process hints: %v\", err)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/boot/vfs.go",
"new_path": "runsc/boot/vfs.go",
"diff": "@@ -58,6 +58,10 @@ const (\nNonefs = \"none\"\n)\n+// SelfOverlayFilestoreDirPrefix is the prefix in the directory name of the\n+// self overlay filestore directory.\n+const SelfOverlayFilestoreDirPrefix = \".gvisor.overlay.img.\"\n+\n// SelfOverlayFilestoreDir returns the directory path in which self overlay filestore\n// files are stored for a given mount.\nfunc SelfOverlayFilestoreDir(mountSrc, cid string) string {\n@@ -65,7 +69,11 @@ func SelfOverlayFilestoreDir(mountSrc, cid string) string {\n// the mount being overlayed itself. The same volume can be overlay-ed by\n// multiple containers. So make the filestore directory unique to container\n// by suffixing the container ID.\n- return path.Join(mountSrc, \".gvisor.overlay.img.\"+cid)\n+ return path.Join(mountSrc, selfOverlayFilestoreDirName(cid))\n+}\n+\n+func selfOverlayFilestoreDirName(cid string) string {\n+ return SelfOverlayFilestoreDirPrefix + cid\n}\n// tmpfs has some extra supported options that we must pass through.\n@@ -341,9 +349,12 @@ type containerMounter struct {\n// productName is the value to show in\n// /sys/devices/virtual/dmi/id/product_name.\nproductName string\n+\n+ // cid is the container ID for the container.\n+ cid string\n}\n-func newContainerMounter(info *containerInfo, k *kernel.Kernel, hints *podMountHints, productName string) *containerMounter {\n+func newContainerMounter(info *containerInfo, k *kernel.Kernel, hints *podMountHints, productName string, cid string) *containerMounter {\nreturn &containerMounter{\nroot: info.spec.Root,\nmounts: compileMounts(info.spec, info.conf),\n@@ -352,6 +363,7 @@ func newContainerMounter(info *containerInfo, k *kernel.Kernel, hints *podMountH\nk: k,\nhints: hints,\nproductName: productName,\n+ cid: cid,\n}\n}\n@@ -457,8 +469,7 @@ func (c *containerMounter) createMountNamespace(ctx context.Context, conf *confi\nreturn mns, nil\n}\n-func useOverlayFilestoreFD(conf *config.Config, isDir bool) bool {\n- overlay2 := conf.GetOverlay2()\n+func useOverlayFilestoreFD(overlay2 config.Overlay2, isDir bool) bool {\nif !overlay2.IsBackedByHostFile() {\nreturn false\n}\n@@ -473,7 +484,7 @@ func useOverlayFilestoreFD(conf *config.Config, isDir bool) bool {\n// layer using tmpfs, and return overlay mount options. \"cleanup\" must be called\n// after the options have been used to mount the overlay, to release refs on\n// lower and upper mounts.\n-func (c *containerMounter) configureOverlay(ctx context.Context, conf *config.Config, creds *auth.Credentials, lowerOpts *vfs.MountOptions, lowerFSName string, useFilestoreFD func(conf *config.Config, isDir bool) bool) (*vfs.MountOptions, func(), error) {\n+func (c *containerMounter) configureOverlay(ctx context.Context, conf *config.Config, creds *auth.Credentials, lowerOpts *vfs.MountOptions, lowerFSName string, useFilestoreFD func(overlay2 config.Overlay2, isDir bool) bool) (*vfs.MountOptions, func(), error) {\n// First copy options from lower layer to upper layer and overlay. Clear\n// filesystem specific options.\nupperOpts := *lowerOpts\n@@ -514,7 +525,8 @@ func (c *containerMounter) configureOverlay(ctx context.Context, conf *config.Co\ntmpfsOpts := tmpfs.FilesystemOpts{\nRootFileType: uint16(rootType),\n}\n- if useFilestoreFD != nil && useFilestoreFD(conf, rootType == linux.S_IFDIR) {\n+ overlay2 := conf.GetOverlay2()\n+ if useFilestoreFD != nil && useFilestoreFD(overlay2, rootType == linux.S_IFDIR) {\ntmpfsOpts.FilestoreFD = c.overlayFilestoreFDs.removeAsFD()\n}\nupperOpts.GetFilesystemOptions.InternalData = tmpfsOpts\n@@ -554,6 +566,18 @@ func (c *containerMounter) configureOverlay(ctx context.Context, conf *config.Co\n}\n}\n+ // If host filestore is being used and it is backed by self, then we need to\n+ // hide the filestore from the containerized application.\n+ if overlay2.IsBackedBySelf() && useFilestoreFD != nil && useFilestoreFD(overlay2, rootType == linux.S_IFDIR) {\n+ if err := overlay.CreateWhiteout(ctx, c.k.VFS(), creds, &vfs.PathOperation{\n+ Root: upperRootVD,\n+ Start: upperRootVD,\n+ Path: fspath.Parse(selfOverlayFilestoreDirName(c.cid)),\n+ }); err != nil {\n+ return nil, nil, fmt.Errorf(\"failed to create whiteout to hide self overlay filestore: %w\", err)\n+ }\n+ }\n+\n// Propagate the lower layer's root's owner, group, and mode to the upper\n// layer's root for consistency with VFS1.\nerr = c.k.VFS().SetStatAt(ctx, creds, &vfs.PathOperation{\n"
},
{
"change_type": "MODIFY",
"old_path": "test/e2e/BUILD",
"new_path": "test/e2e/BUILD",
"diff": "@@ -42,6 +42,7 @@ go_test(\ndeps = [\n\"//pkg/test/dockerutil\",\n\"//pkg/test/testutil\",\n+ \"//runsc/boot\",\n\"@com_github_docker_docker//api/types/mount:go_default_library\",\n\"@org_golang_x_sys//unix:go_default_library\",\n],\n"
},
{
"change_type": "MODIFY",
"old_path": "test/e2e/integration_runtime_test.go",
"new_path": "test/e2e/integration_runtime_test.go",
"diff": "@@ -39,6 +39,7 @@ import (\n\"golang.org/x/sys/unix\"\n\"gvisor.dev/gvisor/pkg/test/dockerutil\"\n\"gvisor.dev/gvisor/pkg/test/testutil\"\n+ \"gvisor.dev/gvisor/runsc/boot\"\n)\nconst (\n@@ -186,8 +187,7 @@ func TestOverlayNameTooLong(t *testing.T) {\ndefer d.CleanUp(ctx)\nopts := dockerutil.RunOpts{\n- Image: \"basic/integrationtest\",\n- WorkDir: \"/root\",\n+ Image: \"basic/ubuntu\",\n}\nlongName := strings.Repeat(\"a\", unix.NAME_MAX+1)\nif got, err := d.Run(ctx, opts, \"bash\", \"-c\", fmt.Sprintf(\"stat %s || true\", longName)); err != nil {\n@@ -234,3 +234,20 @@ func TestMultipleOverlayMounts(t *testing.T) {\nt.Errorf(\"overlay not applied to both bind mounts, %q file exists\", filePath)\n}\n}\n+\n+// Tests that the overlay backing host file inside the container's rootfs is\n+// hidden from the application.\n+func TestOverlayRootfsWhiteout(t *testing.T) {\n+ ctx := context.Background()\n+ d := dockerutil.MakeContainerWithRuntime(ctx, t, \"-overlay\")\n+ defer d.CleanUp(ctx)\n+\n+ opts := dockerutil.RunOpts{\n+ Image: \"basic/ubuntu\",\n+ }\n+ if got, err := d.Run(ctx, opts, \"bash\", \"-c\", fmt.Sprintf(\"ls -al / | grep %q || true\", boot.SelfOverlayFilestoreDirPrefix)); err != nil {\n+ t.Fatalf(\"docker run failed: %s, %v\", got, err)\n+ } else if got != \"\" {\n+ t.Errorf(\"root directory contains a file/directory whose name contains %q: output = %q\", boot.SelfOverlayFilestoreDirPrefix, got)\n+ }\n+}\n"
}
] | Go | Apache License 2.0 | google/gvisor | Hide root overlay filestore from container using whiteout.
PiperOrigin-RevId: 507355437 |
259,885 | 06.02.2023 09:11:11 | 28,800 | 56141517243d9694f809f5130fafce50757b93d6 | checkinfo: Also skip vars whose type is a type parameter. | [
{
"change_type": "MODIFY",
"old_path": "tools/checkinfo/checkinfo.go",
"new_path": "tools/checkinfo/checkinfo.go",
"diff": "@@ -73,9 +73,14 @@ func (p *pkg) walkObject(pass *analysis.Pass, obj types.Object) {\ncase *types.PkgName:\n// Don't walk to other packages.\ncase *types.Var:\n+ // Skip if the var's type is a type parameter.\n+ typ := x.Type()\n+ if _, ok := typ.(*types.TypeParam); ok {\n+ break\n+ }\n// Add information as a field.\n- a := Align(pass.TypesSizes.Alignof(x.Type()))\n- s := Size(pass.TypesSizes.Sizeof(x.Type()))\n+ a := Align(pass.TypesSizes.Alignof(typ))\n+ s := Size(pass.TypesSizes.Sizeof(typ))\npass.ExportObjectFact(obj, &a)\npass.ExportObjectFact(obj, &s)\ncase *types.TypeName:\n"
}
] | Go | Apache License 2.0 | google/gvisor | checkinfo: Also skip vars whose type is a type parameter.
PiperOrigin-RevId: 507497705 |
259,909 | 06.02.2023 11:21:37 | 28,800 | d4843e167a59f029c41b79390908679029125095 | Enable the stat_times and truncate test for FUSE. | [
{
"change_type": "MODIFY",
"old_path": "pkg/abi/linux/fuse.go",
"new_path": "pkg/abi/linux/fuse.go",
"diff": "package linux\nimport (\n+ \"time\"\n+\n\"gvisor.dev/gvisor/pkg/marshal/primitive\"\n)\n@@ -348,6 +350,24 @@ type FUSEAttr struct {\n_ uint32\n}\n+// ATimeNsec returns the last access time as the total time since the unix epoch\n+// in nanoseconds.\n+func (a FUSEAttr) ATimeNsec() int64 {\n+ return int64(a.Atime)*time.Second.Nanoseconds() + int64(a.AtimeNsec)\n+}\n+\n+// MTimeNsec returns the last modification time as the total time since the unix\n+// epoch in nanoseconds.\n+func (a FUSEAttr) MTimeNsec() int64 {\n+ return int64(a.Mtime)*time.Second.Nanoseconds() + int64(a.MtimeNsec)\n+}\n+\n+// CTimeNsec returns the last change time as the total time since the unix epoch\n+// in nanoseconds.\n+func (a FUSEAttr) CTimeNsec() int64 {\n+ return int64(a.Ctime)*time.Second.Nanoseconds() + int64(a.CtimeNsec)\n+}\n+\n// FUSEAttrOut is the reply sent by the daemon to the kernel\n// for FUSEGetAttrIn and FUSESetAttrIn.\n//\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/file.go",
"new_path": "pkg/sentry/fsimpl/fuse/file.go",
"diff": "@@ -133,6 +133,9 @@ func (fd *fileDescription) SetStat(ctx context.Context, opts vfs.SetStatOptions)\ninode := fd.inode()\ninode.attrMu.Lock()\ndefer inode.attrMu.Unlock()\n+ if err := vfs.CheckSetStat(ctx, creds, &opts, inode.filemode(), auth.KUID(inode.uid.Load()), auth.KGID(inode.gid.Load())); err != nil {\n+ return err\n+ }\nreturn inode.setAttr(ctx, fs, creds, opts, fhOptions{useFh: true, fh: fd.Fh})\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/fuse/inode.go",
"new_path": "pkg/sentry/fsimpl/fuse/inode.go",
"diff": "@@ -17,6 +17,7 @@ package fuse\nimport (\n\"fmt\"\n\"sync\"\n+ \"time\"\n\"gvisor.dev/gvisor/pkg/abi/linux\"\n\"gvisor.dev/gvisor/pkg/atomicbitops\"\n@@ -562,6 +563,7 @@ func (i *inode) Readlink(ctx context.Context, mnt *vfs.Mount) (string, error) {\n//\n// +checklocks:i.attrMu\nfunc (i *inode) getFUSEAttr() linux.FUSEAttr {\n+ ns := time.Second.Nanoseconds()\nreturn linux.FUSEAttr{\nIno: i.nodeID,\nUID: i.uid.Load(),\n@@ -569,9 +571,12 @@ func (i *inode) getFUSEAttr() linux.FUSEAttr {\nSize: i.size.Load(),\nMode: uint32(i.filemode()),\nBlkSize: i.blockSize.Load(),\n- Atime: uint64(i.atime.Load()),\n- Mtime: uint64(i.mtime.Load()),\n- Ctime: uint64(i.ctime.Load()),\n+ Atime: uint64(i.atime.Load() / ns),\n+ Mtime: uint64(i.mtime.Load() / ns),\n+ Ctime: uint64(i.ctime.Load() / ns),\n+ AtimeNsec: uint32(i.atime.Load() % ns),\n+ MtimeNsec: uint32(i.mtime.Load() % ns),\n+ CtimeNsec: uint32(i.ctime.Load() % ns),\nNlink: i.nlink.Load(),\n}\n}\n@@ -771,11 +776,14 @@ func fattrMaskFromStats(mask uint32) uint32 {\n// SetStat implements kernfs.Inode.SetStat.\nfunc (i *inode) SetStat(ctx context.Context, fs *vfs.Filesystem, creds *auth.Credentials, opts vfs.SetStatOptions) error {\n+ i.attrMu.Lock()\n+ defer i.attrMu.Unlock()\n+ if err := vfs.CheckSetStat(ctx, creds, &opts, i.filemode(), auth.KUID(i.uid.Load()), auth.KGID(i.gid.Load())); err != nil {\n+ return err\n+ }\nif opts.Stat.Mask == 0 {\nreturn nil\n}\n- i.attrMu.Lock()\n- defer i.attrMu.Unlock()\nreturn i.setAttr(ctx, fs, creds, opts, fhOptions{useFh: false})\n}\n@@ -797,6 +805,12 @@ func (i *inode) setAttr(ctx context.Context, fs *vfs.Filesystem, creds *auth.Cre\nif fhOpts.useFh {\nfattrMask |= linux.FATTR_FH\n}\n+ if opts.Stat.Mask&linux.STATX_ATIME != 0 && opts.Stat.Atime.Nsec == linux.UTIME_NOW {\n+ fattrMask |= linux.FATTR_ATIME_NOW\n+ }\n+ if opts.Stat.Mask&linux.STATX_MTIME != 0 && opts.Stat.Mtime.Nsec == linux.UTIME_NOW {\n+ fattrMask |= linux.FATTR_ATIME_NOW\n+ }\nin := linux.FUSESetAttrIn{\nValid: fattrMask,\nFh: fhOpts.fh,\n@@ -840,9 +854,9 @@ func (i *inode) updateAttrs(attr linux.FUSEAttr, attrTimeout uint64) {\ni.uid.Store(attr.UID)\ni.gid.Store(attr.GID)\n- i.atime.Store(int64(attr.Atime))\n- i.mtime.Store(int64(attr.Mtime))\n- i.ctime.Store(int64(attr.Ctime))\n+ i.atime.Store(attr.ATimeNsec())\n+ i.mtime.Store(attr.MTimeNsec())\n+ i.ctime.Store(attr.CTimeNsec())\ni.size.Store(attr.Size)\ni.nlink.Store(attr.Nlink)\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/BUILD",
"new_path": "test/syscalls/BUILD",
"diff": "@@ -942,6 +942,7 @@ syscall_test(\n)\nsyscall_test(\n+ add_fusefs = True,\nadd_overlay = True,\ntest = \"//test/syscalls/linux:stat_times_test\",\n)\n@@ -1007,6 +1008,7 @@ syscall_test(\n)\nsyscall_test(\n+ add_fusefs = True,\nadd_overlay = True,\ntest = \"//test/syscalls/linux:truncate_test\",\n)\n"
}
] | Go | Apache License 2.0 | google/gvisor | Enable the stat_times and truncate test for FUSE.
PiperOrigin-RevId: 507534117 |
259,891 | 06.02.2023 17:28:45 | 28,800 | d5eafb28757c79c8ef077c964add7a26a763ba0f | sharedmem: avoid eventfd close/write race
The dispatch loop could pickup the change to e.stopRequested and close the
eventFD before the call to Notify().
See bug for more detail. | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/link/sharedmem/rx.go",
"new_path": "pkg/tcpip/link/sharedmem/rx.go",
"diff": "@@ -85,8 +85,8 @@ func (r *rx) init(mtu uint32, c *QueueConfig) error {\nreturn nil\n}\n-// cleanup releases all resources allocated during init(). It must only be\n-// called if init() has previously succeeded.\n+// cleanup releases all resources allocated during init() except r.eventFD. It\n+// must only be called if init() has previously succeeded.\nfunc (r *rx) cleanup() {\na, b := r.q.Bytes()\nunix.Munmap(a)\n@@ -94,7 +94,6 @@ func (r *rx) cleanup() {\nunix.Munmap(r.data)\nunix.Munmap(r.sharedData)\n- r.eventFD.Close()\n}\n// notify writes to the tx.eventFD to indicate to the peer that there is data to\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/link/sharedmem/sharedmem.go",
"new_path": "pkg/tcpip/link/sharedmem/sharedmem.go",
"diff": "@@ -254,6 +254,7 @@ func (e *endpoint) Close() {\n// stopped after a Close() call.\nfunc (e *endpoint) Wait() {\ne.completed.Wait()\n+ e.rx.eventFD.Close()\n}\n// Attach implements stack.LinkEndpoint.Attach. It launches the goroutine that\n"
}
] | Go | Apache License 2.0 | google/gvisor | sharedmem: avoid eventfd close/write race
The dispatch loop could pickup the change to e.stopRequested and close the
eventFD before the call to Notify().
See bug for more detail.
PiperOrigin-RevId: 507626752 |
260,004 | 07.02.2023 11:06:13 | 28,800 | be5314c5a6aa678ef615b22f106feda58bea0dfb | Allow forcing multicast group protocol mode
Updates | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"diff": "@@ -244,6 +244,7 @@ type protocolMode int\nconst (\nprotocolModeV2 protocolMode = iota\n+ protocolModeV1Forced\nprotocolModeV1Compatibility\n)\n@@ -291,6 +292,35 @@ type GenericMulticastProtocolState struct {\nstateChangedReportV2TimerSet bool\n}\n+// SetForcedV1ModeLocked sets the V1 forced configuration.\n+//\n+// Precondition: g.protocolMU must be locked.\n+func (g *GenericMulticastProtocolState) SetForcedV1ModeLocked(v bool) {\n+ if v {\n+ switch g.mode {\n+ case protocolModeV2:\n+ g.cancelV2ReportTimers()\n+ case protocolModeV1Compatibility:\n+ g.modeTimer.Stop()\n+ case protocolModeV1Forced:\n+ // Already in V1 forced mode; nothing to do.\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n+ }\n+ g.mode = protocolModeV1Forced\n+ return\n+ }\n+\n+ switch g.mode {\n+ case protocolModeV2, protocolModeV1Compatibility:\n+ // Not in V1 forced mode; nothing to do.\n+ case protocolModeV1Forced:\n+ g.mode = protocolModeV2\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n+ }\n+}\n+\nfunc (g *GenericMulticastProtocolState) cancelV2ReportTimers() {\nif g.generalQueryV2Timer != nil {\ng.generalQueryV2Timer.Stop()\n@@ -357,7 +387,7 @@ func (g *GenericMulticastProtocolState) MakeAllNonMemberLocked() {\ngroupAddress,\n)\n}\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\nhandler = g.transitionToNonMemberLocked\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -404,7 +434,7 @@ func (g *GenericMulticastProtocolState) InitializeGroupsLocked() {\nswitch g.mode {\ncase protocolModeV2:\nv2ReportBuilder = g.opts.Protocol.NewReportV2Builder()\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n@@ -451,7 +481,7 @@ func (g *GenericMulticastProtocolState) SendQueuedReportsLocked() {\nswitch g.mode {\ncase protocolModeV2:\ng.sendV2ReportAndMaybeScheduleChangedTimer(groupAddress, &info, MulticastGroupProtocolV2ReportRecordChangeToExcludeMode)\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ng.maybeSendReportLocked(groupAddress, &info)\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -498,7 +528,7 @@ func (g *GenericMulticastProtocolState) JoinGroupLocked(groupAddress tcpip.Addre\n// Nothing meaningful we can do with the error here - we only try to\n// send a delayed report once.\n_, _ = reportBuilder.Send()\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ng.maybeSendReportLocked(groupAddress, &info)\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -644,7 +674,7 @@ func (g *GenericMulticastProtocolState) LeaveGroupLocked(groupAddress tcpip.Addr\n} else {\ndelete(g.memberships, groupAddress)\n}\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ng.transitionToNonMemberLocked(groupAddress, &info)\ndelete(g.memberships, groupAddress)\ndefault:\n@@ -663,7 +693,7 @@ func (g *GenericMulticastProtocolState) HandleQueryV2Locked(groupAddress tcpip.A\n}\nswitch g.mode {\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ng.handleQueryInnerLocked(groupAddress, g.opts.Protocol.V2QueryMaxRespCodeToV1Delay(maxResponseCode))\nreturn\ncase protocolModeV2:\n@@ -847,6 +877,8 @@ func (g *GenericMulticastProtocolState) HandleQueryLocked(groupAddress tcpip.Add\nreturn\n}\n+ switch g.mode {\n+ case protocolModeV2, protocolModeV1Compatibility:\n// As per 3376 section 8.12 (for IGMPv3),\n//\n// The Older Version Querier Interval is the time-out for transitioning\n@@ -882,7 +914,10 @@ func (g *GenericMulticastProtocolState) HandleQueryLocked(groupAddress tcpip.Add\n}\ng.mode = protocolModeV1Compatibility\ng.cancelV2ReportTimers()\n-\n+ case protocolModeV1Forced:\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n+ }\ng.handleQueryInnerLocked(groupAddress, maxResponseTime)\n}\n@@ -961,7 +996,7 @@ func (g *GenericMulticastProtocolState) initializeNewMemberLocked(groupAddress t\ncallersV2ReportBuilder.AddRecord(MulticastGroupProtocolV2ReportRecordChangeToExcludeMode, groupAddress)\ninfo.transmissionLeft--\n}\n- case protocolModeV1Compatibility:\n+ case protocolModeV1Compatibility, protocolModeV1Forced:\ninfo.transmissionLeft = unsolicitedTransmissionCount\ng.maybeSendReportLocked(groupAddress, info)\ndefault:\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"diff": "@@ -17,7 +17,6 @@ package ip_test\nimport (\n\"bytes\"\n\"fmt\"\n- \"math\"\n\"math/rand\"\n\"testing\"\n\"time\"\n@@ -61,11 +60,7 @@ func (m *mockMulticastGroupProtocol) init(opts ip.GenericMulticastProtocolOption\nm.mu.genericMulticastGroup.Init(&m.mu.RWMutex, opts)\nif v1Compatibility {\n- // A General V1 query should make us drop into V1 compatibility mode.\n- //\n- // Since we just init-ed, we know we don't have any groups to send\n- // reports for so this won't break any tests looking at packets.\n- m.mu.genericMulticastGroup.HandleQueryLocked(\"\", math.MaxInt64)\n+ m.mu.genericMulticastGroup.SetForcedV1ModeLocked(true)\n}\n}\n@@ -87,6 +82,12 @@ func (m *mockMulticastGroupProtocol) setQueuePackets(v bool) {\nm.mu.makeQueuePackets = v\n}\n+func (m *mockMulticastGroupProtocol) setForcedV1Mode(v bool) {\n+ m.mu.Lock()\n+ defer m.mu.Unlock()\n+ m.mu.genericMulticastGroup.SetForcedV1ModeLocked(v)\n+}\n+\nfunc (m *mockMulticastGroupProtocol) joinGroup(addr tcpip.Address) {\nm.mu.Lock()\ndefer m.mu.Unlock()\n@@ -1416,11 +1417,6 @@ func TestQueuedPackets(t *testing.T) {\n// The delayed report timer should have been cancelled since we did not send\n// the initial report earlier.\nclock.Advance(time.Hour)\n- if test.v1Compatibility {\n- // V1 query targetting an unjoined group should drop us into V1\n- // compatibility mode without sending any packets, affecting tests.\n- mgp.handleQuery(addr3, 0)\n- }\nif diff := mgp.check(checkFields{}); diff != \"\" {\nt.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n@@ -1509,3 +1505,40 @@ func TestQueuedPackets(t *testing.T) {\n})\n}\n}\n+\n+func TestV1Compatibility(t *testing.T) {\n+ clock := faketime.NewManualClock()\n+ mgp := mockMulticastGroupProtocol{t: t}\n+ mgp.init(ip.GenericMulticastProtocolOptions{\n+ Rand: rand.New(rand.NewSource(4)),\n+ Clock: clock,\n+ MaxUnsolicitedReportDelay: maxUnsolicitedReportDelay,\n+ }, false /* v1Compatibility */)\n+\n+ mgp.joinGroup(addr1)\n+ if diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{\n+ {\n+ recordType: ip.MulticastGroupProtocolV2ReportRecordChangeToExcludeMode,\n+ groupAddress: addr1,\n+ },\n+ }}}}); diff != \"\" {\n+ t.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n+ }\n+\n+ mgp.setForcedV1Mode(true)\n+ mgp.joinGroup(addr2)\n+ if diff := mgp.check(checkFields{sendReportGroupAddresses: []tcpip.Address{addr2}}); diff != \"\" {\n+ t.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n+ }\n+\n+ mgp.setForcedV1Mode(false)\n+ mgp.joinGroup(addr3)\n+ if diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{\n+ {\n+ recordType: ip.MulticastGroupProtocolV2ReportRecordChangeToExcludeMode,\n+ groupAddress: addr3,\n+ },\n+ }}}}); diff != \"\" {\n+ t.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n+ }\n+}\n"
}
] | Go | Apache License 2.0 | google/gvisor | Allow forcing multicast group protocol mode
Updates #8346
PiperOrigin-RevId: 507832493 |
259,907 | 07.02.2023 11:07:08 | 28,800 | 8373fb5db8c8f4f4a028c39f0c2cf7e95a7fca80 | Check hard link target's mount compatibility before kernfs.Dentry cast.
Reported-by: | [
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"new_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"diff": "@@ -362,8 +362,9 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nreturn err\n}\n- parent.dirMu.Lock()\n- defer parent.dirMu.Unlock()\n+ if rp.Mount() != vd.Mount() {\n+ return linuxerr.EXDEV\n+ }\ninode := vd.Dentry().Impl().(*Dentry).Inode()\nif inode.Mode().IsDir() {\nreturn linuxerr.EPERM\n@@ -371,6 +372,8 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif err := vfs.MayLink(rp.Credentials(), inode.Mode(), inode.UID(), inode.GID()); err != nil {\nreturn err\n}\n+ parent.dirMu.Lock()\n+ defer parent.dirMu.Unlock()\npc := rp.Component()\nif err := checkCreateLocked(ctx, rp.Credentials(), pc, parent); err != nil {\nreturn err\n@@ -378,9 +381,6 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif rp.MustBeDir() {\nreturn linuxerr.ENOENT\n}\n- if rp.Mount() != vd.Mount() {\n- return linuxerr.EXDEV\n- }\nif err := rp.Mount().CheckBeginWrite(); err != nil {\nreturn err\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | Check hard link target's mount compatibility before kernfs.Dentry cast.
Reported-by: syzbot+65dcd89bab032fdb8ac8@syzkaller.appspotmail.com
PiperOrigin-RevId: 507832777 |
259,891 | 07.02.2023 11:27:02 | 28,800 | efea4074717caf58510dbb1e8b765fa9ba46bd30 | sharedmem: clarify cleanup in comments | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/link/sharedmem/sharedmem.go",
"new_path": "pkg/tcpip/link/sharedmem/sharedmem.go",
"diff": "@@ -191,6 +191,9 @@ type endpoint struct {\n// New creates a new shared-memory-based endpoint. Buffers will be broken up\n// into buffers of \"bufferSize\" bytes.\n+//\n+// In order to release all resources held by the returned endpoint, Close()\n+// must be called followed by Wait().\nfunc New(opts Options) (stack.LinkEndpoint, error) {\ne := &endpoint{\nmtu: opts.MTU,\n@@ -231,7 +234,8 @@ func New(opts Options) (stack.LinkEndpoint, error) {\nreturn e, nil\n}\n-// Close frees all resources associated with the endpoint.\n+// Close frees most resources associated with the endpoint. Wait() must be\n+// called after Close() in order to free the rest.\nfunc (e *endpoint) Close() {\n// Tell dispatch goroutine to stop, then write to the eventfd so that\n// it wakes up in case it's sleeping.\n"
}
] | Go | Apache License 2.0 | google/gvisor | sharedmem: clarify cleanup in comments
PiperOrigin-RevId: 507838107 |
260,004 | 07.02.2023 12:16:56 | 28,800 | c3ff31ef8cd2bcd9c6652623f5d1b0748e6e61ba | Allow setting MLD version
Updates | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"diff": "@@ -244,7 +244,7 @@ type protocolMode int\nconst (\nprotocolModeV2 protocolMode = iota\n- protocolModeV1Forced\n+ protocolModeV1\nprotocolModeV1Compatibility\n)\n@@ -292,30 +292,35 @@ type GenericMulticastProtocolState struct {\nstateChangedReportV2TimerSet bool\n}\n-// SetForcedV1ModeLocked sets the V1 forced configuration.\n+// SetV1ModeLocked sets the V1 configuration.\n+//\n+// Returns the previous configuration.\n//\n// Precondition: g.protocolMU must be locked.\n-func (g *GenericMulticastProtocolState) SetForcedV1ModeLocked(v bool) {\n+func (g *GenericMulticastProtocolState) SetV1ModeLocked(v bool) bool {\nif v {\nswitch g.mode {\ncase protocolModeV2:\ng.cancelV2ReportTimers()\ncase protocolModeV1Compatibility:\ng.modeTimer.Stop()\n- case protocolModeV1Forced:\n- // Already in V1 forced mode; nothing to do.\n+ case protocolModeV1:\n+ // Already in V1 mode; nothing to do.\n+ return true\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n- g.mode = protocolModeV1Forced\n- return\n+ g.mode = protocolModeV1\n+ return false\n}\nswitch g.mode {\ncase protocolModeV2, protocolModeV1Compatibility:\n- // Not in V1 forced mode; nothing to do.\n- case protocolModeV1Forced:\n+ // Not in V1 mode; nothing to do.\n+ return false\n+ case protocolModeV1:\ng.mode = protocolModeV2\n+ return true\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n@@ -387,7 +392,7 @@ func (g *GenericMulticastProtocolState) MakeAllNonMemberLocked() {\ngroupAddress,\n)\n}\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\nhandler = g.transitionToNonMemberLocked\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -434,7 +439,7 @@ func (g *GenericMulticastProtocolState) InitializeGroupsLocked() {\nswitch g.mode {\ncase protocolModeV2:\nv2ReportBuilder = g.opts.Protocol.NewReportV2Builder()\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n@@ -481,7 +486,7 @@ func (g *GenericMulticastProtocolState) SendQueuedReportsLocked() {\nswitch g.mode {\ncase protocolModeV2:\ng.sendV2ReportAndMaybeScheduleChangedTimer(groupAddress, &info, MulticastGroupProtocolV2ReportRecordChangeToExcludeMode)\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ng.maybeSendReportLocked(groupAddress, &info)\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -528,7 +533,7 @@ func (g *GenericMulticastProtocolState) JoinGroupLocked(groupAddress tcpip.Addre\n// Nothing meaningful we can do with the error here - we only try to\n// send a delayed report once.\n_, _ = reportBuilder.Send()\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ng.maybeSendReportLocked(groupAddress, &info)\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n@@ -674,7 +679,7 @@ func (g *GenericMulticastProtocolState) LeaveGroupLocked(groupAddress tcpip.Addr\n} else {\ndelete(g.memberships, groupAddress)\n}\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ng.transitionToNonMemberLocked(groupAddress, &info)\ndelete(g.memberships, groupAddress)\ndefault:\n@@ -693,7 +698,7 @@ func (g *GenericMulticastProtocolState) HandleQueryV2Locked(groupAddress tcpip.A\n}\nswitch g.mode {\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ng.handleQueryInnerLocked(groupAddress, g.opts.Protocol.V2QueryMaxRespCodeToV1Delay(maxResponseCode))\nreturn\ncase protocolModeV2:\n@@ -914,7 +919,7 @@ func (g *GenericMulticastProtocolState) HandleQueryLocked(groupAddress tcpip.Add\n}\ng.mode = protocolModeV1Compatibility\ng.cancelV2ReportTimers()\n- case protocolModeV1Forced:\n+ case protocolModeV1:\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n@@ -996,7 +1001,7 @@ func (g *GenericMulticastProtocolState) initializeNewMemberLocked(groupAddress t\ncallersV2ReportBuilder.AddRecord(MulticastGroupProtocolV2ReportRecordChangeToExcludeMode, groupAddress)\ninfo.transmissionLeft--\n}\n- case protocolModeV1Compatibility, protocolModeV1Forced:\n+ case protocolModeV1Compatibility, protocolModeV1:\ninfo.transmissionLeft = unsolicitedTransmissionCount\ng.maybeSendReportLocked(groupAddress, info)\ndefault:\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"diff": "@@ -60,7 +60,7 @@ func (m *mockMulticastGroupProtocol) init(opts ip.GenericMulticastProtocolOption\nm.mu.genericMulticastGroup.Init(&m.mu.RWMutex, opts)\nif v1Compatibility {\n- m.mu.genericMulticastGroup.SetForcedV1ModeLocked(true)\n+ m.mu.genericMulticastGroup.SetV1ModeLocked(true)\n}\n}\n@@ -82,10 +82,10 @@ func (m *mockMulticastGroupProtocol) setQueuePackets(v bool) {\nm.mu.makeQueuePackets = v\n}\n-func (m *mockMulticastGroupProtocol) setForcedV1Mode(v bool) {\n+func (m *mockMulticastGroupProtocol) setV1Mode(v bool) bool {\nm.mu.Lock()\ndefer m.mu.Unlock()\n- m.mu.genericMulticastGroup.SetForcedV1ModeLocked(v)\n+ return m.mu.genericMulticastGroup.SetV1ModeLocked(v)\n}\nfunc (m *mockMulticastGroupProtocol) joinGroup(addr tcpip.Address) {\n@@ -1506,7 +1506,7 @@ func TestQueuedPackets(t *testing.T) {\n}\n}\n-func TestV1Compatibility(t *testing.T) {\n+func TestSetV1Mode(t *testing.T) {\nclock := faketime.NewManualClock()\nmgp := mockMulticastGroupProtocol{t: t}\nmgp.init(ip.GenericMulticastProtocolOptions{\n@@ -1525,13 +1525,17 @@ func TestV1Compatibility(t *testing.T) {\nt.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n- mgp.setForcedV1Mode(true)\n+ if mgp.setV1Mode(true) {\n+ t.Error(\"got mgp.setV1Mode(true) = true, want = false\")\n+ }\nmgp.joinGroup(addr2)\nif diff := mgp.check(checkFields{sendReportGroupAddresses: []tcpip.Address{addr2}}); diff != \"\" {\nt.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n- mgp.setForcedV1Mode(false)\n+ if !mgp.setV1Mode(false) {\n+ t.Error(\"got mgp.setV1Mode(false) = false, want = true\")\n+ }\nmgp.joinGroup(addr3)\nif diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/ipv6.go",
"new_path": "pkg/tcpip/network/ipv6/ipv6.go",
"diff": "@@ -180,6 +180,7 @@ var _ stack.GroupAddressableEndpoint = (*endpoint)(nil)\nvar _ stack.AddressableEndpoint = (*endpoint)(nil)\nvar _ stack.NetworkEndpoint = (*endpoint)(nil)\nvar _ stack.NDPEndpoint = (*endpoint)(nil)\n+var _ MLDEndpoint = (*endpoint)(nil)\nvar _ NDPEndpoint = (*endpoint)(nil)\ntype endpoint struct {\n@@ -356,6 +357,13 @@ func (e *endpoint) InvalidateDefaultRouter(rtr tcpip.Address) {\ne.mu.ndp.invalidateOffLinkRoute(offLinkRoute{dest: header.IPv6EmptySubnet, router: rtr})\n}\n+// SetMLDVersion implements MLDEndpoint.\n+func (e *endpoint) SetMLDVersion(v MLDVersion) MLDVersion {\n+ e.mu.Lock()\n+ defer e.mu.Unlock()\n+ return e.mu.mld.setVersion(v)\n+}\n+\n// SetNDPConfigurations implements NDPEndpoint.\nfunc (e *endpoint) SetNDPConfigurations(c NDPConfigurations) {\nc.validate()\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/mld.go",
"new_path": "pkg/tcpip/network/ipv6/mld.go",
"diff": "@@ -33,6 +33,26 @@ const (\nUnsolicitedReportIntervalMax = 10 * time.Second\n)\n+// MLDVersion is the forced version of MLD.\n+type MLDVersion int\n+\n+const (\n+ _ MLDVersion = iota\n+ // MLDVersion1 indicates MLDv1.\n+ MLDVersion1\n+ // MLDVersion2 indicates MLDv2. Note that MLD may still fallback to V1\n+ // compatibility mode as required by MLDv2.\n+ MLDVersion2\n+)\n+\n+// MLDEndpoint is a network endpoint that supports MLD.\n+type MLDEndpoint interface {\n+ // Sets the MLD version.\n+ //\n+ // Returns the previous MLD version.\n+ SetMLDVersion(MLDVersion) MLDVersion\n+}\n+\n// MLDOptions holds options for MLD.\ntype MLDOptions struct {\n// Enabled indicates whether MLD will be performed.\n@@ -300,6 +320,26 @@ func (mld *mldState) sendQueuedReports() {\nmld.genericMulticastProtocol.SendQueuedReportsLocked()\n}\n+// setVersion sets the MLD version.\n+//\n+// Precondition: mld.ep.mu must be locked.\n+func (mld *mldState) setVersion(v MLDVersion) MLDVersion {\n+ var prev bool\n+ switch v {\n+ case MLDVersion2:\n+ prev = mld.genericMulticastProtocol.SetV1ModeLocked(false)\n+ case MLDVersion1:\n+ prev = mld.genericMulticastProtocol.SetV1ModeLocked(true)\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized version = %d\", v))\n+ }\n+\n+ if prev {\n+ return MLDVersion1\n+ }\n+ return MLDVersion2\n+}\n+\n// writePacket assembles and sends an MLD packet.\n//\n// Precondition: mld.ep.mu must be read locked.\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/mld_test.go",
"new_path": "pkg/tcpip/network/ipv6/mld_test.go",
"diff": "@@ -44,6 +44,24 @@ var (\nglobalAddrSNMC = header.SolicitedNodeAddr(globalAddr)\n)\n+func checkVersion(t *testing.T, s *stack.Stack, nicID tcpip.NICID, v1 bool) {\n+ if !v1 {\n+ return\n+ }\n+\n+ ep, err := s.GetNetworkEndpoint(nicID, header.IPv6ProtocolNumber)\n+ if err != nil {\n+ t.Fatalf(\"s.GetNetworkEndpoint(%d, %d): %s\", nicID, header.IPv6ProtocolNumber, err)\n+ }\n+\n+ mldEP, ok := ep.(ipv6.MLDEndpoint)\n+ if !ok {\n+ t.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, mldEP)\n+ }\n+\n+ mldEP.SetMLDVersion(ipv6.MLDVersion1)\n+}\n+\nfunc validateMLDPacket(t *testing.T, v *bufferv2.View, localAddress, remoteAddress tcpip.Address, mldType header.ICMPv6Type, groupAddress tcpip.Address) {\nt.Helper()\n@@ -141,17 +159,7 @@ func TestIPv6JoinLeaveSolicitedNodeAddressPerformsMLD(t *testing.T) {\nt.Fatalf(\"CreateNIC(%d, _): %s\", nicID, err)\n}\n- if test.v1Compatibility {\n- createAndInjectMLDPacket(\n- e,\n- header.ICMPv6MulticastListenerQuery,\n- header.MLDHopLimit,\n- linkLocalAddr,\n- header.IPv6Any,\n- true, /* withRouterAlertOption */\n- header.IPv6RouterAlertMLD,\n- )\n- }\n+ checkVersion(t, s, nicID, test.v1Compatibility)\n// The stack will join an address's solicited node multicast address when\n// an address is added. An MLD report message should be sent for the\n@@ -306,20 +314,7 @@ func TestSendQueuedMLDReports(t *testing.T) {\n}\n}\n- checkVersion := func() {\n- if subTest.v1Compatibility {\n- createAndInjectMLDPacket(\n- e,\n- header.ICMPv6MulticastListenerQuery,\n- header.MLDHopLimit,\n- linkLocalAddr,\n- unusedMulticastAddr,\n- true, /* withRouterAlertOption */\n- header.IPv6RouterAlertMLD,\n- )\n- }\n- }\n- checkVersion()\n+ checkVersion(t, s, nicID, subTest.v1Compatibility)\nvar reportCounter uint64\nvar doneCounter uint64\n@@ -335,7 +330,6 @@ func TestSendQueuedMLDReports(t *testing.T) {\nsubTest.checkStats(t, s, reportCounter, doneCounter, reportV2Counter)\nsubTest.validate(t, e, header.IPv6Any, []tcpip.Address{globalMulticastAddr}, false /* leave */)\nclock.Advance(time.Hour)\n- checkVersion()\nif p := e.Read(); !p.IsNil() {\nt.Errorf(\"got unexpected packet = %#v\", p)\np.DecRef()\n@@ -720,17 +714,7 @@ func TestMLDSkipProtocol(t *testing.T) {\ndefer e.Close()\ndefer c.cleanup()\n- if subTest.v1Compatibility {\n- createAndInjectMLDPacket(\n- e,\n- header.ICMPv6MulticastListenerQuery,\n- header.MLDHopLimit,\n- linkLocalAddr,\n- header.IPv6Any,\n- true, /* withRouterAlertOption */\n- header.IPv6RouterAlertMLD,\n- )\n- }\n+ checkVersion(t, s, nicID, subTest.v1Compatibility)\nprotocolAddr := tcpip.ProtocolAddress{\nProtocol: ipv6.ProtocolNumber,\n@@ -775,6 +759,70 @@ func TestMLDSkipProtocol(t *testing.T) {\n}\n}\n+func TestSetMLDVersion(t *testing.T) {\n+ const nicID = 1\n+\n+ c := newMLDTestContext()\n+ s := c.s\n+\n+ e := channel.New(1, header.IPv6MinimumMTU, \"\")\n+ if err := s.CreateNIC(nicID, e); err != nil {\n+ t.Fatalf(\"CreateNIC(%d, _): %s\", nicID, err)\n+ }\n+\n+ defer e.Close()\n+ defer c.cleanup()\n+\n+ ep, err := s.GetNetworkEndpoint(nicID, header.IPv6ProtocolNumber)\n+ if err != nil {\n+ t.Fatalf(\"s.GetNetworkEndpoint(%d, %d): %s\", nicID, header.IPv6ProtocolNumber, err)\n+ }\n+ mldEP, ok := ep.(ipv6.MLDEndpoint)\n+ if !ok {\n+ t.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, mldEP)\n+ }\n+\n+ protocolAddr := tcpip.ProtocolAddress{\n+ Protocol: ipv6.ProtocolNumber,\n+ AddressWithPrefix: linkLocalAddr.WithPrefix(),\n+ }\n+ if err := s.AddProtocolAddress(nicID, protocolAddr, stack.AddressProperties{}); err != nil {\n+ t.Fatalf(\"AddProtocolAddress(%d, %+v, {}): %s\", nicID, protocolAddr, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateMLDv2ReportPacket(t, stack.PayloadSince(p.NetworkHeader()), linkLocalAddr, linkLocalAddrSNMC, header.MLDv2ReportRecordChangeToExcludeMode)\n+ p.DecRef()\n+ }\n+\n+ if got := mldEP.SetMLDVersion(ipv6.MLDVersion1); got != ipv6.MLDVersion2 {\n+ t.Errorf(\"got mldEP.SetMLDVersion(%d) = %d, want = %d\", ipv6.MLDVersion1, got, ipv6.MLDVersion2)\n+ }\n+ if err := s.JoinGroup(ipv6.ProtocolNumber, nicID, globalMulticastAddr); err != nil {\n+ t.Fatalf(\"s.JoinGroup(%d, %d, %s): %s\", ipv6.ProtocolNumber, nicID, globalMulticastAddr, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateMLDPacket(t, stack.PayloadSince(p.NetworkHeader()), linkLocalAddr, globalMulticastAddr, header.ICMPv6MulticastListenerReport, globalMulticastAddr)\n+ p.DecRef()\n+ }\n+\n+ if got := mldEP.SetMLDVersion(ipv6.MLDVersion2); got != ipv6.MLDVersion1 {\n+ t.Errorf(\"got mldEP.SetMLDVersion(%d) = %d, want = %d\", ipv6.MLDVersion2, got, ipv6.MLDVersion1)\n+ }\n+ if err := s.LeaveGroup(ipv6.ProtocolNumber, nicID, globalMulticastAddr); err != nil {\n+ t.Fatalf(\"s.LeaveGroup(%d, %d, %s): %s\", ipv6.ProtocolNumber, nicID, globalMulticastAddr, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateMLDv2ReportPacket(t, stack.PayloadSince(p.NetworkHeader()), linkLocalAddr, globalMulticastAddr, header.MLDv2ReportRecordChangeToIncludeMode)\n+ p.DecRef()\n+ }\n+}\n+\nfunc TestMain(m *testing.M) {\nrefs.SetLeakMode(refs.LeaksPanic)\ncode := m.Run()\n"
}
] | Go | Apache License 2.0 | google/gvisor | Allow setting MLD version
Updates #8346
PiperOrigin-RevId: 507851551 |
259,909 | 07.02.2023 14:35:12 | 28,800 | 1da6444d05e9f9a734c0e3c32cd9b2d3bd3dd3ec | Enable unlink test for FUSE. | [
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"new_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"diff": "@@ -362,9 +362,8 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nreturn err\n}\n- if rp.Mount() != vd.Mount() {\n- return linuxerr.EXDEV\n- }\n+ parent.dirMu.Lock()\n+ defer parent.dirMu.Unlock()\ninode := vd.Dentry().Impl().(*Dentry).Inode()\nif inode.Mode().IsDir() {\nreturn linuxerr.EPERM\n@@ -372,8 +371,6 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif err := vfs.MayLink(rp.Credentials(), inode.Mode(), inode.UID(), inode.GID()); err != nil {\nreturn err\n}\n- parent.dirMu.Lock()\n- defer parent.dirMu.Unlock()\npc := rp.Component()\nif err := checkCreateLocked(ctx, rp.Credentials(), pc, parent); err != nil {\nreturn err\n@@ -381,6 +378,9 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif rp.MustBeDir() {\nreturn linuxerr.ENOENT\n}\n+ if rp.Mount() != vd.Mount() {\n+ return linuxerr.EXDEV\n+ }\nif err := rp.Mount().CheckBeginWrite(); err != nil {\nreturn err\n}\n@@ -793,46 +793,67 @@ func (fs *Filesystem) RmdirAt(ctx context.Context, rp *vfs.ResolvingPath) error\nfs.mu.Lock()\ndefer fs.processDeferredDecRefs(ctx)\ndefer fs.mu.Unlock()\n-\n- d, err := fs.walkExistingLocked(ctx, rp)\n+ parent, err := fs.walkParentDirLocked(ctx, rp, rp.Start().Impl().(*Dentry))\nif err != nil {\nreturn err\n}\n+ if err := parent.inode.CheckPermissions(ctx, rp.Credentials(), vfs.MayWrite|vfs.MayExec); err != nil {\n+ return err\n+ }\nif err := rp.Mount().CheckBeginWrite(); err != nil {\nreturn err\n}\ndefer rp.Mount().EndWrite()\n- if err := checkDeleteLocked(ctx, rp, d); err != nil {\n+ name := rp.Component()\n+ if name == \".\" {\n+ return linuxerr.EINVAL\n+ }\n+ if name == \"..\" {\n+ return linuxerr.ENOTEMPTY\n+ }\n+ child, ok := parent.children[name]\n+ if !ok {\n+ return linuxerr.ENOENT\n+ }\n+ if err := checkDeleteLocked(ctx, rp, child); err != nil {\nreturn err\n}\n- if !d.isDir() {\n+ if err := vfs.CheckDeleteSticky(\n+ rp.Credentials(),\n+ linux.FileMode(parent.inode.Mode()),\n+ auth.KUID(parent.inode.UID()),\n+ auth.KUID(child.inode.UID()),\n+ auth.KGID(child.inode.GID()),\n+ ); err != nil {\n+ return err\n+ }\n+ if !child.isDir() {\nreturn linuxerr.ENOTDIR\n}\n- if d.inode.HasChildren() {\n+ if child.inode.HasChildren() {\nreturn linuxerr.ENOTEMPTY\n}\nvirtfs := rp.VirtualFilesystem()\n- parentDentry := d.parent\n- parentDentry.dirMu.Lock()\n- defer parentDentry.dirMu.Unlock()\n+ parent.dirMu.Lock()\n+ defer parent.dirMu.Unlock()\nmntns := vfs.MountNamespaceFromContext(ctx)\ndefer mntns.DecRef(ctx)\n- vfsd := d.VFSDentry()\n+ vfsd := child.VFSDentry()\nif err := virtfs.PrepareDeleteDentry(mntns, vfsd); err != nil {\nreturn err // +checklocksforce: vfsd is not locked.\n}\n- if err := parentDentry.inode.RmDir(ctx, d.name, d.inode); err != nil {\n+ if err := parent.inode.RmDir(ctx, child.name, child.inode); err != nil {\nvirtfs.AbortDeleteDentry(vfsd)\nreturn err\n}\n- delete(parentDentry.children, d.name)\n- parentDentry.inode.Watches().Notify(ctx, d.name, linux.IN_DELETE|linux.IN_ISDIR, 0, vfs.InodeEvent, true /* unlinked */)\n+ delete(parent.children, child.name)\n+ parent.inode.Watches().Notify(ctx, child.name, linux.IN_DELETE|linux.IN_ISDIR, 0, vfs.InodeEvent, true /* unlinked */)\n// Defer decref so that fs.mu and parentDentry.dirMu are unlocked by then.\n- fs.deferDecRef(d)\n+ fs.deferDecRef(child)\nvirtfs.CommitDeleteDentry(ctx, vfsd)\n- d.setDeleted()\n+ child.setDeleted()\nreturn nil\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/BUILD",
"new_path": "test/syscalls/BUILD",
"diff": "@@ -1043,6 +1043,7 @@ syscall_test(\n)\nsyscall_test(\n+ add_fusefs = True,\nadd_overlay = True,\ntest = \"//test/syscalls/linux:unlink_test\",\n)\n"
}
] | Go | Apache License 2.0 | google/gvisor | Enable unlink test for FUSE.
PiperOrigin-RevId: 507888060 |
260,004 | 07.02.2023 17:15:19 | 28,800 | 6080f5725e576b7a1289ba9b95743fadc9c248bc | Allow setting IGMP version
Updates | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/igmp.go",
"new_path": "pkg/tcpip/network/ipv4/igmp.go",
"diff": "@@ -19,7 +19,6 @@ import (\n\"math\"\n\"time\"\n- \"gvisor.dev/gvisor/pkg/atomicbitops\"\n\"gvisor.dev/gvisor/pkg/bufferv2\"\n\"gvisor.dev/gvisor/pkg/tcpip\"\n\"gvisor.dev/gvisor/pkg/tcpip/header\"\n@@ -28,11 +27,6 @@ import (\n)\nconst (\n- // igmpV1PresentDefault is the initial state for igmpV1Present in the\n- // igmpState. As per RFC 2236 Page 9 says \"No IGMPv1 Router Present ... is\n- // the initial state.\"\n- igmpV1PresentDefault = 0\n-\n// v1RouterPresentTimeout from RFC 2236 Section 8.11, Page 18\n// See note on igmpState.igmpV1Present for more detail.\nv1RouterPresentTimeout = 400 * time.Second\n@@ -51,6 +45,47 @@ const (\nUnsolicitedReportIntervalMax = 10 * time.Second\n)\n+type protocolMode int\n+\n+const (\n+ protocolModeV2OrV3 protocolMode = iota\n+ protocolModeV1\n+ // protocolModeV1Compatibility is for maintaining compatibility with IGMPv1\n+ // Routers.\n+ //\n+ // Per RFC 2236 Section 4 Page 6: \"The IGMPv1 router expects Version 1\n+ // Membership Reports in response to its Queries, and will not pay\n+ // attention to Version 2 Membership Reports. Therefore, a state variable\n+ // MUST be kept for each interface, describing whether the multicast\n+ // Querier on that interface is running IGMPv1 or IGMPv2. This variable\n+ // MUST be based upon whether or not an IGMPv1 query was heard in the last\n+ // [Version 1 Router Present Timeout] seconds\".\n+ protocolModeV1Compatibility\n+)\n+\n+// IGMPVersion is the forced version of IGMP.\n+type IGMPVersion int\n+\n+const (\n+ _ IGMPVersion = iota\n+ // IGMPVersion1 indicates IGMPv1.\n+ IGMPVersion1\n+ // IGMPVersion2 indicates IGMPv2. Note that IGMP may still fallback to V1\n+ // compatibility mode as required by IGMPv2.\n+ IGMPVersion2\n+ // IGMPVersion3 indicates IGMPv3. Note that IGMP may still fallback to V2\n+ // compatibility mode as required by IGMPv3.\n+ IGMPVersion3\n+)\n+\n+// IGMPEndpoint is a network endpoint that supports IGMP.\n+type IGMPEndpoint interface {\n+ // Sets the IGMP version.\n+ //\n+ // Returns the previous IGMP version.\n+ SetIGMPVersion(IGMPVersion) IGMPVersion\n+}\n+\n// IGMPOptions holds options for IGMP.\ntype IGMPOptions struct {\n// Enabled indicates whether IGMP will be performed.\n@@ -75,17 +110,8 @@ type igmpState struct {\ngenericMulticastProtocol ip.GenericMulticastProtocolState\n- // igmpV1Present is for maintaining compatibility with IGMPv1 Routers, from\n- // RFC 2236 Section 4 Page 6: \"The IGMPv1 router expects Version 1\n- // Membership Reports in response to its Queries, and will not pay\n- // attention to Version 2 Membership Reports. Therefore, a state variable\n- // MUST be kept for each interface, describing whether the multicast\n- // Querier on that interface is running IGMPv1 or IGMPv2. This variable\n- // MUST be based upon whether or not an IGMPv1 query was heard in the last\n- // [Version 1 Router Present Timeout] seconds\".\n- //\n- // Holds a value of 1 when true, 0 when false.\n- igmpV1Present atomicbitops.Uint32\n+ // mode is used to configure the version of IGMP to perform.\n+ mode protocolMode\n// igmpV1Job is scheduled when this interface receives an IGMPv1 style\n// message, upon expiration the igmpV1Present flag is cleared.\n@@ -105,8 +131,12 @@ func (igmp *igmpState) Enabled() bool {\n// +checklocksread:igmp.ep.mu\nfunc (igmp *igmpState) SendReport(groupAddress tcpip.Address) (bool, tcpip.Error) {\nigmpType := header.IGMPv2MembershipReport\n- if igmp.v1Present() {\n+ switch igmp.mode {\n+ case protocolModeV2OrV3:\n+ case protocolModeV1, protocolModeV1Compatibility:\nigmpType = header.IGMPv1MembershipReport\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n}\nreturn igmp.writePacket(groupAddress, groupAddress, igmpType)\n}\n@@ -119,11 +149,15 @@ func (igmp *igmpState) SendLeave(groupAddress tcpip.Address) tcpip.Error {\n// Querier is running IGMPv1, this action SHOULD be skipped. If the flag\n// saying we were the last host to report is cleared, this action MAY be\n// skipped.\"\n- if igmp.v1Present() {\n- return nil\n- }\n+ switch igmp.mode {\n+ case protocolModeV2OrV3:\n_, err := igmp.writePacket(header.IPv4AllRoutersGroup, groupAddress, header.IGMPLeaveGroup)\nreturn err\n+ case protocolModeV1, protocolModeV1Compatibility:\n+ return nil\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n+ }\n}\n// ShouldPerformProtocol implements ip.MulticastGroupProtocol.\n@@ -251,9 +285,11 @@ func (igmp *igmpState) init(ep *endpoint) {\nProtocol: igmp,\nMaxUnsolicitedReportDelay: UnsolicitedReportIntervalMax,\n})\n- igmp.igmpV1Present = atomicbitops.FromUint32(igmpV1PresentDefault)\n+ // As per RFC 2236 Page 9 says \"No IGMPv1 Router Present ... is\n+ // the initial state.\n+ igmp.mode = protocolModeV2OrV3\nigmp.igmpV1Job = tcpip.NewJob(ep.protocol.stack.Clock(), &ep.mu, func() {\n- igmp.setV1Present(false)\n+ igmp.mode = protocolModeV2OrV3\n})\n}\n@@ -381,21 +417,15 @@ func (igmp *igmpState) handleIGMP(pkt stack.PacketBufferPtr, hasRouterAlertOptio\n}\n}\n-func (igmp *igmpState) v1Present() bool {\n- return igmp.igmpV1Present.Load() == 1\n-}\n-\n-func (igmp *igmpState) setV1Present(v bool) {\n- if v {\n- igmp.igmpV1Present.Store(1)\n- } else {\n- igmp.igmpV1Present.Store(0)\n- }\n-}\n-\nfunc (igmp *igmpState) resetV1Present() {\nigmp.igmpV1Job.Cancel()\n- igmp.setV1Present(false)\n+ switch igmp.mode {\n+ case protocolModeV2OrV3, protocolModeV1:\n+ case protocolModeV1Compatibility:\n+ igmp.mode = protocolModeV2OrV3\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n+ }\n}\n// handleMembershipQuery handles a membership query.\n@@ -406,9 +436,16 @@ func (igmp *igmpState) handleMembershipQuery(groupAddress tcpip.Address, maxResp\n// then change the state to note that an IGMPv1 router is present and\n// schedule the query received Job.\nif maxRespTime == 0 && igmp.Enabled() {\n+ switch igmp.mode {\n+ case protocolModeV2OrV3, protocolModeV1Compatibility:\nigmp.igmpV1Job.Cancel()\nigmp.igmpV1Job.Schedule(v1RouterPresentTimeout)\n- igmp.setV1Present(true)\n+ igmp.mode = protocolModeV1Compatibility\n+ case protocolModeV1:\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n+ }\n+\nmaxRespTime = v1MaxRespTime\n}\n@@ -556,7 +593,44 @@ func (igmp *igmpState) initializeAll() {\n// sendQueuedReports attempts to send any reports that are queued for sending.\n//\n-// +checklocksread:igmp.ep.mu\n+// +checklocks:igmp.ep.mu\nfunc (igmp *igmpState) sendQueuedReports() {\nigmp.genericMulticastProtocol.SendQueuedReportsLocked()\n}\n+\n+// setVersion sets the IGMP version.\n+//\n+// +checklocks:igmp.ep.mu\n+func (igmp *igmpState) setVersion(v IGMPVersion) IGMPVersion {\n+ prev := igmp.mode\n+ igmp.igmpV1Job.Cancel()\n+\n+ var prevGenericModeV1 bool\n+ switch v {\n+ case IGMPVersion3:\n+ prevGenericModeV1 = igmp.genericMulticastProtocol.SetV1ModeLocked(false)\n+ igmp.mode = protocolModeV2OrV3\n+ case IGMPVersion2:\n+ // IGMPv1 and IGMPv2 map to V1 of the generic multicast protocol.\n+ prevGenericModeV1 = igmp.genericMulticastProtocol.SetV1ModeLocked(true)\n+ igmp.mode = protocolModeV2OrV3\n+ case IGMPVersion1:\n+ // IGMPv1 and IGMPv2 map to V1 of the generic multicast protocol.\n+ prevGenericModeV1 = igmp.genericMulticastProtocol.SetV1ModeLocked(true)\n+ igmp.mode = protocolModeV1\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized version = %d\", v))\n+ }\n+\n+ switch prev {\n+ case protocolModeV2OrV3, protocolModeV1Compatibility:\n+ if prevGenericModeV1 {\n+ return IGMPVersion2\n+ }\n+ return IGMPVersion3\n+ case protocolModeV1:\n+ return IGMPVersion1\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/igmp_test.go",
"new_path": "pkg/tcpip/network/ipv4/igmp_test.go",
"diff": "@@ -43,7 +43,9 @@ var (\nremoteAddr = testutil.MustParse4(\"10.0.0.2\")\nmulticastAddr1 = testutil.MustParse4(\"224.0.0.3\")\nmulticastAddr2 = testutil.MustParse4(\"224.0.0.4\")\n- unusedMulticastAddr = testutil.MustParse4(\"224.0.0.5\")\n+ multicastAddr3 = testutil.MustParse4(\"224.0.0.5\")\n+ multicastAddr4 = testutil.MustParse4(\"224.0.0.6\")\n+ unusedMulticastAddr = testutil.MustParse4(\"224.0.0.7\")\n)\n// validateIgmpPacket checks that a passed packet is an IPv4 IGMP packet sent\n@@ -276,16 +278,17 @@ func TestSendQueuedIGMPReports(t *testing.T) {\ncheckVersion := func() {\nif test.v2Compatibility {\n- createAndInjectIGMPPacket(\n- e,\n- header.IGMPMembershipQuery,\n- 1, /* maxRespTime */\n- header.IGMPTTL,\n- remoteAddr,\n- header.IPv4AllSystems,\n- unusedMulticastAddr,\n- true, /* hasRouterAlertOption */\n- )\n+ ep, err := s.GetNetworkEndpoint(nicID, header.IPv4ProtocolNumber)\n+ if err != nil {\n+ t.Fatalf(\"s.GetNetworkEndpoint(%d, %d): %s\", nicID, header.IPv4ProtocolNumber, err)\n+ }\n+\n+ igmpEP, ok := ep.(ipv4.IGMPEndpoint)\n+ if !ok {\n+ t.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, igmpEP)\n+ }\n+\n+ igmpEP.SetIGMPVersion(ipv4.IGMPVersion2)\n}\n}\nprotocolAddr := tcpip.ProtocolAddress{\n@@ -505,3 +508,78 @@ func TestIGMPPacketValidation(t *testing.T) {\n})\n}\n}\n+\n+func TestSetIGMPVersion(t *testing.T) {\n+ const nicID = 1\n+\n+ c := newIGMPTestContext(t, true /* igmpEnabled */)\n+ defer c.cleanup()\n+ s := c.s\n+ e := c.ep\n+\n+ ep, err := s.GetNetworkEndpoint(nicID, header.IPv4ProtocolNumber)\n+ if err != nil {\n+ t.Fatalf(\"s.GetNetworkEndpoint(%d, %d): %s\", nicID, header.IPv4ProtocolNumber, err)\n+ }\n+ igmpEP, ok := ep.(ipv4.IGMPEndpoint)\n+ if !ok {\n+ t.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, igmpEP)\n+ }\n+\n+ protocolAddr := tcpip.ProtocolAddress{\n+ Protocol: ipv4.ProtocolNumber,\n+ AddressWithPrefix: tcpip.AddressWithPrefix{Address: stackAddr, PrefixLen: defaultPrefixLength},\n+ }\n+ if err := s.AddProtocolAddress(nicID, protocolAddr, stack.AddressProperties{}); err != nil {\n+ t.Fatalf(\"AddProtocolAddress(%d, %+v, {}): %s\", nicID, protocolAddr, err)\n+ }\n+\n+ if err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr1); err != nil {\n+ t.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr1, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateIgmpv3ReportPacket(t, p, stackAddr, multicastAddr1)\n+ p.DecRef()\n+ }\n+\n+ if got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion2); got != ipv4.IGMPVersion3 {\n+ t.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion2, got, ipv4.IGMPVersion3)\n+ }\n+ if err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr2); err != nil {\n+ t.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr2, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateIgmpPacket(t, p, header.IGMPv2MembershipReport, 0, stackAddr, multicastAddr2, multicastAddr2)\n+ p.DecRef()\n+ }\n+\n+ if got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion1); got != ipv4.IGMPVersion2 {\n+ t.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion1, got, ipv4.IGMPVersion2)\n+ }\n+ if err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr3); err != nil {\n+ t.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr3, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateIgmpPacket(t, p, header.IGMPv1MembershipReport, 0, stackAddr, multicastAddr3, multicastAddr3)\n+ p.DecRef()\n+ }\n+\n+ if got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion3); got != ipv4.IGMPVersion1 {\n+ t.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion3, got, ipv4.IGMPVersion1)\n+ }\n+ if err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr4); err != nil {\n+ t.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr4, err)\n+ }\n+ if p := e.Read(); p.IsNil() {\n+ t.Fatal(\"expected a report message to be sent\")\n+ } else {\n+ validateIgmpv3ReportPacket(t, p, stackAddr, multicastAddr4)\n+ p.DecRef()\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/ipv4.go",
"new_path": "pkg/tcpip/network/ipv4/ipv4.go",
"diff": "@@ -77,6 +77,7 @@ var _ stack.MulticastForwardingNetworkEndpoint = (*endpoint)(nil)\nvar _ stack.GroupAddressableEndpoint = (*endpoint)(nil)\nvar _ stack.AddressableEndpoint = (*endpoint)(nil)\nvar _ stack.NetworkEndpoint = (*endpoint)(nil)\n+var _ IGMPEndpoint = (*endpoint)(nil)\ntype endpoint struct {\nnic stack.NetworkInterface\n@@ -109,6 +110,19 @@ type endpoint struct {\nigmp igmpState\n}\n+// SetIGMPVersion implements IGMPEndpoint.\n+func (e *endpoint) SetIGMPVersion(v IGMPVersion) IGMPVersion {\n+ e.mu.Lock()\n+ defer e.mu.Unlock()\n+ return e.setIGMPVersionLocked(v)\n+}\n+\n+// +checklocks:e.mu\n+// +checklocksalias:e.igmp.ep.mu=e.mu\n+func (e *endpoint) setIGMPVersionLocked(v IGMPVersion) IGMPVersion {\n+ return e.igmp.setVersion(v)\n+}\n+\n// HandleLinkResolutionFailure implements stack.LinkResolvableNetworkEndpoint.\nfunc (e *endpoint) HandleLinkResolutionFailure(pkt stack.PacketBufferPtr) {\n// If we are operating as a router, return an ICMP error to the original\n"
}
] | Go | Apache License 2.0 | google/gvisor | Allow setting IGMP version
Updates #8346
PiperOrigin-RevId: 507927598 |
259,907 | 08.02.2023 09:32:08 | 28,800 | 6d4f68ec4f242facf6bb733708e2aaa4c0773dae | Consistently RetryEINTR(connect) in tcp_socket_test.
connect(2) can block and is susceptible to being interrupted by a signal.
This is to prevents flakes like | [
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/tcp_socket.cc",
"new_path": "test/syscalls/linux/tcp_socket.cc",
"diff": "@@ -196,10 +196,12 @@ TEST_P(TcpSocketTest, ConnectOnEstablishedConnection) {\nASSERT_NO_ERRNO_AND_VALUE(InetLoopbackAddr(GetParam()));\nsocklen_t addrlen = sizeof(addr);\n- ASSERT_THAT(connect(connected_.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ connected_.get(),\nreinterpret_cast<const struct sockaddr*>(&addr), addrlen),\nSyscallFailsWithErrno(EISCONN));\n- ASSERT_THAT(connect(accepted_.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ accepted_.get(),\nreinterpret_cast<const struct sockaddr*>(&addr), addrlen),\nSyscallFailsWithErrno(EISCONN));\n}\n@@ -1480,7 +1482,8 @@ TEST_P(SimpleTcpSocketTest, CleanupOnConnectionRefused) {\n// socket to return an error and clean itself up immediately.\n// The error being ECONNREFUSED diverges with RFC 793, page 37, but does what\n// Linux does.\n- ASSERT_THAT(connect(client_s.get(),\n+ ASSERT_THAT(\n+ RetryEINTR(connect)(client_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(ECONNREFUSED));\n@@ -1502,13 +1505,15 @@ TEST_P(SimpleTcpSocketTest, CleanupOnConnectionRefused) {\n// Linux actually sends a SYN again and gets a RST and correctly returns\n// ECONNREFUSED.\nif (IsRunningOnGvisor()) {\n- ASSERT_THAT(connect(client_s.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ client_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(ECONNABORTED));\nreturn;\n}\n- ASSERT_THAT(connect(client_s.get(),\n+ ASSERT_THAT(\n+ RetryEINTR(connect)(client_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(ECONNREFUSED));\n@@ -2175,14 +2180,16 @@ void ShutdownConnectingSocket(int domain, int shutdown_mode) {\n// connections will not get a SYN-ACK because the queue is full.\nFileDescriptor connected_s =\nASSERT_NO_ERRNO_AND_VALUE(Socket(domain, SOCK_STREAM, IPPROTO_TCP));\n- ASSERT_THAT(connect(connected_s.get(),\n+ ASSERT_THAT(\n+ RetryEINTR(connect)(connected_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallSucceeds());\nFileDescriptor connecting_s = ASSERT_NO_ERRNO_AND_VALUE(\nSocket(domain, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP));\n- ASSERT_THAT(connect(connecting_s.get(),\n+ ASSERT_THAT(\n+ RetryEINTR(connect)(connecting_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(EINPROGRESS));\n@@ -2270,7 +2277,8 @@ TEST_P(SimpleTcpSocketTest, OnlyAcknowledgeBacklogConnections) {\n// Establish a connection, but do not accept it.\nFileDescriptor connected_s = ASSERT_NO_ERRNO_AND_VALUE(\nSocket(GetParam(), SOCK_STREAM, IPPROTO_TCP));\n- ASSERT_THAT(connect(connected_s.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ connected_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallSucceeds());\n@@ -2279,7 +2287,8 @@ TEST_P(SimpleTcpSocketTest, OnlyAcknowledgeBacklogConnections) {\n// socket because this is expected to timeout.\nFileDescriptor connecting_s = ASSERT_NO_ERRNO_AND_VALUE(\nSocket(GetParam(), SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP));\n- ASSERT_THAT(connect(connecting_s.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ connecting_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(EINPROGRESS));\n@@ -2321,7 +2330,8 @@ TEST_P(SimpleTcpSocketTest, SynRcvdOnListenerShutdown) {\nfor (auto& thread : threads) {\nFileDescriptor connecting_s = ASSERT_NO_ERRNO_AND_VALUE(\nSocket(GetParam(), SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP));\n- ASSERT_THAT(connect(connecting_s.get(),\n+ ASSERT_THAT(RetryEINTR(connect)(\n+ connecting_s.get(),\nreinterpret_cast<const struct sockaddr*>(&bound_addr),\nbound_addrlen),\nSyscallFailsWithErrno(EINPROGRESS));\n"
}
] | Go | Apache License 2.0 | google/gvisor | Consistently RetryEINTR(connect) in tcp_socket_test.
connect(2) can block and is susceptible to being interrupted by a signal.
This is to prevents flakes like
https://buildkite.com/gvisor/pipeline/builds/19195#01862e07-a7b6-4a5e-8822-690512569abe.
PiperOrigin-RevId: 508102460 |
259,868 | 08.02.2023 10:43:58 | 28,800 | f08082fbd73bb39ead3b3d4519368d55a157e1de | runsc metric-server: Add flag to tolerate absence of `--root` directory. | [
{
"change_type": "MODIFY",
"old_path": "runsc/cmd/metric_server.go",
"new_path": "runsc/cmd/metric_server.go",
"diff": "@@ -231,6 +231,7 @@ func queryMetrics(ctx context.Context, sand *sandbox.Sandbox, verifier *promethe\n// MetricServer implements subcommands.Command for the \"metric-server\" command.\ntype MetricServer struct {\nrootDir string\n+ allowUnknownRoot bool\naddress string\nexporterPrefix string\nstartTime time.Time\n@@ -329,7 +330,9 @@ func (m *MetricServer) refreshSandboxesLocked() {\n}\nsandboxIDs, err := container.ListSandboxes(m.rootDir)\nif err != nil {\n+ if !m.allowUnknownRoot {\nlog.Warningf(\"Cannot list containers in root directory %s, it has likely gone away: %v.\", m.rootDir, err)\n+ }\nreturn\n}\nfor sandboxID, sandbox := range m.sandboxes {\n@@ -752,8 +755,10 @@ func (m *MetricServer) verify(ctx context.Context) {\nm.mu.Lock()\ndefer m.mu.Unlock()\nif err != nil {\n+ if !m.allowUnknownRoot {\nlog.Warningf(\"Cannot list sandboxes in root directory %s, it has likely gone away: %v. Server shutting down.\", m.rootDir, err)\nm.shutdownLocked(ctx)\n+ }\nreturn\n}\nm.refreshSandboxesLocked()\n@@ -797,15 +802,22 @@ func (m *MetricServer) Execute(ctx context.Context, f *flag.FlagSet, args ...any\nreturn util.Errorf(\"Metric server address contains '%%ID%%': %v. This should have been replaced by the parent process.\", conf.MetricServer)\n}\nif _, err := container.ListSandboxes(conf.RootDir); err != nil {\n+ if !conf.MetricServerAllowUnknownRoot {\nreturn util.Errorf(\"Invalid root directory %q: tried to list sandboxes within it and got: %v\", conf.RootDir, err)\n}\n+ log.Warningf(\"Invalid root directory %q: tried to list sandboxes within it and got: %v. Continuing anyway, as the server is configured to tolerate this.\", conf.RootDir, err)\n+ }\n// container.ListSandboxes uses a glob pattern, which doesn't error out on\n// permission errors. Double-check by actually listing the directory.\nif _, err := ioutil.ReadDir(conf.RootDir); err != nil {\n+ if !conf.MetricServerAllowUnknownRoot {\nreturn util.Errorf(\"Invalid root directory %q: tried to list all entries within it and got: %v\", conf.RootDir, err)\n}\n+ log.Warningf(\"Invalid root directory %q: tried to list all entries within it and got: %v. Continuing anyway, as the server is configured to tolerate this.\", conf.RootDir, err)\n+ }\nm.startTime = time.Now()\nm.rootDir = conf.RootDir\n+ m.allowUnknownRoot = conf.MetricServerAllowUnknownRoot\nm.exporterPrefix = conf.MetricExporterPrefix\nif strings.Contains(conf.MetricServer, \"%RUNTIME_ROOT%\") {\nnewAddr := strings.ReplaceAll(conf.MetricServer, \"%RUNTIME_ROOT%\", m.rootDir)\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/config/config.go",
"new_path": "runsc/config/config.go",
"diff": "@@ -152,6 +152,12 @@ type Config struct {\n// The value of this flag must also match across the two command lines.\nMetricServer string `flag:\"metric-server\"`\n+ // MetricServerAllowUnknownRoot, if set, makes the metric server tolerate a non-existent or bad\n+ // --root directory, and will remain running regardless of its validity.\n+ // This is useful if the existence of the --root directory depends on the state of the machine,\n+ // e.g. it is only created after the first pod that uses runsc has been created.\n+ MetricServerAllowUnknownRoot bool `flag:\"metric-server-allow-unknown-root\"`\n+\n// MetricExporterPrefix is added as prefix to all metric names.\n// It is used to follow Prometheus's exporter convention, whereby all metric names should be\n// prefixed by a name meaningfully identifying the software exporting the metric.\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/config/flags.go",
"new_path": "runsc/config/flags.go",
"diff": "@@ -53,6 +53,7 @@ func RegisterFlags(flagSet *flag.FlagSet) {\n// Metrics flags.\nflagSet.String(\"metric-server\", \"\", \"if set, export metrics on this address. This may either be 1) 'addr:port' to export metrics on a specific network interface address, 2) ':port' for exporting metrics on all interfaces, or 3) an absolute path to a Unix Domain Socket. The substring '%ID%' will be replaced by the container ID, and '%RUNTIME_ROOT%' by the root. This flag must be specified in both `runsc metric-server` and `runsc create`, and their values must match.\")\n+ flagSet.Bool(\"metric-server-allow-unknown-root\", false, \"if set, the metric server will keep running regardless of the existence of --root or the metric server's ability to access it.\")\nflagSet.String(\"metric-exporter-prefix\", \"runsc_\", \"prefix for all metric names, following Prometheus exporter convention\")\n// Debugging flags: strace related\n"
},
{
"change_type": "MODIFY",
"old_path": "runsc/container/metric_server_test.go",
"new_path": "runsc/container/metric_server_test.go",
"diff": "@@ -54,7 +54,7 @@ type metricsTest struct {\n// setupMetrics sets up a container configuration with metrics enabled, and returns it all.\n// Also returns a cleanup function.\n-func setupMetrics(t *testing.T) (*metricsTest, func()) {\n+func setupMetrics(t *testing.T, forceTempUDS bool) (*metricsTest, func()) {\n// Start the child reaper.\nchildReaper := &testutil.Reaper{}\nchildReaper.Start()\n@@ -73,21 +73,19 @@ func setupMetrics(t *testing.T) (*metricsTest, func()) {\nt.Fatalf(\"error setting up container: %v\", err)\n}\ncu.Add(cleanup)\n- udsPath := filepath.Join(rootDir, \"metrics.sock\")\n- if len(udsPath) >= 100 {\n- // This is longer than the max UDS path length allowed by Linux. Try somewhere else in /tmp.\ntmpDir, err := os.MkdirTemp(\"/tmp\", \"metrics-\")\nif err != nil {\n- t.Fatalf(\"Runtime root is %s which means the metrics UDS %s (%d bytes) is longer than the maximum length allowed for a UDS path. The test could also not create a temporary directory in /tmp as a fallback (%v).\", rootDir, udsPath, len(udsPath), err)\n+ t.Fatalf(\"Cannot create temporary directory in /tmp: %v\", err)\n}\ncu.Add(func() { os.RemoveAll(tmpDir) })\n- udsPathTmp := filepath.Join(tmpDir, \"metrics.sock\")\n- if len(udsPathTmp) >= 100 {\n- t.Fatalf(\"Runtime root is %s which means the metrics UDS %s (%d bytes) is longer than the maximum length allowed for a UDS path. The test tried to create a fallback in /tmp but it was too long too (%q is %d characters).\", rootDir, udsPath, len(udsPath), udsPathTmp, len(udsPathTmp))\n+ udsPath := filepath.Join(rootDir, \"metrics.sock\")\n+ if forceTempUDS || len(udsPath) >= 100 {\n+ udsPath = filepath.Join(tmpDir, \"metrics.sock\")\n}\n- udsPath = udsPathTmp\n- conf.MetricServer = udsPathTmp\n+ if len(udsPath) >= 100 {\n+ t.Fatalf(\"Cannot come up with a UDS path shorter than the maximum length allowed by Linux (tried to use %q)\", udsPath)\n}\n+ conf.MetricServer = udsPath\n// The UDS should be deleted by the metrics server itself, but we clean it up here anyway just in case:\ncu.Add(func() { os.Remove(udsPath) })\n@@ -112,7 +110,7 @@ func setupMetrics(t *testing.T) (*metricsTest, func()) {\nfunc TestContainerMetrics(t *testing.T) {\ntargetOpens := 200\n- te, cleanup := setupMetrics(t)\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, false)\ndefer cleanup()\nif _, err := te.client.GetMetrics(te.testCtx); err != nil {\n@@ -202,7 +200,7 @@ func TestContainerMetrics(t *testing.T) {\n// TestContainerMetricsIterationID verifies that two successive containers with the same ID\n// do not have the same iteration ID.\nfunc TestContainerMetricsIterationID(t *testing.T) {\n- te, cleanup := setupMetrics(t)\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, false)\ndefer cleanup()\nargs := Args{\n@@ -264,7 +262,7 @@ func TestContainerMetricsIterationID(t *testing.T) {\n// unavailability or restarts.\nfunc TestContainerMetricsRobustAgainstRestarts(t *testing.T) {\ntargetOpens := 200\n- te, cleanup := setupMetrics(t)\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, false)\ndefer cleanup()\n// First, start a container which will kick off the metric server as normal.\n@@ -414,7 +412,7 @@ func TestContainerMetricsRobustAgainstRestarts(t *testing.T) {\nfunc TestContainerMetricsMultiple(t *testing.T) {\nnumConcurrentContainers := 5\n- te, cleanup := setupMetrics(t)\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, false)\ndefer cleanup()\nvar containers []*Container\nneedCleanup := map[*Container]struct{}{}\n@@ -517,7 +515,7 @@ func TestContainerMetricsMultiple(t *testing.T) {\n}\nfunc TestMetricServerChecksRootDirectoryAccess(t *testing.T) {\n- te, cleanup := setupMetrics(t)\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, false)\ndefer cleanup()\nif err := te.client.ShutdownServer(te.testCtx); err != nil {\nt.Fatalf(\"Cannot stop metric server: %v\", err)\n@@ -540,3 +538,24 @@ func TestMetricServerChecksRootDirectoryAccess(t *testing.T) {\nt.Error(\"Metric server was successfully able to be spawned despite not having access to the root directory\")\n}\n}\n+\n+func TestMetricServerToleratesNoRootDirectory(t *testing.T) {\n+ te, cleanup := setupMetrics(t /* forceTempUDS= */, true)\n+ defer cleanup()\n+ if err := te.client.ShutdownServer(te.testCtx); err != nil {\n+ t.Fatalf(\"Cannot stop metric server: %v\", err)\n+ }\n+ if err := os.RemoveAll(te.sleepConf.RootDir); err != nil {\n+ t.Fatalf(\"cannot remove root directory %q: %v\", te.sleepConf.RootDir, err)\n+ }\n+ te.sleepConf.MetricServerAllowUnknownRoot = false\n+ shortCtx, shortCtxCancel := context.WithTimeout(te.testCtx, time.Second)\n+ defer shortCtxCancel()\n+ if err := te.client.SpawnServer(shortCtx, te.sleepConf); err == nil {\n+ t.Fatalf(\"Metric server was successfully able to be spawned despite a non-existent root directory\")\n+ }\n+ te.sleepConf.MetricServerAllowUnknownRoot = true\n+ if err := te.client.SpawnServer(te.testCtx, te.sleepConf); err != nil {\n+ t.Errorf(\"Metric server was not able to be spawned despite being configured to tolerate a non-existent root directory: %v\", err)\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/metricclient/BUILD",
"new_path": "test/metricclient/BUILD",
"diff": "@@ -12,6 +12,7 @@ go_library(\n\"//runsc:__subpackages__\",\n],\ndeps = [\n+ \"//pkg/cleanup\",\n\"//pkg/prometheus\",\n\"//pkg/sync\",\n\"//runsc/config\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/metricclient/metricclient.go",
"new_path": "test/metricclient/metricclient.go",
"diff": "@@ -34,6 +34,7 @@ import (\n\"github.com/cenkalti/backoff\"\n\"github.com/prometheus/common/expfmt\"\n\"golang.org/x/sys/unix\"\n+ \"gvisor.dev/gvisor/pkg/cleanup\"\n\"gvisor.dev/gvisor/pkg/prometheus\"\n\"gvisor.dev/gvisor/pkg/sync\"\n\"gvisor.dev/gvisor/runsc/config\"\n@@ -187,6 +188,10 @@ func (c *MetricClient) SpawnServer(ctx context.Context, baseConf *config.Config)\noverriddenConf.MetricServer = c.addr\noverriddenConf.RootDir = c.rootDir\nc.server = exec.Command(specutils.ExePath, overriddenConf.ToFlags()...)\n+ cu := cleanup.Make(func() {\n+ c.server = nil\n+ })\n+ defer cu.Clean()\nc.server.SysProcAttr = &unix.SysProcAttr{\n// Detach from this session, otherwise cmd will get SIGHUP and SIGCONT\n// when re-parented.\n@@ -221,6 +226,7 @@ func (c *MetricClient) SpawnServer(ctx context.Context, baseConf *config.Config)\nif bindCtx.Err() != nil {\nreturn fmt.Errorf(\"metrics server did not bind to %s in time: %w\", c.addr, bindCtx.Err())\n}\n+ cu.Release()\nreturn nil\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | runsc metric-server: Add flag to tolerate absence of `--root` directory.
PiperOrigin-RevId: 508122696 |
260,004 | 08.02.2023 16:46:07 | 28,800 | a5ac059e279b602ad42caeb4c48d09cb566e6eba | Return current IGMP/MLD version
Updates | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"diff": "@@ -292,38 +292,45 @@ type GenericMulticastProtocolState struct {\nstateChangedReportV2TimerSet bool\n}\n+// GetV1ModeLocked returns the V1 configuration.\n+//\n+// Precondition: g.protocolMU must be read locked.\n+func (g *GenericMulticastProtocolState) GetV1ModeLocked() bool {\n+ switch g.mode {\n+ case protocolModeV2, protocolModeV1Compatibility:\n+ return false\n+ case protocolModeV1:\n+ return true\n+ default:\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n+ }\n+}\n+\n+func (g *GenericMulticastProtocolState) stopModeTimer() {\n+ if g.modeTimer != nil {\n+ g.modeTimer.Stop()\n+ }\n+}\n+\n// SetV1ModeLocked sets the V1 configuration.\n//\n// Returns the previous configuration.\n//\n// Precondition: g.protocolMU must be locked.\nfunc (g *GenericMulticastProtocolState) SetV1ModeLocked(v bool) bool {\n+ if g.GetV1ModeLocked() == v {\n+ return v\n+ }\n+\nif v {\n- switch g.mode {\n- case protocolModeV2:\n+ g.stopModeTimer()\ng.cancelV2ReportTimers()\n- case protocolModeV1Compatibility:\n- g.modeTimer.Stop()\n- case protocolModeV1:\n- // Already in V1 mode; nothing to do.\n- return true\n- default:\n- panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n- }\ng.mode = protocolModeV1\nreturn false\n}\n- switch g.mode {\n- case protocolModeV2, protocolModeV1Compatibility:\n- // Not in V1 mode; nothing to do.\n- return false\n- case protocolModeV1:\ng.mode = protocolModeV2\nreturn true\n- default:\n- panic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n- }\n}\nfunc (g *GenericMulticastProtocolState) cancelV2ReportTimers() {\n@@ -375,9 +382,7 @@ func (g *GenericMulticastProtocolState) MakeAllNonMemberLocked() {\nreturn\n}\n- if g.modeTimer != nil {\n- g.modeTimer.Stop()\n- }\n+ g.stopModeTimer()\ng.cancelV2ReportTimers()\nvar v2ReportBuilder MulticastGroupProtocolV2ReportBuilder\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"diff": "@@ -88,6 +88,12 @@ func (m *mockMulticastGroupProtocol) setV1Mode(v bool) bool {\nreturn m.mu.genericMulticastGroup.SetV1ModeLocked(v)\n}\n+func (m *mockMulticastGroupProtocol) getV1Mode() bool {\n+ m.mu.RLock()\n+ defer m.mu.RUnlock()\n+ return m.mu.genericMulticastGroup.GetV1ModeLocked()\n+}\n+\nfunc (m *mockMulticastGroupProtocol) joinGroup(addr tcpip.Address) {\nm.mu.Lock()\ndefer m.mu.Unlock()\n@@ -1506,7 +1512,7 @@ func TestQueuedPackets(t *testing.T) {\n}\n}\n-func TestSetV1Mode(t *testing.T) {\n+func TestGetSetV1Mode(t *testing.T) {\nclock := faketime.NewManualClock()\nmgp := mockMulticastGroupProtocol{t: t}\nmgp.init(ip.GenericMulticastProtocolOptions{\n@@ -1515,6 +1521,10 @@ func TestSetV1Mode(t *testing.T) {\nMaxUnsolicitedReportDelay: maxUnsolicitedReportDelay,\n}, false /* v1Compatibility */)\n+ if mgp.getV1Mode() {\n+ t.Error(\"got mgp.getV1Mode() = true, want = false\")\n+ }\n+\nmgp.joinGroup(addr1)\nif diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{\n{\n@@ -1528,6 +1538,9 @@ func TestSetV1Mode(t *testing.T) {\nif mgp.setV1Mode(true) {\nt.Error(\"got mgp.setV1Mode(true) = true, want = false\")\n}\n+ if !mgp.getV1Mode() {\n+ t.Error(\"got mgp.getV1Mode() = false, want = true\")\n+ }\nmgp.joinGroup(addr2)\nif diff := mgp.check(checkFields{sendReportGroupAddresses: []tcpip.Address{addr2}}); diff != \"\" {\nt.Fatalf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n@@ -1536,6 +1549,9 @@ func TestSetV1Mode(t *testing.T) {\nif !mgp.setV1Mode(false) {\nt.Error(\"got mgp.setV1Mode(false) = false, want = true\")\n}\n+ if mgp.getV1Mode() {\n+ t.Error(\"got mgp.getV1Mode() = true, want = false\")\n+ }\nmgp.joinGroup(addr3)\nif diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/igmp.go",
"new_path": "pkg/tcpip/network/ipv4/igmp.go",
"diff": "@@ -80,10 +80,13 @@ const (\n// IGMPEndpoint is a network endpoint that supports IGMP.\ntype IGMPEndpoint interface {\n- // Sets the IGMP version.\n+ // SetIGMPVersion sets the IGMP version.\n//\n// Returns the previous IGMP version.\nSetIGMPVersion(IGMPVersion) IGMPVersion\n+\n+ // GetIGMPVersion returns the IGMP version.\n+ GetIGMPVersion() IGMPVersion\n}\n// IGMPOptions holds options for IGMP.\n@@ -622,15 +625,26 @@ func (igmp *igmpState) setVersion(v IGMPVersion) IGMPVersion {\npanic(fmt.Sprintf(\"unrecognized version = %d\", v))\n}\n- switch prev {\n+ return toIGMPVersion(prev, prevGenericModeV1)\n+}\n+\n+func toIGMPVersion(mode protocolMode, genericV1 bool) IGMPVersion {\n+ switch mode {\ncase protocolModeV2OrV3, protocolModeV1Compatibility:\n- if prevGenericModeV1 {\n+ if genericV1 {\nreturn IGMPVersion2\n}\nreturn IGMPVersion3\ncase protocolModeV1:\nreturn IGMPVersion1\ndefault:\n- panic(fmt.Sprintf(\"unrecognized mode = %d\", igmp.mode))\n+ panic(fmt.Sprintf(\"unrecognized mode = %d\", mode))\n}\n}\n+\n+// getVersion returns the IGMP version.\n+//\n+// +checklocksread:igmp.ep.mu\n+func (igmp *igmpState) getVersion() IGMPVersion {\n+ return toIGMPVersion(igmp.mode, igmp.genericMulticastProtocol.GetV1ModeLocked())\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/igmp_test.go",
"new_path": "pkg/tcpip/network/ipv4/igmp_test.go",
"diff": "@@ -509,7 +509,7 @@ func TestIGMPPacketValidation(t *testing.T) {\n}\n}\n-func TestSetIGMPVersion(t *testing.T) {\n+func TestGetSetIGMPVersion(t *testing.T) {\nconst nicID = 1\nc := newIGMPTestContext(t, true /* igmpEnabled */)\n@@ -525,6 +525,9 @@ func TestSetIGMPVersion(t *testing.T) {\nif !ok {\nt.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, igmpEP)\n}\n+ if got := igmpEP.GetIGMPVersion(); got != ipv4.IGMPVersion3 {\n+ t.Errorf(\"got igmpEP.GetIGMPVersion() = %d, want = %d\", got, ipv4.IGMPVersion3)\n+ }\nprotocolAddr := tcpip.ProtocolAddress{\nProtocol: ipv4.ProtocolNumber,\n@@ -547,6 +550,9 @@ func TestSetIGMPVersion(t *testing.T) {\nif got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion2); got != ipv4.IGMPVersion3 {\nt.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion2, got, ipv4.IGMPVersion3)\n}\n+ if got := igmpEP.GetIGMPVersion(); got != ipv4.IGMPVersion2 {\n+ t.Errorf(\"got igmpEP.GetIGMPVersion() = %d, want = %d\", got, ipv4.IGMPVersion2)\n+ }\nif err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr2); err != nil {\nt.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr2, err)\n}\n@@ -560,6 +566,9 @@ func TestSetIGMPVersion(t *testing.T) {\nif got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion1); got != ipv4.IGMPVersion2 {\nt.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion1, got, ipv4.IGMPVersion2)\n}\n+ if got := igmpEP.GetIGMPVersion(); got != ipv4.IGMPVersion1 {\n+ t.Errorf(\"got igmpEP.GetIGMPVersion() = %d, want = %d\", got, ipv4.IGMPVersion1)\n+ }\nif err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr3); err != nil {\nt.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr3, err)\n}\n@@ -573,6 +582,9 @@ func TestSetIGMPVersion(t *testing.T) {\nif got := igmpEP.SetIGMPVersion(ipv4.IGMPVersion3); got != ipv4.IGMPVersion1 {\nt.Errorf(\"got igmpEP.SetIGMPVersion(%d) = %d, want = %d\", ipv4.IGMPVersion3, got, ipv4.IGMPVersion1)\n}\n+ if got := igmpEP.GetIGMPVersion(); got != ipv4.IGMPVersion3 {\n+ t.Errorf(\"got igmpEP.GetIGMPVersion() = %d, want = %d\", got, ipv4.IGMPVersion3)\n+ }\nif err := s.JoinGroup(ipv4.ProtocolNumber, nicID, multicastAddr4); err != nil {\nt.Fatalf(\"JoinGroup(ipv4, nic, %s) = %s\", multicastAddr4, err)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv4/ipv4.go",
"new_path": "pkg/tcpip/network/ipv4/ipv4.go",
"diff": "@@ -117,12 +117,25 @@ func (e *endpoint) SetIGMPVersion(v IGMPVersion) IGMPVersion {\nreturn e.setIGMPVersionLocked(v)\n}\n+// GetIGMPVersion implements IGMPEndpoint.\n+func (e *endpoint) GetIGMPVersion() IGMPVersion {\n+ e.mu.RLock()\n+ defer e.mu.RUnlock()\n+ return e.getIGMPVersionLocked()\n+}\n+\n// +checklocks:e.mu\n// +checklocksalias:e.igmp.ep.mu=e.mu\nfunc (e *endpoint) setIGMPVersionLocked(v IGMPVersion) IGMPVersion {\nreturn e.igmp.setVersion(v)\n}\n+// +checklocksread:e.mu\n+// +checklocksalias:e.igmp.ep.mu=e.mu\n+func (e *endpoint) getIGMPVersionLocked() IGMPVersion {\n+ return e.igmp.getVersion()\n+}\n+\n// HandleLinkResolutionFailure implements stack.LinkResolvableNetworkEndpoint.\nfunc (e *endpoint) HandleLinkResolutionFailure(pkt stack.PacketBufferPtr) {\n// If we are operating as a router, return an ICMP error to the original\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/ipv6.go",
"new_path": "pkg/tcpip/network/ipv6/ipv6.go",
"diff": "@@ -364,6 +364,13 @@ func (e *endpoint) SetMLDVersion(v MLDVersion) MLDVersion {\nreturn e.mu.mld.setVersion(v)\n}\n+// GetMLDVersion implements MLDEndpoint.\n+func (e *endpoint) GetMLDVersion() MLDVersion {\n+ e.mu.RLock()\n+ defer e.mu.RUnlock()\n+ return e.mu.mld.getVersion()\n+}\n+\n// SetNDPConfigurations implements NDPEndpoint.\nfunc (e *endpoint) SetNDPConfigurations(c NDPConfigurations) {\nc.validate()\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/mld.go",
"new_path": "pkg/tcpip/network/ipv6/mld.go",
"diff": "@@ -47,10 +47,13 @@ const (\n// MLDEndpoint is a network endpoint that supports MLD.\ntype MLDEndpoint interface {\n- // Sets the MLD version.\n+ // SetMLDVersions sets the MLD version.\n//\n// Returns the previous MLD version.\nSetMLDVersion(MLDVersion) MLDVersion\n+\n+ // GetMLDVersion returns the MLD version.\n+ GetMLDVersion() MLDVersion\n}\n// MLDOptions holds options for MLD.\n@@ -334,12 +337,23 @@ func (mld *mldState) setVersion(v MLDVersion) MLDVersion {\npanic(fmt.Sprintf(\"unrecognized version = %d\", v))\n}\n- if prev {\n+ return toMLDVersion(prev)\n+}\n+\n+func toMLDVersion(v1Generic bool) MLDVersion {\n+ if v1Generic {\nreturn MLDVersion1\n}\nreturn MLDVersion2\n}\n+// getVersion returns the MLD version.\n+//\n+// Precondition: mld.ep.mu must be read locked.\n+func (mld *mldState) getVersion() MLDVersion {\n+ return toMLDVersion(mld.genericMulticastProtocol.GetV1ModeLocked())\n+}\n+\n// writePacket assembles and sends an MLD packet.\n//\n// Precondition: mld.ep.mu must be read locked.\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/ipv6/mld_test.go",
"new_path": "pkg/tcpip/network/ipv6/mld_test.go",
"diff": "@@ -759,7 +759,7 @@ func TestMLDSkipProtocol(t *testing.T) {\n}\n}\n-func TestSetMLDVersion(t *testing.T) {\n+func TestGetSetMLDVersion(t *testing.T) {\nconst nicID = 1\nc := newMLDTestContext()\n@@ -781,6 +781,9 @@ func TestSetMLDVersion(t *testing.T) {\nif !ok {\nt.Fatalf(\"got (%T).(%T) = (_, false), want = (_ true)\", ep, mldEP)\n}\n+ if got := mldEP.GetMLDVersion(); got != ipv6.MLDVersion2 {\n+ t.Errorf(\"got mldEP.GetMLDVersion() = %d, want = %d\", got, ipv6.MLDVersion2)\n+ }\nprotocolAddr := tcpip.ProtocolAddress{\nProtocol: ipv6.ProtocolNumber,\n@@ -799,6 +802,9 @@ func TestSetMLDVersion(t *testing.T) {\nif got := mldEP.SetMLDVersion(ipv6.MLDVersion1); got != ipv6.MLDVersion2 {\nt.Errorf(\"got mldEP.SetMLDVersion(%d) = %d, want = %d\", ipv6.MLDVersion1, got, ipv6.MLDVersion2)\n}\n+ if got := mldEP.GetMLDVersion(); got != ipv6.MLDVersion1 {\n+ t.Errorf(\"got mldEP.GetMLDVersion() = %d, want = %d\", got, ipv6.MLDVersion1)\n+ }\nif err := s.JoinGroup(ipv6.ProtocolNumber, nicID, globalMulticastAddr); err != nil {\nt.Fatalf(\"s.JoinGroup(%d, %d, %s): %s\", ipv6.ProtocolNumber, nicID, globalMulticastAddr, err)\n}\n@@ -812,6 +818,9 @@ func TestSetMLDVersion(t *testing.T) {\nif got := mldEP.SetMLDVersion(ipv6.MLDVersion2); got != ipv6.MLDVersion1 {\nt.Errorf(\"got mldEP.SetMLDVersion(%d) = %d, want = %d\", ipv6.MLDVersion2, got, ipv6.MLDVersion1)\n}\n+ if got := mldEP.GetMLDVersion(); got != ipv6.MLDVersion2 {\n+ t.Errorf(\"got mldEP.GetMLDVersion() = %d, want = %d\", got, ipv6.MLDVersion2)\n+ }\nif err := s.LeaveGroup(ipv6.ProtocolNumber, nicID, globalMulticastAddr); err != nil {\nt.Fatalf(\"s.LeaveGroup(%d, %d, %s): %s\", ipv6.ProtocolNumber, nicID, globalMulticastAddr, err)\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | Return current IGMP/MLD version
Updates #8346
PiperOrigin-RevId: 508218820 |
259,853 | 08.02.2023 23:58:37 | 28,800 | 60bae95f0ade4004e6fa14eda956bbae78d96679 | test: address comments from cl/504951567 | [
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/BUILD",
"new_path": "test/syscalls/linux/BUILD",
"diff": "@@ -2140,6 +2140,7 @@ cc_binary(\n\"//test/util:test_main\",\n\"//test/util:test_util\",\n\"//test/util:thread_util\",\n+ \"@com_google_absl//absl/algorithm:container\",\n\"@com_google_absl//absl/strings\",\n],\n)\n@@ -4143,6 +4144,7 @@ cc_binary(\nlinkstatic = 1,\ndeps = [\n\"//test/util:fs_util\",\n+ \"@com_google_absl//absl/algorithm:container\",\ngtest,\n\"//test/util:posix_error\",\n\"//test/util:proc_util\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/rlimits.cc",
"new_path": "test/syscalls/linux/rlimits.cc",
"diff": "#include <string>\n#include <vector>\n+#include \"absl/algorithm/container.h\"\n#include \"absl/strings/numbers.h\"\n#include \"absl/strings/str_split.h\"\n#include \"test/util/capability_util.h\"\n@@ -41,12 +42,12 @@ PosixErrorOr<ProcLimitsEntry> GetProcLimitEntryByType(LimitType limit_type) {\nASSIGN_OR_RETURN_ERRNO(std::string proc_self_limits,\nGetContents(\"/proc/self/limits\"));\nASSIGN_OR_RETURN_ERRNO(auto entries, ParseProcLimits(proc_self_limits));\n- auto it = std::find_if(entries.begin(), entries.end(),\n- [limit_type](const ProcLimitsEntry& v) {\n+ auto it = absl::c_find_if(entries, [limit_type](const ProcLimitsEntry& v) {\nreturn v.limit_type == limit_type;\n});\nif (it == entries.end()) {\n- return PosixError(ENOENT, \"limit type not found\");\n+ return PosixError(ENOENT, absl::StrFormat(\"limit type \\\"%s\\\" not found\",\n+ LimitTypeToString(limit_type)));\n}\nreturn *it;\n}\n@@ -65,7 +66,7 @@ TEST(RlimitTest, SetRlimitHigher) {\n// Now verify we can read the changed values via /proc/self/limits\nconst ProcLimitsEntry limit_entry = ASSERT_NO_ERRNO_AND_VALUE(\n- GetProcLimitEntryByType(LimitType::NumberOfFiles));\n+ GetProcLimitEntryByType(LimitType::kNumberOfFiles));\nEXPECT_EQ(rl.rlim_cur, limit_entry.cur_limit);\nEXPECT_EQ(rl.rlim_max, limit_entry.max_limit);\n@@ -154,6 +155,13 @@ TEST(RlimitTest, RlimitNProc) {\n}).Join();\n}\n+TEST(RlimitTest, ParseProcPidLimits) {\n+ auto proc_self_limits =\n+ ASSERT_NO_ERRNO_AND_VALUE(GetContents(\"/proc/self/limits\"));\n+ auto entries = ASSERT_NO_ERRNO_AND_VALUE(ParseProcLimits(proc_self_limits));\n+ EXPECT_EQ(entries.size(), LimitTypes.size());\n+}\n+\n} // namespace\n} // namespace testing\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/vdso.cc",
"new_path": "test/syscalls/linux/vdso.cc",
"diff": "#include <algorithm>\n#include \"gtest/gtest.h\"\n+#include \"absl/algorithm/container.h\"\n#include \"test/util/fs_util.h\"\n#include \"test/util/posix_error.h\"\n#include \"test/util/proc_util.h\"\n@@ -32,9 +33,8 @@ namespace {\nTEST(VvarTest, WriteVvar) {\nauto contents = ASSERT_NO_ERRNO_AND_VALUE(GetContents(\"/proc/self/maps\"));\nauto maps = ASSERT_NO_ERRNO_AND_VALUE(ParseProcMaps(contents));\n- auto it = std::find_if(maps.begin(), maps.end(), [](const ProcMapsEntry& e) {\n- return e.filename == \"[vvar]\";\n- });\n+ auto it = absl::c_find_if(\n+ maps, [](const ProcMapsEntry& e) { return e.filename == \"[vvar]\"; });\nSKIP_IF(it == maps.end());\nEXPECT_THAT(mprotect(reinterpret_cast<void*>(it->start), kPageSize,\n"
},
{
"change_type": "MODIFY",
"old_path": "test/util/BUILD",
"new_path": "test/util/BUILD",
"diff": "@@ -82,6 +82,7 @@ cc_library(\n\":fs_util\",\n\":posix_error\",\n\":test_util\",\n+ \"@com_google_absl//absl/algorithm:container\",\n\"@com_google_absl//absl/container:flat_hash_set\",\n\"@com_google_absl//absl/strings\",\n\"@com_google_absl//absl/types:optional\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/util/proc_util.cc",
"new_path": "test/util/proc_util.cc",
"diff": "#include <iostream>\n#include <vector>\n+#include \"absl/algorithm/container.h\"\n#include \"absl/container/flat_hash_set.h\"\n#include \"absl/strings/ascii.h\"\n#include \"absl/strings/str_cat.h\"\n@@ -284,7 +285,7 @@ PosixErrorOr<ProcSmapsEntry> FindUniqueSmapsEntry(\nauto const pred = [&](ProcSmapsEntry const& entry) {\nreturn entry.maps_entry.start <= addr && addr < entry.maps_entry.end;\n};\n- auto const it = std::find_if(entries.begin(), entries.end(), pred);\n+ auto const it = absl::c_find_if(entries, pred);\nif (it == entries.end()) {\nreturn PosixError(EINVAL,\nabsl::StrFormat(\"no entry contains address %#x\", addr));\n@@ -331,6 +332,45 @@ bool IsTHPDisabled() {\nreturn StackTHPDisabled(maps.ValueOrDie());\n}\n+std::string LimitTypeToString(LimitType type) {\n+ switch (type) {\n+ case LimitType::kCPU:\n+ return \"cpu time\";\n+ case LimitType::kFileSize:\n+ return \"file size\";\n+ case LimitType::kData:\n+ return \"data size\";\n+ case LimitType::kStack:\n+ return \"stack size\";\n+ case LimitType::kCore:\n+ return \"core file size\";\n+ case LimitType::kRSS:\n+ return \"resident set\";\n+ case LimitType::kProcessCount:\n+ return \"processes\";\n+ case LimitType::kNumberOfFiles:\n+ return \"open files\";\n+ case LimitType::kMemoryLocked:\n+ return \"locked memory\";\n+ case LimitType::kAS:\n+ return \"address space\";\n+ case LimitType::kLocks:\n+ return \"file locks\";\n+ case LimitType::kSignalsPending:\n+ return \"pending signals\";\n+ case LimitType::kMessageQueueBytes:\n+ return \"msgqueue size\";\n+ case LimitType::kNice:\n+ return \"nice priority\";\n+ case LimitType::kRealTimePriority:\n+ return \"realtime priority\";\n+ case LimitType::kRttime:\n+ return \"realtime timeout\";\n+ default:\n+ return \"unknown\";\n+ }\n+}\n+\nPosixErrorOr<ProcLimitsEntry> ParseProcLimitsLine(absl::string_view line) {\nProcLimitsEntry limits_entry = {};\n@@ -348,41 +388,13 @@ PosixErrorOr<ProcLimitsEntry> ParseProcLimitsLine(absl::string_view line) {\n// parse the limit type\nauto limitType = line.substr(0, 25);\n- if (absl::StrContains(limitType, \"cpu time\")) {\n- limits_entry.limit_type = LimitType::CPU;\n- } else if (absl::StrContains(limitType, \"file size\")) {\n- limits_entry.limit_type = LimitType::FileSize;\n- } else if (absl::StrContains(limitType, \"data size\")) {\n- limits_entry.limit_type = LimitType::Data;\n- } else if (absl::StrContains(limitType, \"stack size\")) {\n- limits_entry.limit_type = LimitType::Stack;\n- } else if (absl::StrContains(limitType, \"core file size\")) {\n- limits_entry.limit_type = LimitType::Core;\n- } else if (absl::StrContains(limitType, \"resident set\")) {\n- limits_entry.limit_type = LimitType::RSS;\n- } else if (absl::StrContains(limitType, \"processes\")) {\n- limits_entry.limit_type = LimitType::ProcessCount;\n- } else if (absl::StrContains(limitType, \"open files\")) {\n- limits_entry.limit_type = LimitType::NumberOfFiles;\n- } else if (absl::StrContains(limitType, \"locked memory\")) {\n- limits_entry.limit_type = LimitType::MemoryLocked;\n- } else if (absl::StrContains(limitType, \"address space\")) {\n- limits_entry.limit_type = LimitType::AS;\n- } else if (absl::StrContains(limitType, \"file locks\")) {\n- limits_entry.limit_type = LimitType::Locks;\n- } else if (absl::StrContains(limitType, \"pending signals\")) {\n- limits_entry.limit_type = LimitType::SignalsPending;\n- } else if (absl::StrContains(limitType, \"msgqueue size\")) {\n- limits_entry.limit_type = LimitType::MessageQueueBytes;\n- } else if (absl::StrContains(limitType, \"nice priority\")) {\n- limits_entry.limit_type = LimitType::Nice;\n- } else if (absl::StrContains(limitType, \"realtime priority\")) {\n- limits_entry.limit_type = LimitType::RealTimePriority;\n- } else if (absl::StrContains(limitType, \"realtime timeout\")) {\n- limits_entry.limit_type = LimitType::Rttime;\n- } else {\n+ auto it = absl::c_find_if(LimitTypes, [&limitType](LimitType t) {\n+ return absl::StrContains(limitType, LimitTypeToString(t));\n+ });\n+ if (it == LimitTypes.end()) {\nreturn PosixError(EINVAL, absl::StrCat(\"Invalid limit type: \", limitType));\n}\n+ limits_entry.limit_type = *it;\n// parse soft limit\nif (parts[0] == \"unlimited\") {\n@@ -418,119 +430,55 @@ PosixErrorOr<std::vector<ProcLimitsEntry>> ParseProcLimits(\n}\nstd::ostream& operator<<(std::ostream& os, const ProcLimitsEntry& entry) {\n- std::string str = \"Max \";\n-\n- switch (entry.limit_type) {\n- case LimitType::CPU:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"cpu time\"));\n- break;\n- case LimitType::FileSize:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"file size\"));\n- break;\n- case LimitType::Data:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"data size\"));\n- break;\n- case LimitType::Stack:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"stack size\"));\n- break;\n- case LimitType::Core:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"core file size\"));\n- break;\n- case LimitType::RSS:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"resident set\"));\n- break;\n- case LimitType::ProcessCount:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"processes\"));\n- break;\n- case LimitType::NumberOfFiles:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"open files\"));\n- break;\n- case LimitType::MemoryLocked:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"locked memory\"));\n- break;\n- case LimitType::AS:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"address space\"));\n- break;\n- case LimitType::Locks:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"file locks\"));\n- break;\n- case LimitType::SignalsPending:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"pending signals\"));\n- break;\n- case LimitType::MessageQueueBytes:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"msgqueue size\"));\n- break;\n- case LimitType::Nice:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"nice priority\"));\n- break;\n- case LimitType::RealTimePriority:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"realtime priority\"));\n- break;\n- case LimitType::Rttime:\n- absl::StrAppend(&str, absl::StrFormat(\"%-25s \", \"realtime timeout\"));\n- break;\n- }\n+ std::string str =\n+ absl::StrFormat(\"Max %-25s \", LimitTypeToString(entry.limit_type));\nif (entry.cur_limit == ~0ULL) {\n- absl::StrAppend(&str, absl::StrFormat(\"%-20s \", \"unlimited\"));\n+ absl::StrAppendFormat(&str, \"%-20s \", \"unlimited\");\n} else {\n- absl::StrAppend(&str, absl::StrFormat(\"%-20d \", entry.cur_limit));\n+ absl::StrAppendFormat(&str, \"%-20d \", entry.cur_limit);\n}\nif (entry.max_limit == ~0ULL) {\n- absl::StrAppend(&str, absl::StrFormat(\"%-20s \", \"unlimited\"));\n+ absl::StrAppendFormat(&str, \"%-20s \", \"unlimited\");\n} else {\n- absl::StrAppend(&str, absl::StrFormat(\"%-20d \", entry.max_limit));\n+ absl::StrAppendFormat(&str, \"%-20d \", entry.max_limit);\n}\nswitch (entry.limit_type) {\n- case LimitType::CPU:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s\", \"seconds\"));\n- break;\n- case LimitType::FileSize:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n- break;\n- case LimitType::Data:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n- break;\n- case LimitType::Stack:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n- break;\n- case LimitType::Core:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n- break;\n- case LimitType::RSS:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n- break;\n- case LimitType::ProcessCount:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"processes\"));\n- break;\n- case LimitType::NumberOfFiles:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"files\"));\n+ case LimitType::kFileSize:\n+ case LimitType::kData:\n+ case LimitType::kStack:\n+ case LimitType::kCore:\n+ case LimitType::kRSS:\n+ case LimitType::kMemoryLocked:\n+ case LimitType::kAS:\n+ case LimitType::kMessageQueueBytes:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"bytes\");\nbreak;\n- case LimitType::MemoryLocked:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n+ case LimitType::kCPU:\n+ absl::StrAppendFormat(&str, \"%-10s\", \"seconds\");\nbreak;\n- case LimitType::AS:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n+ case LimitType::kNumberOfFiles:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"files\");\nbreak;\n- case LimitType::Locks:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"locks\"));\n+ case LimitType::kLocks:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"locks\");\nbreak;\n- case LimitType::SignalsPending:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"signals\"));\n+ case LimitType::kSignalsPending:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"signals\");\nbreak;\n- case LimitType::MessageQueueBytes:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"bytes\"));\n+ case LimitType::kProcessCount:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"processes\");\nbreak;\n- case LimitType::Nice:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"\"));\n+ case LimitType::kNice:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"\");\nbreak;\n- case LimitType::RealTimePriority:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"\"));\n+ case LimitType::kRealTimePriority:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"\");\nbreak;\n- case LimitType::Rttime:\n- absl::StrAppend(&str, absl::StrFormat(\"%-10s \", \"us\"));\n+ case LimitType::kRttime:\n+ absl::StrAppendFormat(&str, \"%-10s \", \"us\");\nbreak;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/util/proc_util.h",
"new_path": "test/util/proc_util.h",
"diff": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n+#include \"absl/algorithm/container.h\"\n#include \"absl/strings/str_cat.h\"\n#include \"absl/strings/string_view.h\"\n#include \"absl/types/optional.h\"\n@@ -142,7 +143,7 @@ inline std::ostream& operator<<(std::ostream& os,\nreturn os;\n}\n-// GMock printer for std::vector<ProcMapsEntry>.\n+// GoogleTest printer for std::vector<ProcMapsEntry>.\ninline void PrintTo(const std::vector<ProcMapsEntry>& vec, std::ostream* os) {\n*os << vec;\n}\n@@ -173,7 +174,7 @@ MATCHER_P(ContainsMappings, mappings,\nbool all_present = true;\nstd::for_each(mappings.begin(), mappings.end(), [&](const ProcMapsEntry& e1) {\nauto it =\n- std::find_if(maps.begin(), maps.end(), [&e1](const ProcMapsEntry& e2) {\n+ absl::c_find_if(maps, [&e1](const ProcMapsEntry& e2) {\nreturn e1.start == e2.start && e1.end == e2.end &&\ne1.readable == e2.readable && e1.writable == e2.writable &&\ne1.executable == e2.executable && e1.priv == e2.priv &&\n@@ -197,24 +198,45 @@ MATCHER_P(ContainsMappings, mappings,\n// LimitType is an rlimit type\nenum class LimitType {\n- CPU,\n- FileSize,\n- Data,\n- Stack,\n- Core,\n- RSS,\n- ProcessCount,\n- NumberOfFiles,\n- MemoryLocked,\n- AS,\n- Locks,\n- SignalsPending,\n- MessageQueueBytes,\n- Nice,\n- RealTimePriority,\n- Rttime,\n+ kCPU,\n+ kFileSize,\n+ kData,\n+ kStack,\n+ kCore,\n+ kRSS,\n+ kProcessCount,\n+ kNumberOfFiles,\n+ kMemoryLocked,\n+ kAS,\n+ kLocks,\n+ kSignalsPending,\n+ kMessageQueueBytes,\n+ kNice,\n+ kRealTimePriority,\n+ kRttime,\n};\n+const std::vector<LimitType> LimitTypes{\n+ LimitType::kCPU,\n+ LimitType::kFileSize,\n+ LimitType::kData,\n+ LimitType::kStack,\n+ LimitType::kCore,\n+ LimitType::kRSS,\n+ LimitType::kProcessCount,\n+ LimitType::kNumberOfFiles,\n+ LimitType::kMemoryLocked,\n+ LimitType::kAS,\n+ LimitType::kLocks,\n+ LimitType::kSignalsPending,\n+ LimitType::kMessageQueueBytes,\n+ LimitType::kNice,\n+ LimitType::kRealTimePriority,\n+ LimitType::kRttime,\n+};\n+\n+std::string LimitTypeToString(LimitType type);\n+\n// ProcLimitsEntry contains the data from a single line in /proc/xxx/limits.\nstruct ProcLimitsEntry {\nLimitType limit_type;\n@@ -222,10 +244,10 @@ struct ProcLimitsEntry {\nuint64_t max_limit;\n};\n-// Parses a single line from /proc/xxx/limits\n+// Parses a single line from /proc/xxx/limits.\nPosixErrorOr<ProcLimitsEntry> ParseProcLimitsLine(absl::string_view line);\n-// Parses an entire /proc/xxx/limits file into lines\n+// Parses an entire /proc/xxx/limits file into lines.\nPosixErrorOr<std::vector<ProcLimitsEntry>> ParseProcLimits(\nabsl::string_view contents);\n@@ -236,7 +258,7 @@ std::ostream& operator<<(std::ostream& os, const ProcLimitsEntry& entry);\nstd::ostream& operator<<(std::ostream& os,\nconst std::vector<ProcLimitsEntry>& vec);\n-// GMock printer for std::vector<ProcLimitsEntry>.\n+// GoogleTest printer for std::vector<ProcLimitsEntry>.\ninline void PrintTo(const std::vector<ProcLimitsEntry>& vec, std::ostream* os) {\n*os << vec;\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | test: address comments from cl/504951567
PiperOrigin-RevId: 508289325 |
260,004 | 09.02.2023 12:40:16 | 28,800 | 89cc675c292b4c06d6b3651671478c8d272490f9 | Don't transition from V1 -> V2 unless requested
Leave the generic multicast protocol in V1 mode even when transitioning
all groups to non-member state (when interface is disabled).
Updates | [
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol.go",
"diff": "@@ -397,14 +397,15 @@ func (g *GenericMulticastProtocolState) MakeAllNonMemberLocked() {\ngroupAddress,\n)\n}\n- case protocolModeV1Compatibility, protocolModeV1:\n+ case protocolModeV1Compatibility:\n+ g.mode = protocolModeV2\n+ fallthrough\n+ case protocolModeV1:\nhandler = g.transitionToNonMemberLocked\ndefault:\npanic(fmt.Sprintf(\"unrecognized mode = %d\", g.mode))\n}\n- g.mode = protocolModeV2\n-\nfor groupAddress, info := range g.memberships {\nif !g.shouldPerformForGroup(groupAddress) {\ncontinue\n"
},
{
"change_type": "MODIFY",
"old_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"new_path": "pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go",
"diff": "@@ -1153,13 +1153,28 @@ func TestJoinCount(t *testing.T) {\n}\nfunc TestMakeAllNonMemberAndInitialize(t *testing.T) {\n+ const unsolicitedTransmissionCount = 2\n+\ntests := []struct {\nname string\n+ v1 bool\nv1Compatibility bool\ncheckFields func([]tcpip.Address, bool) checkFields\n}{\n+ {\n+ name: \"V1\",\n+ v1: true,\n+ v1Compatibility: false,\n+ checkFields: func(addrs []tcpip.Address, leave bool) checkFields {\n+ if leave {\n+ return checkFields{sendLeaveGroupAddresses: addrs}\n+ }\n+ return checkFields{sendReportGroupAddresses: addrs}\n+ },\n+ },\n{\nname: \"V1 Compatibility\",\n+ v1: false,\nv1Compatibility: true,\ncheckFields: func(addrs []tcpip.Address, leave bool) checkFields {\nif leave {\n@@ -1170,6 +1185,7 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\n},\n{\nname: \"V2\",\n+ v1: false,\nv1Compatibility: false,\ncheckFields: func(addrs []tcpip.Address, leave bool) checkFields {\nrecordType := ip.MulticastGroupProtocolV2ReportRecordChangeToExcludeMode\n@@ -1198,7 +1214,13 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\nRand: rand.New(rand.NewSource(3)),\nClock: clock,\nMaxUnsolicitedReportDelay: maxUnsolicitedReportDelay,\n- }, test.v1Compatibility)\n+ }, test.v1)\n+\n+ if test.v1Compatibility {\n+ // V1 query targetting an unjoined group should drop us into V1\n+ // compatibility mode without sending any packets, affecting tests.\n+ mgp.handleQuery(addr3, 0)\n+ }\nmgp.joinGroup(addr1)\nif diff := mgp.check(test.checkFields([]tcpip.Address{addr1}, false /* leave */)); diff != \"\" {\n@@ -1216,8 +1238,7 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\n// Should send the leave reports for each but still consider them locally\n// joined.\nmgp.makeAllNonMember()\n- expectedLeaveFields := test.checkFields([]tcpip.Address{addr1, addr2}, true /* leave */)\n- if diff := mgp.check(expectedLeaveFields); diff != \"\" {\n+ if diff := mgp.check(test.checkFields([]tcpip.Address{addr1, addr2}, true /* leave */)); diff != \"\" {\nt.Errorf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n@@ -1234,6 +1255,12 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\n// Should send the initial set of unsolcited V2 reports.\nmgp.initializeGroups()\n+ for i := 0; i < unsolicitedTransmissionCount; i++ {\n+ if test.v1 {\n+ if diff := mgp.check(test.checkFields([]tcpip.Address{addr1, addr2}, false /* leave */)); diff != \"\" {\n+ t.Errorf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n+ }\n+ } else {\nif diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{\n{\nrecords: []mockReportV2Record{\n@@ -1254,22 +1281,8 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\n}}); diff != \"\" {\nt.Errorf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n+ }\nclock.Advance(maxUnsolicitedReportDelay)\n- if diff := mgp.check(checkFields{sentV2Reports: []mockReportV2{\n- {\n- records: []mockReportV2Record{\n- {\n- recordType: ip.MulticastGroupProtocolV2ReportRecordChangeToExcludeMode,\n- groupAddress: addr1,\n- },\n- {\n- recordType: ip.MulticastGroupProtocolV2ReportRecordChangeToExcludeMode,\n- groupAddress: addr2,\n- },\n- },\n- },\n- }}); diff != \"\" {\n- t.Errorf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n// Should have no more messages to send.\n@@ -1277,6 +1290,10 @@ func TestMakeAllNonMemberAndInitialize(t *testing.T) {\nif diff := mgp.check(checkFields{}); diff != \"\" {\nt.Errorf(\"mockMulticastGroupProtocol mismatch (-want +got):\\n%s\", diff)\n}\n+\n+ if got := mgp.getV1Mode(); got != test.v1 {\n+ t.Errorf(\"got mgp.getV1Mode() = %t, want = %t\", got, test.v1)\n+ }\n})\n}\n}\n"
}
] | Go | Apache License 2.0 | google/gvisor | Don't transition from V1 -> V2 unless requested
Leave the generic multicast protocol in V1 mode even when transitioning
all groups to non-member state (when interface is disabled).
Updates #8346
PiperOrigin-RevId: 508448263 |
259,907 | 10.02.2023 13:38:52 | 28,800 | 1beb3e2b251df5b59d817d90831805ba7d44b7ff | Check hard link target's mount compatibility before kernfs.Dentry cast. Again.
commit mistakenly reverted commit Make the same
commit again. This time add a regression test to avoid such a thing from
happening again.
Reported-by:
Reported-by: | [
{
"change_type": "MODIFY",
"old_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"new_path": "pkg/sentry/fsimpl/kernfs/filesystem.go",
"diff": "@@ -362,8 +362,9 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nreturn err\n}\n- parent.dirMu.Lock()\n- defer parent.dirMu.Unlock()\n+ if rp.Mount() != vd.Mount() {\n+ return linuxerr.EXDEV\n+ }\ninode := vd.Dentry().Impl().(*Dentry).Inode()\nif inode.Mode().IsDir() {\nreturn linuxerr.EPERM\n@@ -371,6 +372,8 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif err := vfs.MayLink(rp.Credentials(), inode.Mode(), inode.UID(), inode.GID()); err != nil {\nreturn err\n}\n+ parent.dirMu.Lock()\n+ defer parent.dirMu.Unlock()\npc := rp.Component()\nif err := checkCreateLocked(ctx, rp.Credentials(), pc, parent); err != nil {\nreturn err\n@@ -378,9 +381,6 @@ func (fs *Filesystem) LinkAt(ctx context.Context, rp *vfs.ResolvingPath, vd vfs.\nif rp.MustBeDir() {\nreturn linuxerr.ENOENT\n}\n- if rp.Mount() != vd.Mount() {\n- return linuxerr.EXDEV\n- }\nif err := rp.Mount().CheckBeginWrite(); err != nil {\nreturn err\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/syscalls/linux/link.cc",
"new_path": "test/syscalls/linux/link.cc",
"diff": "@@ -349,6 +349,12 @@ TEST(LinkTest, LinkatWithSymlinkFollow) {\nEXPECT_THAT(unlink(newname.c_str()), SyscallSucceeds());\n}\n+TEST(LinkTest, KernfsAcrossFilesystem) {\n+ auto file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile());\n+ EXPECT_THAT(link(file.path().c_str(), \"/sys/newfile\"),\n+ SyscallFailsWithErrno(::testing::AnyOf(EROFS, EXDEV)));\n+}\n+\n} // namespace\n} // namespace testing\n"
}
] | Go | Apache License 2.0 | google/gvisor | Check hard link target's mount compatibility before kernfs.Dentry cast. Again.
1da6444d05e9 commit mistakenly reverted commit 8373fb5db8c8. Make the same
commit again. This time add a regression test to avoid such a thing from
happening again.
Reported-by: syzbot+05b6f8c23f6cd54deb2c@syzkaller.appspotmail.com
Reported-by: syzbot+c12cc3a057f3b75eb3cf@syzkaller.appspotmail.com
PiperOrigin-RevId: 508743552 |
530,388 | 05.01.2017 12:12:27 | -19,080 | 48e8995cb35f4d1e783af1d0de9a764c0a7cf1c1 | chore: update dependencies and tasks | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@angular/forms\": \"^2.3.0\",\n\"@angular/http\": \"^2.3.0\",\n\"@angular/platform-browser\": \"^2.3.0\",\n- \"@angular/platform-browser-dynamic\": \"^2.3.0\",\n- \"@angular/router\": \"^3.3.0\",\n\"core-js\": \"^2.4.1\",\n\"rxjs\": \"5.0.0-beta.12\",\n\"systemjs\": \"0.19.38\",\n},\n\"devDependencies\": {\n\"@angular/compiler-cli\": \"^2.3.0\",\n+ \"@angular/platform-browser-dynamic\": \"^2.3.0\",\n\"@angular/platform-server\": \"^2.3.0\",\n+ \"@angular/router\": \"^3.3.0\",\n\"@types/glob\": \"^5.0.29\",\n\"@types/gulp\": \"^3.8.29\",\n+ \"@types/hammerjs\": \"^2.0.30\",\n+ \"@types/jasmine\": \"^2.2.31\",\n\"@types/merge2\": \"0.0.28\",\n\"@types/minimist\": \"^1.1.28\",\n\"@types/node\": \"^6.0.34\",\n+ \"@types/protractor\": \"^4.0.0\",\n\"@types/run-sequence\": \"0.0.27\",\n\"@types/rx\": \"^2.5.33\",\n+ \"@types/selenium-webdriver\": \"2.53.36\",\n+ \"axe-core\": \"^2.0.7\",\n+ \"axe-webdriverjs\": \"^0.4.0\",\n\"conventional-changelog\": \"^1.1.0\",\n\"conventional-github-releaser\": \"^1.1.3\",\n\"dgeni\": \"^0.4.2\",\n\"dgeni-packages\": \"^0.16.2\",\n\"express\": \"^4.14.0\",\n+ \"firebase-admin\": \"^4.0.4\",\n+ \"firebase-tools\": \"^2.2.1\",\n\"fs-extra\": \"^0.26.5\",\n\"glob\": \"^6.0.4\",\n\"gulp\": \"^3.9.1\",\n\"gulp-sourcemaps\": \"^1.6.0\",\n\"gulp-transform\": \"^1.1.0\",\n\"gulp-typescript\": \"^3.1.3\",\n+ \"hammerjs\": \"^2.0.8\",\n\"highlight.js\": \"^9.9.0\",\n+ \"jasmine-core\": \"^2.4.1\",\n+ \"karma\": \"^1.1.1\",\n+ \"karma-browserstack-launcher\": \"^1.0.1\",\n+ \"karma-chrome-launcher\": \"^1.0.1\",\n+ \"karma-firefox-launcher\": \"^1.0.0\",\n+ \"karma-jasmine\": \"^1.0.2\",\n+ \"karma-sauce-launcher\": \"^1.0.0\",\n+ \"karma-sourcemap-loader\": \"^0.3.7\",\n\"madge\": \"^0.6.0\",\n\"merge2\": \"^1.0.2\",\n\"minimist\": \"^1.2.0\",\n\"node-sass\": \"^3.4.2\",\n+ \"protractor\": \"^4.0.8\",\n\"resolve-bin\": \"^0.4.0\",\n\"run-sequence\": \"^1.2.2\",\n\"sass\": \"^0.5.0\",\n+ \"selenium-webdriver\": \"2.53.3\",\n\"strip-ansi\": \"^3.0.0\",\n\"stylelint\": \"^7.7.0\",\n\"symlink-or-copy\": \"^1.0.1\",\n+ \"travis-after-modes\": \"0.0.6-2\",\n\"ts-node\": \"^0.7.3\",\n\"tslint\": \"^3.13.0\",\n\"typedoc\": \"^0.5.1\",\n\"typescript\": \"~2.0.10\",\n- \"typings\": \"^1.3.1\",\n\"uglify-js\": \"^2.7.5\",\n\"which\": \"^1.2.4\"\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/axe-protractor/axe-protractor.js",
"diff": "+'use strict';\n+\n+/**\n+ * Protractor Plugin to run axe-core accessibility audits after Angular bootstrapped.\n+ */\n+\n+const AxeBuilder = require('axe-webdriverjs');\n+const {buildMessage} = require('./build-message');\n+\n+/* List of pages which were already checked by axe-core and shouldn't run again */\n+const checkedPages = [];\n+\n+/**\n+ * Protractor plugin hook which always runs when Angular successfully bootstrapped.\n+ */\n+function onPageStable() {\n+ AxeBuilder(browser.driver)\n+ .configure(this.config || {})\n+ .analyze(results => handleResults(this, results));\n+}\n+\n+/**\n+ * Processes the axe-core results by reporting recognized violations\n+ * to Protractor and printing them out.\n+ * @param {!protractor.ProtractorPlugin} context\n+ * @param {!axe.AxeResults} results\n+ */\n+function handleResults(context, results) {\n+\n+ if (checkedPages.indexOf(results.url) === -1) {\n+\n+ checkedPages.push(results.url);\n+\n+ results.violations.forEach(violation => {\n+\n+ let specName = `${violation.help} (${results.url})`;\n+ let message = '\\n' + buildMessage(violation);\n+\n+ context.addFailure(message, {specName});\n+\n+ });\n+\n+ }\n+\n+}\n+\n+exports.name = 'protractor-axe';\n+exports.onPageStable = onPageStable;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/axe-protractor/build-message.js",
"diff": "+/**\n+ * Builds a simple message of the violation results of axe-core by listing\n+ * each violation and the associated element selector in a new line.\n+ * @param {!axe.Violation} violation\n+ */\n+exports.buildMessage = violation => {\n+\n+ let selectors = violation.nodes.map(node => {\n+ return node.target.join(' ');\n+ });\n+\n+ return selectors.reduce((content, selector) => {\n+ return content + '- ' + selector + '\\n';\n+ }, '');\n+\n+};\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/dgeni/processors/categorizer.js",
"new_path": "tools/dgeni/processors/categorizer.js",
"diff": "@@ -28,6 +28,7 @@ module.exports = function categorizer() {\ndoc.classDoc.methods = [doc];\n} else if (isDirective(doc)) {\ndoc.isDirective = true;\n+ doc.directiveExportAs = getDirectiveExportAs(doc);\n} else if (isService(doc)) {\ndoc.isService = true;\n} else if (isNgModule(doc)) {\n@@ -117,6 +118,17 @@ function getDirectiveOutputAlias(doc) {\nreturn isDirectiveOutput(doc) ? doc.decorators.find(d => d.name == 'Output').arguments[0] : '';\n}\n+function getDirectiveExportAs(doc) {\n+ let metadata = doc.decorators\n+ .find(d => d.name === 'Component' || d.name === 'Directive').arguments[0];\n+\n+ // Use a Regex to determine the exportAs metadata because we can't parse the JSON due to\n+ // environment variables inside of the JSON.\n+ let exportMatches = /exportAs\\s*:\\s*(?:\"|')(\\w+)(?:\"|')/g.exec(metadata);\n+\n+ return exportMatches && exportMatches[1];\n+}\n+\nfunction hasMemberDecorator(doc, decoratorName) {\nreturn doc.docType == 'member' && hasDecorator(doc, decoratorName);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/dgeni/templates/class.template.html",
"new_path": "tools/dgeni/templates/class.template.html",
"diff": "<h3 class=\"docs-api-h3 docs-api-class-name\">{$ class.name $}</h3>\n<p class=\"docs-api-class-description\">{$ class.description $}</p>\n+{%- if class.directiveExportAs -%}\n+<span class=\"docs-api-h4 docs-api-class-export-label\">Exported as:</span>\n+<span class=\"docs-api-class-export-name\">{$ class.directiveExportAs $}</span>\n+{%- endif -%}\n+\n{$ propertyList(class.properties) $}\n{$ methodList(class.methods) $}\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/gulpfile.ts",
"new_path": "tools/gulp/gulpfile.ts",
"diff": "+import './tasks/ci';\nimport './tasks/clean';\nimport './tasks/components';\nimport './tasks/default';\nimport './tasks/deploy';\nimport './tasks/development';\nimport './tasks/docs';\n+import './tasks/e2e';\nimport './tasks/lint';\nimport './tasks/release';\nimport './tasks/serve';\n+import './tasks/unit-test';\nimport './tasks/docs';\n+import './tasks/aot';\n+import './tasks/payload';\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/task_helpers.ts",
"new_path": "tools/gulp/task_helpers.ts",
"diff": "@@ -16,6 +16,7 @@ const gulpSourcemaps = require('gulp-sourcemaps');\nconst gulpAutoprefixer = require('gulp-autoprefixer');\nconst gulpConnect = require('gulp-connect');\nconst resolveBin = require('resolve-bin');\n+const firebaseAdmin = require('firebase-admin');\n/** If the string passed in is a glob, returns it, otherwise append '**\\/*' to it. */\n@@ -53,7 +54,7 @@ export function tsBuildTask(tsConfigPath: string, tsConfigName = 'tsconfig.json'\nlet pipe = tsProject.src()\n.pipe(gulpSourcemaps.init())\n- .pipe(gulpTs(tsProject));\n+ .pipe(tsProject());\nlet dts = pipe.dts.pipe(gulp.dest(dest));\nreturn gulpMerge([\n@@ -211,3 +212,26 @@ export function sequenceTask(...args: any[]) {\n);\n};\n}\n+\n+/** Opens a connection to the firebase realtime database. */\n+export function openFirebaseDatabase() {\n+ // Initialize the Firebase application with admin credentials.\n+ // Credentials need to be for a Service Account, which can be created in the Firebase console.\n+ firebaseAdmin.initializeApp({\n+ credential: firebaseAdmin.credential.cert({\n+ project_id: 'material2-dashboard',\n+ client_email: 'firebase-adminsdk-ch1ob@material2-dashboard.iam.gserviceaccount.com',\n+ // In Travis CI the private key will be incorrect because the line-breaks are escaped.\n+ // The line-breaks need to persist in the service account private key.\n+ private_key: (process.env['MATERIAL2_FIREBASE_PRIVATE_KEY'] || '').replace(/\\\\n/g, '\\n')\n+ }),\n+ databaseURL: 'https://material2-dashboard.firebaseio.com'\n+ });\n+\n+ return firebaseAdmin.database();\n+}\n+\n+/** Whether gulp currently runs inside of Travis as a push. */\n+export function isTravisPushBuild() {\n+ return process.env['TRAVIS_PULL_REQUEST'] === 'false';\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/gulp/tasks/aot.ts",
"diff": "+import {task} from 'gulp';\n+import {join} from 'path';\n+import {DIST_ROOT} from '../constants';\n+import {execNodeTask, sequenceTask} from '../task_helpers';\n+\n+/** Copies the source files of the demo-app to the dist folder. */\n+task('aot:copy', [':build:devapp:scss', ':build:devapp:assets']);\n+\n+/**\n+ * Prepares the AOT compilation by copying the demo-app and building the components with their\n+ * associated metadata files from the Angular compiler.\n+ */\n+task('aot:prepare', sequenceTask(\n+ 'clean',\n+ ['aot:copy', 'build:components:release', ':build:components:ngc'])\n+);\n+\n+/** Builds the demo-app with the Angular compiler to verify that all components work. */\n+task('aot:build', ['aot:prepare'], execNodeTask(\n+ '@angular/compiler-cli', 'ngc', ['-p', join(DIST_ROOT, 'tsconfig-aot.json')])\n+);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/gulp/tasks/ci.ts",
"diff": "+import {task} from 'gulp';\n+\n+\n+task('ci:lint', ['ci:forbidden-identifiers', 'lint']);\n+\n+task('ci:forbidden-identifiers', function() {\n+ require('../../../scripts/ci/forbidden-identifiers.js');\n+});\n+\n+// Travis sometimes does not exit the process and times out. This is to prevent that.\n+task('ci:test', ['test:single-run'], () => process.exit(0));\n+\n+task('ci:e2e', ['e2e']);\n+\n+/** Task to verify that all components work with AOT compilation. */\n+task('ci:aot', ['aot:build']);\n+\n+/** Task which reports the size of the library and stores it in a database. */\n+task('ci:payload', ['payload']);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/gulp/tasks/e2e.ts",
"diff": "+import {task, watch} from 'gulp';\n+import * as path from 'path';\n+\n+import {SOURCE_ROOT, DIST_ROOT, PROJECT_ROOT} from '../constants';\n+import {\n+ tsBuildTask, sassBuildTask, copyTask, buildAppTask, execNodeTask,\n+ vendorTask, sequenceTask, serverTask\n+} from '../task_helpers';\n+\n+const gulpRunSequence = require('run-sequence');\n+const gulpConnect = require('gulp-connect');\n+\n+const appDir = path.join(SOURCE_ROOT, 'e2e-app');\n+const outDir = DIST_ROOT;\n+const PROTRACTOR_CONFIG_PATH = path.join(PROJECT_ROOT, 'test/protractor.conf.js');\n+\n+task(':watch:e2eapp', () => {\n+ watch(path.join(appDir, '**/*.ts'), [':build:e2eapp:ts']);\n+ watch(path.join(appDir, '**/*.html'), [':build:e2eapp:assets']);\n+});\n+\n+/** Copies e2e app dependencies to build output. */\n+task(':build:e2eapp:vendor', vendorTask());\n+\n+/** Builds e2e app ts to js. */\n+task(':build:e2eapp:ts', tsBuildTask(appDir));\n+\n+/** No-op (needed by buildAppTask). */\n+task(':build:e2eapp:scss', sassBuildTask(outDir, appDir));\n+\n+/** Copies e2e app assets (html, css) to build output. */\n+task(':build:e2eapp:assets', copyTask(appDir, outDir));\n+\n+/** Builds the entire e2e app. */\n+task('build:e2eapp', buildAppTask('e2eapp'));\n+\n+/** Ensures that protractor and webdriver are set up to run. */\n+task(':test:protractor:setup', execNodeTask('protractor', 'webdriver-manager', ['update']));\n+\n+/** Runs protractor tests (assumes that server is already running. */\n+task(':test:protractor', execNodeTask('protractor', [PROTRACTOR_CONFIG_PATH]));\n+\n+/** Starts up the e2e app server. */\n+task(':serve:e2eapp', serverTask(false));\n+\n+/** Terminates the e2e app server */\n+task(':serve:e2eapp:stop', gulpConnect.serverClose);\n+\n+/** Builds and serves the e2e app. */\n+task('serve:e2eapp', sequenceTask('build:e2eapp', ':serve:e2eapp'));\n+\n+/**\n+ * [Watch task] Builds and serves e2e app, rebuilding whenever the sources change.\n+ * This should only be used when running e2e tests locally.\n+ */\n+task('serve:e2eapp:watch', ['serve:e2eapp', ':watch:components', ':watch:e2eapp']);\n+\n+/**\n+ * Builds and serves the e2e-app and runs protractor once the e2e-app is ready.\n+ */\n+task('e2e', (done: (err?: string) => void) => {\n+ gulpRunSequence(\n+ ':test:protractor:setup',\n+ 'serve:e2eapp',\n+ ':test:protractor',\n+ ':serve:e2eapp:stop',\n+ (err: any) => done(err)\n+ );\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/gulp/tasks/payload.ts",
"diff": "+import {task} from 'gulp';\n+import {join} from 'path';\n+import {statSync, readFileSync} from 'fs';\n+import {DIST_COMPONENTS_ROOT} from '../constants';\n+import {openFirebaseDatabase, isTravisPushBuild} from '../task_helpers';\n+import {spawnSync} from 'child_process';\n+\n+// Those imports lack types.\n+const uglifyJs = require('uglify-js');\n+\n+const BUNDLE_PATH = join(DIST_COMPONENTS_ROOT, 'bundles', 'material.umd.js');\n+\n+/** Task which runs test against the size of whole library. */\n+task('payload', ['build:release'], () => {\n+\n+ let results = {\n+ umd_kb: getFilesize(BUNDLE_PATH),\n+ umd_minified_uglify_kb: getUglifiedSize(BUNDLE_PATH),\n+ timestamp: Date.now()\n+ };\n+\n+ // Print the results to the console, so we can read it from the CI.\n+ console.log('Payload Results:', JSON.stringify(results, null, 2));\n+\n+ // Publish the results to firebase when it runs on Travis and not as a PR.\n+ if (isTravisPushBuild()) {\n+ return publishResults(results);\n+ }\n+\n+});\n+\n+/** Returns the size of a file in kilobytes. */\n+function getFilesize(filePath: string) {\n+ return statSync(filePath).size / 1000;\n+}\n+\n+/** Returns the size of a uglify minified file in kilobytes */\n+function getUglifiedSize(filePath: string) {\n+ let fileContent = readFileSync(filePath, 'utf-8');\n+\n+ let compressedFile = uglifyJs.minify(fileContent, {\n+ fromString: true\n+ });\n+\n+ return Buffer.byteLength(compressedFile.code, 'utf8') / 1000;\n+}\n+\n+/** Publishes the given results to the firebase database. */\n+function publishResults(results: any) {\n+ let latestSha = spawnSync('git', ['rev-parse', 'HEAD']).stdout.toString().trim();\n+ let database = openFirebaseDatabase();\n+\n+ // Write the results to the payloads object with the latest Git SHA as key.\n+ return database.ref('payloads').child(latestSha).set(results)\n+ .then(() => database.goOffline(), () => database.goOffline());\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/gulp/tasks/unit-test.ts",
"diff": "+import gulp = require('gulp');\n+import path = require('path');\n+import gulpMerge = require('merge2');\n+\n+import {PROJECT_ROOT, COMPONENTS_DIR} from '../constants';\n+import {sequenceTask} from '../task_helpers';\n+\n+const karma = require('karma');\n+const runSequence = require('run-sequence');\n+\n+/** Copies deps for unit tests to the build output. */\n+gulp.task(':build:test:vendor', function() {\n+ const npmVendorFiles = [\n+ '@angular', 'core-js/client', 'hammerjs', 'rxjs', 'systemjs/dist', 'zone.js/dist'\n+ ];\n+\n+ return gulpMerge(\n+ npmVendorFiles.map(function(root) {\n+ const glob = path.join(root, '**/*.+(js|js.map)');\n+ return gulp.src(path.join('node_modules', glob))\n+ .pipe(gulp.dest(path.join('dist/vendor', root)));\n+ }));\n+});\n+\n+/** Builds dependencies for unit tests. */\n+gulp.task(':test:deps', sequenceTask(\n+ 'clean',\n+ [\n+ ':build:test:vendor',\n+ ':build:components:assets',\n+ ':build:components:scss',\n+ ':build:components:spec',\n+ ]\n+));\n+\n+\n+/** Build unit test dependencies and then inlines resources (html, css) into the JS output. */\n+gulp.task(':test:deps:inline', sequenceTask(':test:deps', ':inline-resources'));\n+\n+/**\n+ * Runs the unit tests once with inlined resources (html, css). Does not watch for changes.\n+ *\n+ * This task should be used when running tests on the CI server.\n+ */\n+gulp.task('test:single-run', [':test:deps:inline'], (done: () => void) => {\n+ new karma.Server({\n+ configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),\n+ singleRun: true\n+ }, done).start();\n+});\n+\n+/**\n+ * [Watch task] Runs the unit tests, rebuilding and re-testing when sources change.\n+ * Does not inline resources. Note that this doesn't use Karma's built-in file\n+ * watching. Due to the way our build process is set up, Karma ends up firing\n+ * it's change detection for every file that is written to disk, which causes\n+ * it to run tests multiple time and makes it hard to follow the console output.\n+ * This approach runs the Karma server and then depends on the Gulp API to tell\n+ * Karma when to run the tests.\n+ *\n+ * This task should be used when running unit tests locally.\n+ */\n+gulp.task('test', [':test:deps'], () => {\n+ let patternRoot = path.join(COMPONENTS_DIR, '**/*');\n+\n+ // Configure the Karma server and override the autoWatch and singleRun just in case.\n+ let server = new karma.Server({\n+ configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),\n+ autoWatch: false,\n+ singleRun: false\n+ });\n+\n+ // Refreshes Karma's file list and schedules a test run.\n+ let runTests = () => {\n+ server.refreshFiles().then(() => server._injector.get('executor').schedule());\n+ };\n+\n+ // Boot up the test server and run the tests whenever a new browser connects.\n+ server.start();\n+ server.on('browser_register', runTests);\n+\n+ // Watch for file changes, rebuild and run the tests.\n+ gulp.watch(patternRoot + '.ts', () => runSequence(':build:components:spec', runTests));\n+ gulp.watch(patternRoot + '.scss', () => runSequence(':build:components:scss', runTests));\n+ gulp.watch(patternRoot + '.html', () => runSequence(':build:components:assets', runTests));\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tools/travis/fold.ts",
"diff": "+\n+function encode(str: string) {\n+ return str.replace(/\\W/g, '-').replace(/-$/, '');\n+}\n+\n+export function travisFoldStart(name: string): () => void {\n+ if (process.env['TRAVIS']) {\n+ console.log('travis_fold:start:' + encode(name));\n+ }\n+\n+ return () => {\n+ if (process.env['TRAVIS']) {\n+ console.log('travis_fold:end:' + encode(name));\n+ }\n+ };\n+}\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update dependencies and tasks |
530,388 | 05.01.2017 18:09:20 | -19,080 | 53844d5acc56b7934d3c2541d061c4d647a0b819 | chore: update gulp task constants | [
{
"change_type": "MODIFY",
"old_path": "tools/gulp/constants.ts",
"new_path": "tools/gulp/constants.ts",
"diff": "@@ -31,7 +31,7 @@ export const LICENSE_BANNER = `/**\n*/`;\nexport const NPM_VENDOR_FILES = [\n- '@angular', 'core-js/client', 'rxjs', 'systemjs/dist', 'zone.js/dist'\n+ '@angular', 'core-js/client', 'hammerjs', 'rxjs', 'systemjs/dist', 'zone.js/dist'\n];\nexport const COMPONENTS_DIR = join(SOURCE_ROOT, 'lib');\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update gulp task constants |
530,388 | 05.01.2017 18:10:32 | -19,080 | 29a53da4d8ca1420ac469c20a85d52577695d53e | feat(tooltip) multiple line support | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tooltip/tooltip.scss",
"new_path": "src/lib/tooltip/tooltip.scss",
"diff": "-$md2-tooltip-height: 22px;\n+$md2-tooltip-target-height: 22px;\n+$md2-tooltip-font-size: 10px;\n$md2-tooltip-margin: 14px;\n-$md2-tooltip-padding: 8px;\n+$md2-tooltip-horizontal-padding: 8px;\n+$md2-tooltip-vertical-padding: ($md2-tooltip-target-height - $md2-tooltip-font-size) / 2;\n:host {\npointer-events: none;\n@@ -8,12 +10,12 @@ $md2-tooltip-padding: 8px;\n.md2-tooltip {\ncolor: white;\n- padding: 0 $md2-tooltip-padding;\n+ padding: $md2-tooltip-vertical-padding $md2-tooltip-horizontal-padding;\nborder-radius: 2px;\n- font-size: 10px;\n+ font-size: $md2-tooltip-font-size;\nmargin: $md2-tooltip-margin;\n- height: $md2-tooltip-height;\n- line-height: $md2-tooltip-height;\n+ /*height: $md2-tooltip-target-height;\n+ line-height: $md2-tooltip-target-height;*/\nbackground: rgba(97, 97, 97, 0.9);\n}\n"
}
] | TypeScript | MIT License | promact/md2 | feat(tooltip) multiple line support |
530,388 | 05.01.2017 18:11:18 | -19,080 | ffaa04d386121c82c21a0b73c41b11f758693dda | chore: update tsconfig and dependencies | [
{
"change_type": "MODIFY",
"old_path": "src/lib/package.json",
"new_path": "src/lib/package.json",
"diff": "\"homepage\": \"https://github.com/Promact/md2#readme\",\n\"author\": \"Dharmesh Pipariya <pipariyadharmesh@gmail.com>\",\n\"peerDependencies\": {\n- \"@angular/core\": \"^2.3.0\",\n- \"@angular/common\": \"^2.3.0\",\n- \"@angular/http\": \"^2.3.0\"\n+ \"@angular/core\": \"^2.2.0\",\n+ \"@angular/common\": \"^2.2.0\",\n+ \"@angular/http\": \"^2.2.0\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/tsconfig-srcs.json",
"new_path": "src/lib/tsconfig-srcs.json",
"diff": "\"inlineSources\": true,\n\"stripInternal\": false,\n\"typeRoots\": [\n- \"../../node_modules/@types\"\n+ \"../../node_modules/@types/!(node)\"\n]\n},\n\"exclude\": [\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/tsconfig.json",
"new_path": "src/lib/tsconfig.json",
"diff": "\"paths\": {\n},\n\"typeRoots\": [\n- \"../../node_modules/@types\"\n+ \"../../node_modules/@types/!(node)\"\n],\n\"types\": [\n+ \"jasmine\",\n\"rx/rx.all\"\n]\n},\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update tsconfig and dependencies |
530,388 | 05.01.2017 18:12:21 | -19,080 | 59e4c3144ba8b3426e06c5e892d569d7a361d55d | chore: update script tasks | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/browserstack/start-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+set -e -o pipefail\n+\n+# Workaround for Travis CI cookbook https://github.com/travis-ci/travis-ci/issues/4862,\n+# where $PATH will be extended with relative paths to the NPM binaries.\n+PATH=`echo $PATH | sed -e 's/:\\.\\/node_modules\\/\\.bin//'`\n+\n+TUNNEL_FILE=\"BrowserStackLocal-linux-x64.zip\"\n+TUNNEL_URL=\"https://www.browserstack.com/browserstack-local/$TUNNEL_FILE\"\n+TUNNEL_DIR=\"/tmp/browserstack-tunnel\"\n+TUNNEL_LOG=\"$LOGS_DIR/browserstack-tunnel.log\"\n+\n+BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`\n+\n+# Cleanup and create the folder structure for the tunnel connector.\n+rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE\n+mkdir -p $TUNNEL_DIR\n+touch $TUNNEL_LOG\n+\n+cd $TUNNEL_DIR\n+\n+# Download the browserstack local binaries.\n+curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null\n+\n+# Extract the browserstack local binaries from the tarball.\n+mkdir -p browserstack-tunnel\n+unzip -q $TUNNEL_FILE -d browserstack-tunnel\n+\n+# Cleanup the download directory.\n+rm $TUNNEL_FILE\n+\n+ARGS=\"\"\n+\n+# Set tunnel-id only on Travis, to make local testing easier.\n+if [ ! -z \"$TRAVIS_JOB_NUMBER\" ]; then\n+ ARGS=\"$ARGS --local-identifier $TRAVIS_JOB_NUMBER\"\n+fi\n+\n+echo \"Starting Browserstack Local in the background, logging into:\"\n+echo \" $TUNNEL_LOG\"\n+echo \" ---\"\n+echo \" $ARGS\"\n+\n+# Extension to the BrowserStackLocal binaries, because those can't create a readyfile.\n+function create_ready_file {\n+\n+ # To be able to exit the tail properly we need to have a sub shell spawned, which is\n+ # used to track the state of tail.\n+ { sleep 120; touch $BROWSER_PROVIDER_ERROR_FILE; } &\n+\n+ TIMER_PID=$!\n+\n+ # Disown the background process, because we don't want to show any messages when killing\n+ # the timer.\n+ disown\n+\n+ # When the tail recognizes the `Ctrl-C` log message the BrowserStack Tunnel is up.\n+ {\n+ tail -n0 -f $TUNNEL_LOG --pid $TIMER_PID | { sed '/Ctrl/q' && kill -9 $TIMER_PID; };\n+ } &> /dev/null\n+\n+ echo\n+ echo \"BrowserStack Tunnel ready\"\n+\n+ touch $BROWSER_PROVIDER_READY_FILE\n+}\n+\n+browserstack-tunnel/BrowserStackLocal -k $BROWSER_STACK_ACCESS_KEY $ARGS &>> $TUNNEL_LOG &\n+\n+# Wait for the tunnel to be ready and create the readyfile with the Browserstack PID\n+create_ready_file &\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/browserstack/stop-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+set -e -o pipefail\n+\n+\n+echo \"Shutting down Browserstack tunnel\"\n+\n+killall BrowserStackLocal\n+\n+while [[ -n `ps -ef | grep \"BrowserStackLocal\" | grep -v \"grep\"` ]]; do\n+ printf \".\"\n+ sleep .5\n+done\n+\n+echo \"\"\n+echo \"Browserstack tunnel has been shut down\"\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/browserstack/wait-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+TUNNEL_LOG=\"$LOGS_DIR/browserstack-tunnel.log\"\n+\n+# Wait for Connect to be ready before exiting\n+# Time out if we wait for more than 2 minutes, so the process won't run forever.\n+let \"counter=0\"\n+\n+# Exit the process if there are errors reported. Print the tunnel log to the console.\n+if [ -f $BROWSER_PROVIDER_ERROR_FILE ]; then\n+ echo\n+ echo \"An error occurred while starting the tunnel. See error:\"\n+ cat $TUNNEL_LOG\n+ exit 5\n+fi\n+\n+while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do\n+ let \"counter++\"\n+\n+ if [ $counter -gt 240 ]; then\n+ echo\n+ echo \"Timed out after 2 minutes waiting for tunnel ready file\"\n+ exit 5\n+ fi\n+\n+ printf \".\"\n+ sleep .5\n+done\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/README.md",
"diff": "+# Continuous Integration Scripts\n+\n+This directory contains scripts that are related to CI only.\n+\n+### `build-and-test.sh`\n+\n+The main script. Setup the tests environment, build the files using the `angular-cli` tool and run the tests.\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/after-success.sh",
"diff": "+#!/bin/bash\n+\n+# Script which always runs when the current Travis mode succeeds.\n+# Used to run the travis-after-modes script, which checks if all other modes finished.\n+\n+# Go to the project root directory\n+cd $(dirname $0)/../..\n+\n+# If not running as a PR, wait for all other travis modes to finish.\n+if [ \"$TRAVIS_PULL_REQUEST\" = \"false\" ] && $(npm bin)/travis-after-modes; then\n+ echo \"All travis modes passed. Publishing the build artifacts...\"\n+ ./scripts/release/publish-build-artifacts.sh\n+fi\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/build-and-test.sh",
"diff": "+#!/usr/bin/env bash\n+set -ex\n+\n+echo \"======= Starting build-and-test.sh ========================================\"\n+\n+# Go to project dir\n+cd $(dirname $0)/../..\n+\n+# Include sources.\n+source scripts/ci/sources/mode.sh\n+source scripts/ci/sources/tunnel.sh\n+\n+start_tunnel\n+\n+wait_for_tunnel\n+if is_lint; then\n+ $(npm bin)/gulp ci:lint\n+elif is_e2e; then\n+ $(npm bin)/gulp ci:e2e\n+elif is_aot; then\n+ $(npm bin)/gulp ci:aot\n+elif is_payload; then\n+ $(npm bin)/gulp ci:payload\n+else\n+ $(npm bin)/gulp ci:test\n+fi\n+teardown_tunnel\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/forbidden-identifiers.js",
"diff": "+#!/usr/bin/env node\n+\n+'use strict';\n+\n+/*\n+ * The forbidden identifiers script will check for blocked statements and also detect invalid\n+ * imports of other scope packages.\n+ *\n+ * When running against a PR, the script will only analyze the specific amount of commits inside\n+ * of the Pull Request.\n+ *\n+ * By default it checks all source files and fail if any errors were found.\n+ */\n+\n+const child_process = require('child_process');\n+const fs = require('fs');\n+const path = require('path');\n+const glob = require('glob').sync;\n+\n+const blocked_statements = [\n+ '\\\\bddescribe\\\\(',\n+ '\\\\bfdescribe\\\\(',\n+ '\\\\biit\\\\(',\n+ '\\\\bfit\\\\(',\n+ '\\\\bxdescribe\\\\(',\n+ '\\\\bxit\\\\(',\n+ '\\\\bdebugger;',\n+ 'from \\\\\\'rxjs/Rx\\\\\\'',\n+ '\\\\r'\n+];\n+\n+const sourceFolders = ['./src', './e2e'];\n+const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');\n+\n+/*\n+ * Verify that the current PR is not adding any forbidden identifiers.\n+ * Run the forbidden identifiers check against all sources when not verifying a PR.\n+ */\n+\n+findTestFiles()\n+\n+ /* Only match .js or .ts, and remove .d.ts files. */\n+ .then(files => files.filter(name => /\\.(js|ts)$/.test(name) && !/\\.d\\.ts$/.test(name)))\n+\n+ /* Read content of the filtered files */\n+ .then(files => files.map(name => ({ name, content: fs.readFileSync(name, 'utf-8') })))\n+\n+ /* Run checks against content of the filtered files. */\n+ .then(diffList => findErrors(diffList))\n+\n+ /* Groups similar errors to simplify console output */\n+ .then(errors => groupErrors(errors))\n+\n+ /* Print the resolved errors to the console */\n+ .then(errors => printErrors(errors))\n+\n+ .catch(err => {\n+ // An error occurred in this script. Output the error and the stack.\n+ console.error(err.stack || err);\n+ process.exit(2);\n+ });\n+\n+/**\n+ * Finds errors inside of changed files by running them against the blocked statements.\n+ * @param {{name: string, content: string}[]} diffList\n+ */\n+function findErrors(diffList) {\n+ return diffList.reduce((errors, diffFile) => {\n+ let fileName = diffFile.name;\n+ let content = diffFile.content.split('\\n');\n+ let lineNumber = 0;\n+\n+ content.forEach(line => {\n+ lineNumber++;\n+\n+ let matches = line.match(blockedRegex);\n+\n+ if (matches) {\n+\n+ errors.push({\n+ fileName,\n+ lineNumber,\n+ statement: matches[0]\n+ });\n+\n+ }\n+ });\n+\n+ return errors;\n+\n+ }, []);\n+}\n+\n+/**\n+ * Groups similar errors in the same file which are present over a range of lines.\n+ * @param {{fileName: string, lineNumber: number, statement: string}[]} errors\n+ */\n+function groupErrors(errors) {\n+\n+ let initialError, initialLine, previousLine;\n+\n+ return errors.filter(error => {\n+\n+ if (initialError && isSimilarError(error)) {\n+ previousLine = error.lineNumber;\n+\n+ // Overwrite the lineNumber with a string, which indicates the range of lines.\n+ initialError.lineNumber = `${initialLine}-${previousLine}`;\n+\n+ return false;\n+ }\n+\n+ initialLine = previousLine = error.lineNumber;\n+ initialError = error;\n+\n+ return true;\n+ });\n+\n+ /** Checks whether the given error is similar to the previous one. */\n+ function isSimilarError(error) {\n+ return initialError.fileName === error.fileName &&\n+ initialError.statement === error.statement &&\n+ previousLine === (error.lineNumber - 1);\n+ }\n+}\n+\n+/**\n+ * Prints all errors to the console and terminates the process if errors were present.\n+ * @param {{fileName: string, lineNumber: number, statement: string}[]} errors\n+ */\n+function printErrors(errors) {\n+ if (errors.length > 0) {\n+\n+ console.error('Error: You are using one or more blocked statements:\\n');\n+\n+ errors.forEach(entry => {\n+\n+ // Stringify the statement to represent line-endings or other unescaped characters.\n+ let statement = JSON.stringify(entry.statement);\n+\n+ console.error(` ${entry.fileName}@${entry.lineNumber}, Statement: ${statement}.\\n`);\n+ });\n+\n+ // Exit the process with an error exit code to notify the CI.\n+ process.exit(1);\n+ }\n+}\n+\n+/**\n+ * Resolves all files, which should run against the forbidden identifiers check.\n+ * @return {Promise.<Array.<string>>} Files to be checked.\n+ */\n+function findTestFiles() {\n+ if (process.env['TRAVIS_PULL_REQUEST']) {\n+ return findChangedFiles();\n+ }\n+\n+ let files = sourceFolders.map(folder => {\n+ return glob(`${folder}/**/*`);\n+ }).reduce((files, fileSet) => files.concat(fileSet), []);\n+\n+ return Promise.resolve(files);\n+}\n+\n+/**\n+ * List all the files that have been changed or added in the last commit range.\n+ * @returns {Promise.<Array.<string>>} Resolves with a list of files that are added or changed.\n+ */\n+function findChangedFiles() {\n+ let commitRange = process.env['TRAVIS_COMMIT_RANGE'];\n+\n+ return exec(`git diff --name-status ${commitRange} ${sourceFolders.join(' ')}`)\n+ .then(rawDiff => {\n+ return rawDiff\n+ .split('\\n')\n+ .filter(line => {\n+ // Status: C## => Copied (##% confident)\n+ // R## => Renamed (##% confident)\n+ // D => Deleted\n+ // M => Modified\n+ // A => Added\n+ return line.match(/([CR][0-9]*|[AM])\\s+/);\n+ })\n+ .map(line => line.split(/\\s+/, 2)[1]);\n+ });\n+}\n+\n+/**\n+ * Executes a process command and wraps it inside of a promise.\n+ * @returns {Promise.<String>}\n+ */\n+function exec(cmd) {\n+ return new Promise(function(resolve, reject) {\n+ child_process.exec(cmd, function(err, stdout /*, stderr */) {\n+ if (err) {\n+ reject(err);\n+ } else {\n+ resolve(stdout);\n+ }\n+ });\n+ });\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/sources/mode.sh",
"diff": "+#!/usr/bin/env bash\n+source ./scripts/ci/sources/tunnel.sh\n+\n+is_e2e() {\n+ [[ \"$MODE\" = e2e ]]\n+}\n+\n+is_lint() {\n+ [[ \"$MODE\" = lint ]]\n+}\n+\n+is_aot() {\n+ [[ \"$MODE\" = aot ]]\n+}\n+\n+is_payload() {\n+ [[ \"$MODE\" = payload ]]\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/ci/sources/tunnel.sh",
"diff": "+#!/usr/bin/env bash\n+\n+\n+start_tunnel() {\n+ case \"$MODE\" in\n+ e2e*|saucelabs*)\n+ ./scripts/saucelabs/start-tunnel.sh\n+ ;;\n+ browserstack*)\n+ ./scripts/browserstack/start-tunnel.sh\n+ ;;\n+ *)\n+ ;;\n+ esac\n+}\n+\n+wait_for_tunnel() {\n+ case \"$MODE\" in\n+ e2e*|saucelabs*)\n+ ./scripts/saucelabs/wait-tunnel.sh\n+ ;;\n+ browserstack*)\n+ ./scripts/browserstack/wait-tunnel.sh\n+ ;;\n+ *)\n+ ;;\n+ esac\n+ sleep 10\n+}\n+\n+teardown_tunnel() {\n+ case \"$MODE\" in\n+ e2e*|saucelabs*)\n+ ./scripts/saucelabs/stop-tunnel.sh\n+ ;;\n+ browserstack*)\n+ ./scripts/browserstack/stop-tunnel.sh\n+ ;;\n+ *)\n+ ;;\n+ esac\n+}\n+\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/release/copy-docs.sh",
"diff": "+#!/bin/bash\n+\n+# Copy docs to material docs site\n+\n+# Run this script after `gulp docs`\n+# Need to specify destination folder\n+# Use OVERVIEW.html when possible. If there's no OVERVIEW file exists, use README.html\n+\n+usage='Usage: copy-docs.sh $destinationFolder'\n+if [ $# -ne 1 ]; then\n+ echo \"Missing destination folder. $usage\"\n+ exit\n+fi\n+\n+originFolder=./dist/docs/\n+destFolder=$1\n+\n+if [ ! -w $destFolder ]; then\n+ echo \"Invalid destination folder. $usage\"\n+ exit\n+fi\n+\n+for file in $originFolder*\n+do\n+ name=${file#$originFolder}\n+ overviewFile=$originFolder$name/OVERVIEW.html\n+ readmeFile=$originFolder$name/README.html\n+ destFile=$destFolder/$name.html\n+ if [ -f $overviewFile ]; then\n+ cp $overviewFile $destFile\n+ echo \"Copied $overviewFile to $destFile\"\n+ elif [ -f $readmeFile ]; then\n+ cp $readmeFile $destFile\n+ echo \"Copied $readmeFile to $destFile\"\n+ fi\n+done\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/release/publish-build-artifacts.sh",
"diff": "+#!/bin/bash\n+\n+# Script to publish the build artifacts to a GitHub repository.\n+# Builds will be automatically published once new changes are made to the repository.\n+\n+set -e -o pipefail\n+\n+# Go to the project root directory\n+cd $(dirname $0)/../..\n+\n+buildDir=\"dist/@angular/material\"\n+buildVersion=$(sed -nE 's/^\\s*\"version\": \"(.*?)\",$/\\1/p' package.json)\n+\n+commitSha=$(git rev-parse --short HEAD)\n+commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)\n+commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)\n+commitMessage=$(git log --oneline -n 1)\n+\n+repoName=\"material2-builds\"\n+repoUrl=\"https://github.com/angular/material2-builds.git\"\n+repoDir=\"tmp/$repoName\"\n+\n+# Create a release of the current repository.\n+$(npm bin)/gulp build:release\n+\n+# Prepare cloning the builds repository\n+rm -rf $repoDir\n+mkdir -p $repoDir\n+\n+# Clone the repository\n+git clone $repoUrl $repoDir\n+\n+# Copy the build files to the repository\n+rm -rf $repoDir/*\n+cp -r $buildDir/* $repoDir\n+\n+# Create the build commit and push the changes to the repository.\n+cd $repoDir\n+\n+# Prepare Git for pushing the artifacts to the repository.\n+git config user.name \"$commitAuthorName\"\n+git config user.email \"$commitAuthorEmail\"\n+git config credential.helper \"store --file=.git/credentials\"\n+\n+echo \"https://${MATERIAL2_BUILDS_TOKEN}:@github.com\" > .git/credentials\n+\n+git add -A\n+git commit -m \"$commitMessage\"\n+git tag \"$buildVersion-$commitSha\"\n+git push origin master --tags\n+\n+echo \"Finished publishing build artifacts\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/saucelabs/sauce_config.js",
"diff": "+module.exports = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/saucelabs/start-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+set -e -o pipefail\n+\n+# Setup and start Sauce Connect for your TravisCI build\n+# This script requires your .travis.yml to include the following two private env variables:\n+# SAUCE_USERNAME\n+# SAUCE_ACCESS_KEY\n+# Follow the steps at https://saucelabs.com/opensource/travis to set that up.\n+#\n+# Curl and run this script as part of your .travis.yml before_script section:\n+# before_script:\n+# - curl https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh | bash\n+\n+CONNECT_DIR=\"/tmp/sauce-connect-$RANDOM\"\n+CONNECT_DOWNLOAD=\"sc-latest-linux.tar.gz\"\n+\n+CONNECT_LOG=\"$LOGS_DIR/sauce-connect\"\n+CONNECT_STDOUT=\"$LOGS_DIR/sauce-connect.stdout\"\n+CONNECT_STDERR=\"$LOGS_DIR/sauce-connect.stderr\"\n+\n+# Get the appropriate URL for downloading Sauce Connect\n+if [ `uname -s` = \"Darwin\" ]; then\n+ # If the user is running Mac, download the OSX version\n+ # https://en.wikipedia.org/wiki/Darwin_(operating_system)\n+ CONNECT_URL=\"https://saucelabs.com/downloads/sc-4.4.2-osx.zip\"\n+else\n+ # Otherwise, default to Linux for Travis-CI\n+ CONNECT_URL=\"https://saucelabs.com/downloads/sc-4.4.2-linux.tar.gz\"\n+fi\n+mkdir -p $CONNECT_DIR\n+cd $CONNECT_DIR\n+curl $CONNECT_URL -o $CONNECT_DOWNLOAD 2> /dev/null 1> /dev/null\n+mkdir sauce-connect\n+tar --extract --file=$CONNECT_DOWNLOAD --strip-components=1 --directory=sauce-connect > /dev/null\n+rm $CONNECT_DOWNLOAD\n+\n+\n+SAUCE_ACCESS_KEY=`echo $SAUCE_ACCESS_KEY | rev`\n+\n+ARGS=\"\"\n+\n+# Set tunnel-id only on Travis, to make local testing easier.\n+if [ ! -z \"$TRAVIS_JOB_NUMBER\" ]; then\n+ ARGS=\"$ARGS --tunnel-identifier $TRAVIS_JOB_NUMBER\"\n+fi\n+if [ ! -z \"$BROWSER_PROVIDER_READY_FILE\" ]; then\n+ ARGS=\"$ARGS --readyfile $BROWSER_PROVIDER_READY_FILE\"\n+fi\n+\n+\n+echo \"Starting Sauce Connect in the background, logging into:\"\n+echo \" $CONNECT_LOG\"\n+echo \" $CONNECT_STDOUT\"\n+echo \" $CONNECT_STDERR\"\n+echo \" ---\"\n+echo \" $ARGS\"\n+sauce-connect/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY $ARGS \\\n+ --logfile $CONNECT_LOG 2> $CONNECT_STDERR 1> $CONNECT_STDOUT &\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/saucelabs/stop-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+set -e -o pipefail\n+\n+\n+echo \"Shutting down Sauce Connect tunnel\"\n+\n+killall sc\n+\n+while [[ -n `ps -ef | grep \"sauce-connect-\" | grep -v \"grep\"` ]]; do\n+ printf \".\"\n+ sleep .5\n+done\n+\n+echo \"\"\n+echo \"Sauce Connect tunnel has been shut down\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/saucelabs/wait-tunnel.sh",
"diff": "+#!/bin/bash\n+\n+# Wait for Connect to be ready before exiting\n+echo \"Connecting to Sauce Labs\"\n+\n+\n+# Wait for Saucelabs Connect to be ready before exiting\n+# Time out if we wait for more than 2 minutes, so the process won't run forever.\n+let \"counter=0\"\n+\n+while [ ! -f $BROWSER_PROVIDER_READY_FILE ]; do\n+ let \"counter++\"\n+\n+ if [ $counter -gt 240 ]; then\n+ echo\n+ echo \"Timed out after 2 minutes waiting for tunnel ready file\"\n+ exit 5\n+ fi\n+\n+ printf \".\"\n+ sleep .5\n+done\n+\n+echo\n+echo \"Connected\"\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update script tasks |
530,388 | 07.01.2017 10:00:30 | -19,080 | a9cb10a6ce3fdcccc970329c1baf8bb9646fde0f | chore: update select structure | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.html",
"new_path": "src/lib/select/select.html",
"diff": "<div class=\"md2-select-trigger\" cdk-overlay-origin (click)=\"toggle()\" #origin=\"cdkOverlayOrigin\" #trigger>\n- <span class=\"md2-select-placeholder\" [class.md2-floating-placeholder]=\"this.selected.length\"\n+ <span class=\"md2-select-placeholder\" [class.md2-floating-placeholder]=\"selected.length\"\n[@transformPlaceholder]=\"_placeholderState\" [style.width.px]=\"_selectedValueWidth\">{{ placeholder }}</span>\n<span class=\"md2-select-value\">\n<span class=\"md2-select-value-text\" *ngFor=\"let option of selected\"> {{ option.viewValue }} </span>\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update select structure |
530,388 | 07.01.2017 10:43:31 | -19,080 | 20ff1f89dce479b131f5953957dfa6a4a3491d11 | chore(pagination) update style | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/pagination.scss",
"new_path": "src/lib/data-table/pagination.scss",
"diff": "+$primary: #106cc8 !default;\n+\nmd2-pagination {\ndisplay: block;\n- color: #0e59a5;\n- -webkit-user-select: none;\n- -moz-user-select: none;\n- -ms-user-select: none;\n+ color: $primary;\nuser-select: none;\n}\n@@ -36,7 +35,7 @@ md2-pagination .md2-pagination li {\n}\nmd2-pagination .md2-pagination li:hover {\n- background: rgba(0, 0, 0, 0.12);\n+ background: rgba(black, 0.12);\n}\nmd2-pagination .md2-pagination li.disabled,\n@@ -44,13 +43,13 @@ md2-pagination .md2-pagination li.disabled:hover {\npointer-events: none;\nbackground: transparent;\ncursor: default;\n- opacity: 0.5;\n+ opacity: 0.48;\n}\nmd2-pagination .md2-pagination li.active,\nmd2-pagination .md2-pagination li.active:hover {\n- background: #106cc8;\n- color: #fff;\n+ background: $primary;\n+ color: white;\ncursor: default;\n}\n@@ -64,7 +63,7 @@ md2-pagination .md2-rows-select {\nmargin: 8px 0;\npadding: 0;\nfloat: right;\n- color: rgba(0, 0, 0, 0.54);\n+ color: rgba(black, 0.54);\nline-height: 36px;\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(pagination) update style |
530,387 | 08.01.2017 08:27:05 | -7,200 | 93b5fce24863c470aa8982c658d9c619e7ee54af | Update README.md (solves issue | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -16,7 +16,7 @@ Angular2 based Material Design components, directives and services are Accordion\n// ================\n{\nmap: {\n- 'md2': 'node_modules/md2'\n+ 'md2': 'node_modules/md2/bundles'\n},\npackages: {\n'md2': {\n"
}
] | TypeScript | MIT License | promact/md2 | Update README.md (solves issue #51) |
530,388 | 09.01.2017 10:52:16 | -19,080 | 0deba4524829704a48c24b3770a5ae0febade129 | chore: update redmi.md for system js configuration. | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -16,13 +16,7 @@ Angular2 based Material Design components, directives and services are Accordion\n// ================\n{\nmap: {\n- 'md2': 'node_modules/md2/bundles'\n- },\n- packages: {\n- 'md2': {\n- format: 'cjs',\n- main: 'md2.umd.js'\n- }\n+ 'md2': 'md2/bundles/md2.umd.js'\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update redmi.md for system js configuration. |
530,388 | 10.01.2017 18:46:34 | -19,080 | ddb12c00297512a6f85056e028157d800932be3b | chore(data-table) added shrt directive as separate. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/lib/data-table/sort.html",
"diff": "+<span (click)=\"_sort()\">\n+ <ng-content></ng-content>\n+ <svg *ngIf=\"_isAsc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n+ <path d=\"M7 14l5-5 5 5z\" />\n+ </svg>\n+ <svg *ngIf=\"_isDesc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n+ <path d=\"M7 10l5 5 5-5z\" />\n+ </svg>\n+ <svg *ngIf=\"!_isAsc && !_isDesc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n+ <path d=\"M7,10.5l5-5l5,5H7z\" />\n+ <path d=\"M7,12.5l5,5l5-5H7z\" />\n+ </svg>\n+</span>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/lib/data-table/sort.ts",
"diff": "+import {\n+ Component,\n+ Input,\n+ OnInit,\n+ ViewEncapsulation\n+} from '@angular/core';\n+import { Md2DataTable, SortEvent } from './data-table';\n+\n+@Component({\n+ selector: '[md2SortField]',\n+ templateUrl: 'sort.html',\n+ styleUrls: ['data-table.scss'],\n+ encapsulation: ViewEncapsulation.None\n+})\n+export class Md2DataTableSortField implements OnInit {\n+\n+ @Input('md2SortField') sortField: string;\n+\n+ _isAsc: boolean = false;\n+ _isDesc: boolean = false;\n+\n+ public constructor(private _md2Table: Md2DataTable) {\n+ }\n+\n+ public ngOnInit(): void {\n+ this._md2Table.onSortChange.subscribe((event: SortEvent) => {\n+ this._isAsc = (event.sortBy === this.sortField && event.sortOrder === 'asc');\n+ this._isDesc = (event.sortBy === this.sortField && event.sortOrder === 'desc');\n+ });\n+ }\n+\n+ _sort() {\n+ if (this._isAsc) {\n+ this._md2Table.setSort(this.sortField, 'desc');\n+ } else {\n+ this._md2Table.setSort(this.sortField, 'asc');\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) added shrt directive as separate. |
530,388 | 12.01.2017 15:09:33 | -19,080 | eb6615e481bda7374110344f62ab0ebc67b9553c | chore(data-table) update basic functionality and inputs renamed with camelCase | [
{
"change_type": "MODIFY",
"old_path": "src/demo-app/data-table/data-table-demo.html",
"new_path": "src/demo-app/data-table/data-table-demo.html",
"diff": "<hr />\n<h4>Basic</h4>\n<div>\n- <table [md2-data]=\"data | dataPipe : search\" #md2=\"Md2DataTable\" [md2-page-length]=\"10\">\n+ <table [md2Data]=\"data | dataPipe : search\" #md2=\"md2DataTable\" [rowsPerPage]=\"10\">\n<thead>\n<tr>\n<td colspan=\"4\">\n</td>\n</tr>\n<tr>\n- <th style=\"width: 20%\" md2-sort-field=\"name\">Name</th>\n- <th style=\"width: 50%\" md2-sort-field=\"email\">Email</th>\n- <th style=\"width: 10%\" md2-sort-field=\"age\">Age</th>\n- <th style=\"width: 20%\" md2-sort-field=\"city\">City</th>\n+ <th style=\"width: 20%\" md2SortBy=\"name\">Name</th>\n+ <th style=\"width: 50%\" md2SortBy=\"email\">Email</th>\n+ <th style=\"width: 10%\" md2SortBy=\"age\">Age</th>\n+ <th style=\"width: 20%\" md2SortBy=\"city\">City</th>\n</tr>\n</thead>\n<tbody>\n<tfoot>\n<tr>\n<td colspan=\"4\">\n- <md2-pagination [md2-rows]=\"[5,10,15]\"></md2-pagination>\n+ <md2-pagination [rowsPerPageSet]=\"[5,10,15]\"></md2-pagination>\n</td>\n</tr>\n</tfoot>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/README.md",
"new_path": "src/lib/data-table/README.md",
"diff": "@@ -6,33 +6,35 @@ Data Table is a arrange data in ordering searching and paginate it.\n| Name | Type | Description |\n| --- | --- | --- |\n-| `md2-data` | `Array<any>` | List of array data assign for datatable |\n-| `md2-page-length` | `number` | Number of rows per page |\n+| `md2Data` | `Array<any>` | List of array data assign for datatable |\n+| `rowsPerPage` | `number` | Number of rows per page |\n| `activePage` | `number` | Number of active page |\n+| `sortBy` | `string` or `Array<string>` | Sort by parameter(s) |\n+| `sortOrder` | `string` | Sort order parameters are 'asc' or 'desc' |\n### Examples\nA Datatable would have the following markup.\n```html\n<table class=\"table table-striped\"\n- [md2-data]=\"data\"\n- #md2=\"Md2DataTable\"\n- [md2-page-length]=\"10\"\n- [(activePage)]=\"activePage\">\n+ [md2Data]=\"data\"\n+ #md2=\"md2DataTable\"\n+ [rowsPerPage]=\"10\"\n+ [activePage]=\"activePage\">\n...\n</table>\n```\n-## `[md2-sort-field]`\n+## `[md2SortBy]`\n### Properties\n| Name | Type | Description |\n| --- | --- | --- |\n-| `md2-sort-field` | `string` | field for sorting data |\n+| `md2SortBy` | `string` | Sort by parameter |\n### Examples\nA directive would have the following markup.\n```html\n-<th md2-sort-field=\"name\">Name</th>\n+<th md2SortBy=\"name\">Name</th>\n```\n## `<md2-pagination>`\n@@ -40,8 +42,8 @@ A directive would have the following markup.\n| Name | Type | Description |\n| --- | --- | --- |\n-| `md2-rows` | `Array<string>` | Number of rows on page set list |\n-| `md2-table` | `Md2DataTable` | reference of Md2DataTable |\n+| `rowsPerPageSet` | `Array<string>` | Number of rows per page set list |\n+| `md2Table` | `Md2DataTable` | reference of Md2DataTable |\n### Events\n@@ -58,16 +60,16 @@ A pagination would have the following markup.\n### Examples\nA data-table would have the following markup.\n```html\n-<table [md2-data]=\"data\"\n- #md2=\"Md2DataTable\"\n- [md2-page-length]=\"10\"\n+<table [md2Data]=\"data\"\n+ #md2=\"md2DataTable\"\n+ [rowsPerPage]=\"10\"\n[(activePage)]=\"activePage\">\n<thead>\n<tr>\n- <th md2-sort-field=\"name\">Name</th>\n- <th md2-sort-field=\"email\">Email</th>\n- <th md2-sort-field=\"age\">Age</th>\n- <th md2-sort-field=\"city\">City</th>\n+ <th md2SortBy=\"name\">Name</th>\n+ <th md2SortBy=\"email\">Email</th>\n+ <th md2SortBy=\"age\">Age</th>\n+ <th md2SortBy=\"city\">City</th>\n</tr>\n</thead>\n<tbody>\n@@ -81,7 +83,7 @@ A data-table would have the following markup.\n<tfoot>\n<tr>\n<td colspan=\"4\">\n- <md2-pagination [md2-rows]=\"[5,10,15]\"></md2-pagination>\n+ <md2-pagination [rowsPerPageSet]=\"[5,10,15]\"></md2-pagination>\n</td>\n</tr>\n</tfoot>\n"
},
{
"change_type": "RENAME",
"old_path": "src/lib/data-table/pagination.scss",
"new_path": "src/lib/data-table/data-table.scss",
"diff": "$primary: #106cc8 !default;\n+/*\n+ * Data Table\n+ */\n+\n+\n+/*\n+ * Sort\n+ */\n+[md2SortBy] span {\n+ position: relative;\n+ display: block;\n+ line-height: 24px;\n+ white-space: nowrap;\n+ cursor: pointer;\n+ user-select: none;\n+}\n+\n+[md2SortBy] span svg {\n+ display: inline-block;\n+ vertical-align: middle;\n+ fill: currentColor;\n+}\n+\n+\n+/*\n+ * Pagination\n+ */\nmd2-pagination {\ndisplay: block;\ncolor: $primary;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "import {\nComponent,\nDirective,\n+ EventEmitter,\nInput,\nOutput,\n- EventEmitter,\n+ OnInit,\nSimpleChange,\nOnChanges,\nOptional,\nDoCheck,\n+ IterableDiffers,\n+ IterableDiffer,\n+ ViewEncapsulation,\nNgModule,\nModuleWithProviders,\n- ViewEncapsulation,\n} from '@angular/core';\n+import { ReplaySubject } from 'rxjs/Rx';\nimport { CommonModule } from '@angular/common';\n+export class Md2PaginationChange {\n+ source: Md2Pagination;\n+ activePage: number;\n+}\n+\nexport interface SortEvent {\n- sortField: string | string[];\n+ sortBy: string | string[];\nsortOrder: string;\n}\nexport interface PageEvent {\nactivePage: number;\n- pageLength: number;\n+ rowsPerPage: number;\ndataLength: number;\n}\n@@ -30,247 +39,275 @@ export interface DataEvent {\n}\n@Directive({\n- selector: 'table[md2-data]',\n- exportAs: 'Md2DataTable'\n+ selector: 'table[md2Data]',\n+ exportAs: 'md2DataTable'\n})\nexport class Md2DataTable implements OnChanges, DoCheck {\n- private _dataLength = 0;\n- private _activePage: number = 1;\n+ private diff: IterableDiffer;\n+\n+ @Input('md2Data') inputData: any[] = [];\n+ @Input() rowsPerPage = 1000;\n+ @Input() activePage = 1;\n+ @Input() sortBy: string | string[] = '';\n+ @Input() sortOrder = 'asc';\n+\n+ @Output() sortByChange = new EventEmitter<string | string[]>();\n+ @Output() sortOrderChange = new EventEmitter<string>();\n+\n+ private mustRecalculateData = false;\ndata: any[];\n- onDataChange = new EventEmitter<DataEvent>();\n- onSortChange = new EventEmitter<SortEvent>();\n- onPageChange = new EventEmitter<PageEvent>();\n- private sortField: string | string[] = '';\n- private sortOrder = 'asc';\n- private isDataChanged = false;\n+ onSortChange = new ReplaySubject<SortEvent>(1);\n+ onPageChange = new EventEmitter<PageEvent>();\n- @Input('md2-data') inputData: any[] = [];\n- @Input('md2-page-length') pageLength = 1000;\n- @Input()\n- get activePage(): number { return this._activePage; }\n- set activePage(value: number) {\n- if (this._activePage !== value) {\n- this._activePage = value;\n- this.activePageChange.emit(value);\n+ constructor(private differs: IterableDiffers) {\n+ this.diff = differs.find([]).create(null);\n}\n- }\n-\n- @Output() activePageChange: EventEmitter<any> = new EventEmitter<any>();\ngetSort(): SortEvent {\n- return { sortField: this.sortField, sortOrder: this.sortOrder };\n+ return { sortBy: this.sortBy, sortOrder: this.sortOrder };\n}\n- setSort(sortField: string | string[], sortOrder: string): void {\n- if (this.sortField !== sortField || this.sortOrder !== sortOrder) {\n- this.sortField = sortField;\n- this.sortOrder = sortOrder;\n- this.isDataChanged = true;\n- this.onSortChange.emit({ sortField: sortField, sortOrder: sortOrder });\n+ setSort(sortBy: string | string[], sortOrder: string) {\n+ if (this.sortBy !== sortBy || this.sortOrder !== sortOrder) {\n+ this.sortBy = sortBy;\n+ this.sortOrder = sortOrder;// _.includes(['asc', 'desc'], sortOrder) ? sortOrder : 'asc';\n+ this.mustRecalculateData = true;\n+ this.onSortChange.next({ sortBy: sortBy, sortOrder: sortOrder });\n+ this.sortByChange.emit(this.sortBy);\n+ this.sortOrderChange.emit(this.sortOrder);\n}\n}\ngetPage(): PageEvent {\n- return {\n- activePage: this.activePage,\n- pageLength: this.pageLength,\n- dataLength: this.inputData.length\n- };\n+ return { activePage: this.activePage, rowsPerPage: this.rowsPerPage, dataLength: this.inputData.length };\n}\n- setPage(activePage: number, pageLength: number): void {\n- if (this.pageLength !== pageLength || this.activePage !== activePage) {\n- this.activePage = this.activePage !== activePage ?\n- activePage : this.calculateNewActivePage(this.pageLength, pageLength);\n- this.pageLength = pageLength;\n- this.isDataChanged = true;\n- this._emitPageChangeEvent();\n- }\n- }\n-\n- _emitPageChangeEvent(): void {\n+ setPage(activePage: number, rowsPerPage: number): void {\n+ if (this.rowsPerPage !== rowsPerPage || this.activePage !== activePage) {\n+ this.activePage = this.activePage !== activePage ? activePage : this.calculateNewActivePage(this.rowsPerPage, rowsPerPage);\n+ this.rowsPerPage = rowsPerPage;\n+ this.mustRecalculateData = true;\nthis.onPageChange.emit({\nactivePage: this.activePage,\n- pageLength: this.pageLength,\n- dataLength: this.inputData.length\n+ rowsPerPage: this.rowsPerPage,\n+ dataLength: this.inputData ? this.inputData.length : 0\n});\n}\n+ }\n- private calculateNewActivePage(previousPageLength: number,\n- currentPageLength: number): number {\n- let firstRowOnPage = (this.activePage - 1) * previousPageLength + 1;\n- let newActivePage = Math.ceil(firstRowOnPage / currentPageLength);\n+ private calculateNewActivePage(previousRowsPerPage: number, currentRowsPerPage: number): number {\n+ let firstRowOnPage = (this.activePage - 1) * previousRowsPerPage + 1;\n+ let newActivePage = Math.ceil(firstRowOnPage / currentRowsPerPage);\nreturn newActivePage;\n}\nprivate recalculatePage() {\n- let _lastPage = Math.ceil(this.inputData.length / this.pageLength);\n- this.activePage = _lastPage < this.activePage ? _lastPage : this.activePage;\n+ let lastPage = Math.ceil(this.inputData.length / this.rowsPerPage);\n+ this.activePage = lastPage < this.activePage ? lastPage : this.activePage;\nthis.activePage = this.activePage || 1;\n+\n+ this.onPageChange.emit({\n+ activePage: this.activePage,\n+ rowsPerPage: this.rowsPerPage,\n+ dataLength: this.inputData.length\n+ });\n}\nngOnChanges(changes: { [key: string]: SimpleChange }): any {\n+ if (changes['rowsPerPage']) {\n+ this.rowsPerPage = changes['rowsPerPage'].previousValue;\n+ this.setPage(this.activePage, changes['rowsPerPage'].currentValue);\n+ this.mustRecalculateData = true;\n+ }\n+ if (changes['sortBy'] || changes['sortOrder']) {\n+ //if (!_.includes(['asc', 'desc'], this.sortOrder)) {\n+ // console.warn('md2-data-table: value md2SortOrder must be one of [\"asc\", \"desc\"], but is:', this.sortOrder);\n+ // this.sortOrder = 'asc';\n+ //}\n+ if (this.sortBy) {\n+ this.onSortChange.next({ sortBy: this.sortBy, sortOrder: this.sortOrder });\n+ }\n+ this.mustRecalculateData = true;\n+ }\nif (changes['inputData']) {\nthis.inputData = changes['inputData'].currentValue || [];\n- if (this.inputData.length > 0) {\nthis.recalculatePage();\n- this._emitPageChangeEvent();\n- this.isDataChanged = true;\n- }\n+ this.mustRecalculateData = true;\n}\n}\nngDoCheck(): any {\n- if (this._dataLength !== this.inputData.length) {\n- this._dataLength = this.inputData.length;\n- this.fillData();\n+ let changes = this.diff.diff(this.inputData);\n+ if (changes) {\nthis.recalculatePage();\n- this._emitPageChangeEvent();\n- this.isDataChanged = true;\n+ this.mustRecalculateData = true;\n}\n- if (this.isDataChanged) {\n+ if (this.mustRecalculateData) {\nthis.fillData();\n- this.isDataChanged = false;\n+ this.mustRecalculateData = false;\n}\n}\nprivate fillData(): void {\nthis.activePage = this.activePage;\n- this.pageLength = this.pageLength;\n+ this.rowsPerPage = this.rowsPerPage;\n- let offset = (this.activePage - 1) * this.pageLength;\n+ let offset = (this.activePage - 1) * this.rowsPerPage;\nlet data = this.inputData;\n- let sortField = this.sortField;\n- if (sortField) {\n+ let sortBy = this.sortBy;\n+ //if (typeof sortBy === 'string' || sortBy instanceof String) {\n+ // data = _.orderBy(data, this.caseInsensitiveIteratee(<string>sortBy), [this.sortOrder]);\n+ //} else {\n+ // data = _.orderBy(data, sortBy, [this.sortOrder]);\n+ //}\n+ if (sortBy) {\ndata = data.sort((a: any, b: any) => {\n- let x = isNaN(a[sortField + '']) ? a[sortField + ''].toLowerCase() : a[sortField + ''];\n- let y = isNaN(b[sortField + '']) ? b[sortField + ''].toLowerCase() : b[sortField + ''];\n+ let x = isNaN(a[sortBy + '']) ? a[sortBy + ''].toLowerCase() : a[sortBy + ''];\n+ let y = isNaN(b[sortBy + '']) ? b[sortBy + ''].toLowerCase() : b[sortBy + ''];\nreturn (x > y) ? 1 : (y > x) ? -1 : 0;\n});\n}\nif (this.sortOrder === 'desc') { data.reverse(); }\n- this.data = data.slice(offset, offset + this.pageLength);\n+ this.data = data.slice(offset, offset + this.rowsPerPage);\n}\n+ private caseInsensitiveIteratee(sortBy: string) {\n+ return (row: any): any => {\n+ let value = row;\n+ for (let sortByProperty of sortBy.split('.')) {\n+ value = value[sortByProperty];\n+ }\n+ if (value && typeof value === 'string' || value instanceof String) {\n+ return value.toLowerCase();\n+ }\n+ return value;\n+ };\n+ }\n}\n@Component({\n- selector: '[md2-sort-field]',\n- template: `\n- <span (click)=\"_sort()\">\n- <ng-content></ng-content>\n- <svg *ngIf=\"_isAsc\" width=\"24\"height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7 14l5-5 5 5z\"/>\n- </svg>\n- <svg *ngIf=\"_isDesc\" width=\"24\"height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7 10l5 5 5-5z\"/>\n- </svg>\n- <svg *ngIf=\"!_isAsc && !_isDesc\" width=\"24\"height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7,10.5l5-5l5,5H7z\"/>\n- <path d=\"M7,12.5l5,5l5-5H7z\"/>\n- </svg>\n- </span>\n- `,\n- styles: [`\n- [md2-sort-field] span {\n- position: relative;\n- display: block;\n- line-height: 24px;\n- white-space: nowrap;\n- cursor: pointer;\n- -webkit-user-select: none;\n- -moz-user-select: none;\n- -ms-user-select: none;\n- user-select: none;\n- }\n- [md2-sort-field] span svg {\n- display: inline-block;\n- vertical-align: middle;\n- fill: currentColor;\n- }\n- `],\n+ selector: '[md2SortBy]',\n+ templateUrl: 'sort.html',\n+ styleUrls: ['data-table.scss'],\nencapsulation: ViewEncapsulation.None\n})\n-export class Md2DataTableSortField {\n+export class Md2DataTableSortBy implements OnInit {\n+\n+ @Input() md2SortBy: string;\n+\n_isAsc: boolean = false;\n_isDesc: boolean = false;\n- @Input('md2-sort-field') sortField: string;\n-\nconstructor(private _md2Table: Md2DataTable) {\n- _md2Table.onSortChange.subscribe((event: SortEvent) => {\n- this._isAsc = (event.sortField === this.sortField && event.sortOrder === 'asc');\n- this._isDesc = (event.sortField === this.sortField && event.sortOrder === 'desc');\n+ }\n+\n+ ngOnInit() {\n+ this._md2Table.onSortChange.subscribe((event: SortEvent) => {\n+ this._isAsc = (event.sortBy === this.md2SortBy && event.sortOrder === 'asc');\n+ this._isDesc = (event.sortBy === this.md2SortBy && event.sortOrder === 'desc');\n});\n}\n_sort() {\nif (this._isAsc) {\n- this._md2Table.setSort(this.sortField, 'desc');\n+ this._md2Table.setSort(this.md2SortBy, 'desc');\n} else {\n- this._md2Table.setSort(this.sortField, 'asc');\n+ this._md2Table.setSort(this.md2SortBy, 'asc');\n}\n}\n+\n}\n@Component({\nselector: 'md2-pagination',\ntemplateUrl: 'pagination.html',\n- styleUrls: ['pagination.css'],\n+ styleUrls: ['data-table.css'],\n+ //exportAs: 'md2Pagination',\nencapsulation: ViewEncapsulation.None\n})\n-export class Md2Pagination implements OnChanges {\n+export class Md2Pagination {\n- private _md2Table: Md2DataTable;\n- _activePage: number;\n- _rows: number;\n- _lastPage: number;\n- _dataLength: number = 0;\n+ private _activePage: number = 1;\n+\n+ _onChange = (value: any) => { };\n+ _onTouched = () => { };\n+\n+ //@Output() change: EventEmitter<Md2PaginationChange> = new EventEmitter<Md2PaginationChange>();\n- @Output() change: EventEmitter<any> = new EventEmitter<any>();\n+ @Input() rowsPerPageSet: any = [];\n+ @Input('md2Table') md2DataTable: Md2DataTable;\n- @Input('md2-rows') rows: any = [];\n- @Input('md2-table') md2InputTable: Md2DataTable;\n+ //@Input()\n+ get activePage() { return this._activePage; }\n+ set activePage(value: number) {\n+ if (this._activePage !== value) {\n+ this._activePage = value;\n+ }\n+ }\n- constructor( @Optional() private _injectMd2Table: Md2DataTable) { }\n+ minRowsPerPage = 0;\n+\n+ private mfTable: Md2DataTable;\n+\n+ _rowsPerPage: number;\n+ _dataLength: number = 0;\n+ _lastPage: number;\n- ngAfterViewInit() {\n- this._md2Table = this.md2InputTable || this._injectMd2Table;\n- this._onPageChange(this._md2Table.getPage());\n- this._md2Table.onPageChange.subscribe(this._onPageChange);\n+ constructor( @Optional() private _dataTable: Md2DataTable) {\n}\n- ngOnChanges(changes: any): any {\n- this._md2Table = this.md2InputTable || this._injectMd2Table;\n- this._onPageChange(this._md2Table.getPage());\n- this._md2Table.onPageChange.subscribe(this._onPageChange);\n+ ngDoCheck() {//changes: any\n+ //if (changes.rowsPerPageSet) {\n+ // this.minRowsPerPage = _.min(this.rowsPerPageSet)\n+ //}\n+ this.mfTable = this.md2DataTable || this._dataTable;\n+ this.onPageChangeSubscriber(this.mfTable.getPage());\n+ this.mfTable.onPageChange.subscribe(this.onPageChangeSubscriber);\n}\n- _setPage(page: number): void {\n- this._md2Table.setPage(page, this._rows);\n- this.change.emit(page);\n+ _setPage(pageNumber: number): void {\n+ this.mfTable.setPage(pageNumber, this._rowsPerPage);\n}\n_setRows(event: any): void {\nevent.stopPropagation();\n- this._md2Table.setPage(this._activePage, event.target.value);\n- this.change.emit(this._activePage);\n+ this.mfTable.setPage(this.activePage, event.target.value);\n}\n- private _onPageChange = (event: PageEvent) => {\n- this._activePage = event.activePage;\n- this._rows = event.pageLength;\n+ private onPageChangeSubscriber = (event: PageEvent) => {\n+ this.activePage = event.activePage;\n+ this._rowsPerPage = event.rowsPerPage;\nthis._dataLength = event.dataLength;\n- this._lastPage = Math.ceil(this._dataLength / this._rows);\n- }\n+ this._lastPage = Math.ceil(this._dataLength / this._rowsPerPage);\n+ };\n+\n+\n+ //_emitChangeEvent(): void {\n+ // let event = new Md2PaginationChange();\n+ // event.source = this;\n+ // event.activePage = this._activePage;\n+ // this._onChange(event.activePage);\n+ // this.change.emit(event);\n+ //}\n+\n+ //writeValue(value: number): void {\n+ // if (this._activePage !== value) {\n+ // this._activePage = value;\n+ // }\n+ //}\n+\n+ //registerOnChange(fn: (value: any) => void): void { this._onChange = fn; }\n+\n+ //registerOnTouched(fn: () => {}): void { this._onTouched = fn; }\n+\n}\nexport const MD2_DATA_TABLE_DIRECTIVES: any[] = [\nMd2DataTable,\n- Md2DataTableSortField,\n+ Md2DataTableSortBy,\nMd2Pagination\n];\n"
},
{
"change_type": "DELETE",
"old_path": "src/lib/data-table/sort.ts",
"new_path": null,
"diff": "-import {\n- Component,\n- Input,\n- OnInit,\n- ViewEncapsulation\n-} from '@angular/core';\n-import { Md2DataTable, SortEvent } from './data-table';\n-\n-@Component({\n- selector: '[md2SortField]',\n- templateUrl: 'sort.html',\n- styleUrls: ['data-table.scss'],\n- encapsulation: ViewEncapsulation.None\n-})\n-export class Md2DataTableSortField implements OnInit {\n-\n- @Input('md2SortField') sortField: string;\n-\n- _isAsc: boolean = false;\n- _isDesc: boolean = false;\n-\n- public constructor(private _md2Table: Md2DataTable) {\n- }\n-\n- public ngOnInit(): void {\n- this._md2Table.onSortChange.subscribe((event: SortEvent) => {\n- this._isAsc = (event.sortBy === this.sortField && event.sortOrder === 'asc');\n- this._isDesc = (event.sortBy === this.sortField && event.sortOrder === 'desc');\n- });\n- }\n-\n- _sort() {\n- if (this._isAsc) {\n- this._md2Table.setSort(this.sortField, 'desc');\n- } else {\n- this._md2Table.setSort(this.sortField, 'asc');\n- }\n- }\n-\n-}\n\\ No newline at end of file\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) update basic functionality and inputs renamed with camelCase |
530,388 | 12.01.2017 18:30:47 | -19,080 | 90da4d7cbea1db15bd269ac493ef680a5fda5fd5 | chore(data-table) update core functionality | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -45,19 +45,38 @@ export interface DataEvent {\nexport class Md2DataTable implements OnChanges, DoCheck {\nprivate diff: IterableDiffer;\n+ private isDataChanged = false;\n- @Input('md2Data') inputData: any[] = [];\n- @Input() rowsPerPage = 1000;\n- @Input() activePage = 1;\n+ private _activePage: number = 1;\n+\n+ data: any[];\n+\n+ @Input() md2Data: any[] = [];\n+ @Input() rowsPerPage: number = 1000;\n+ //@Input() activePage: number = 1;\n@Input() sortBy: string | string[] = '';\n- @Input() sortOrder = 'asc';\n+ @Input() sortOrder: string = 'asc';\n- @Output() sortByChange = new EventEmitter<string | string[]>();\n- @Output() sortOrderChange = new EventEmitter<string>();\n+ @Input()\n+ get activePage() { return this._activePage; }\n+ set activePage(value: number) {\n+ console.log('Active Page: ' + value);\n+ if (this._activePage !== value) {\n+ this._activePage = value;\n+ }\n+ }\n- private mustRecalculateData = false;\n+ //@Input()\n+ //get rowsPerPage() { return this._rowsPerPage; }\n+ //set rowsPerPage(value: number) {\n+ // if (this._rowsPerPage !== value) {\n+ // this._rowsPerPage = value;\n+ // }\n+ //}\n- data: any[];\n+ @Output() activePageChange = new EventEmitter<number>();\n+ @Output() sortByChange = new EventEmitter<string | string[]>();\n+ @Output() sortOrderChange = new EventEmitter<string>();\nonSortChange = new ReplaySubject<SortEvent>(1);\nonPageChange = new EventEmitter<PageEvent>();\n@@ -66,6 +85,43 @@ export class Md2DataTable implements OnChanges, DoCheck {\nthis.diff = differs.find([]).create(null);\n}\n+ ngOnChanges(changes: { [key: string]: SimpleChange }): any {\n+ console.log('ngOnChanges');\n+ if (changes['rowsPerPage']) {\n+ this.rowsPerPage = changes['rowsPerPage'].currentValue;//.previousValue;\n+ this.setPage(this.activePage, changes['rowsPerPage'].currentValue);\n+ this.isDataChanged = true;\n+ }\n+ if (changes['sortBy'] || changes['sortOrder']) {\n+ //if (!_.includes(['asc', 'desc'], this.sortOrder)) {\n+ // console.warn('md2-data-table: value md2SortOrder must be one of [\"asc\", \"desc\"], but is:', this.sortOrder);\n+ // this.sortOrder = 'asc';\n+ //}\n+ if (this.sortBy) {\n+ this.onSortChange.next({ sortBy: this.sortBy, sortOrder: this.sortOrder });\n+ }\n+ this.isDataChanged = true;\n+ }\n+ if (changes['md2Data']) {\n+ this.md2Data = changes['md2Data'].currentValue || [];\n+ this.recalculatePage();\n+ this.isDataChanged = true;\n+ }\n+ }\n+\n+ ngDoCheck(): any {\n+ console.log('ngOnChanges');\n+ let changes = this.diff.diff(this.md2Data);\n+ if (changes) {\n+ this.recalculatePage();\n+ this.isDataChanged = true;\n+ }\n+ if (this.isDataChanged) {\n+ this.fillData();\n+ this.isDataChanged = false;\n+ }\n+ }\n+\ngetSort(): SortEvent {\nreturn { sortBy: this.sortBy, sortOrder: this.sortOrder };\n}\n@@ -74,7 +130,7 @@ export class Md2DataTable implements OnChanges, DoCheck {\nif (this.sortBy !== sortBy || this.sortOrder !== sortOrder) {\nthis.sortBy = sortBy;\nthis.sortOrder = sortOrder;// _.includes(['asc', 'desc'], sortOrder) ? sortOrder : 'asc';\n- this.mustRecalculateData = true;\n+ this.isDataChanged = true;\nthis.onSortChange.next({ sortBy: sortBy, sortOrder: sortOrder });\nthis.sortByChange.emit(this.sortBy);\nthis.sortOrderChange.emit(this.sortOrder);\n@@ -82,19 +138,20 @@ export class Md2DataTable implements OnChanges, DoCheck {\n}\ngetPage(): PageEvent {\n- return { activePage: this.activePage, rowsPerPage: this.rowsPerPage, dataLength: this.inputData.length };\n+ return { activePage: this.activePage, rowsPerPage: this.rowsPerPage, dataLength: this.md2Data.length };\n}\nsetPage(activePage: number, rowsPerPage: number): void {\nif (this.rowsPerPage !== rowsPerPage || this.activePage !== activePage) {\nthis.activePage = this.activePage !== activePage ? activePage : this.calculateNewActivePage(this.rowsPerPage, rowsPerPage);\nthis.rowsPerPage = rowsPerPage;\n- this.mustRecalculateData = true;\n+ this.isDataChanged = true;\nthis.onPageChange.emit({\nactivePage: this.activePage,\nrowsPerPage: this.rowsPerPage,\n- dataLength: this.inputData ? this.inputData.length : 0\n+ dataLength: this.md2Data ? this.md2Data.length : 0\n});\n+ this.activePageChange.emit(this.activePage);\n}\n}\n@@ -105,58 +162,22 @@ export class Md2DataTable implements OnChanges, DoCheck {\n}\nprivate recalculatePage() {\n- let lastPage = Math.ceil(this.inputData.length / this.rowsPerPage);\n+ let lastPage = Math.ceil(this.md2Data.length / this.rowsPerPage);\nthis.activePage = lastPage < this.activePage ? lastPage : this.activePage;\nthis.activePage = this.activePage || 1;\nthis.onPageChange.emit({\nactivePage: this.activePage,\nrowsPerPage: this.rowsPerPage,\n- dataLength: this.inputData.length\n+ dataLength: this.md2Data.length\n});\n}\n- ngOnChanges(changes: { [key: string]: SimpleChange }): any {\n- if (changes['rowsPerPage']) {\n- this.rowsPerPage = changes['rowsPerPage'].previousValue;\n- this.setPage(this.activePage, changes['rowsPerPage'].currentValue);\n- this.mustRecalculateData = true;\n- }\n- if (changes['sortBy'] || changes['sortOrder']) {\n- //if (!_.includes(['asc', 'desc'], this.sortOrder)) {\n- // console.warn('md2-data-table: value md2SortOrder must be one of [\"asc\", \"desc\"], but is:', this.sortOrder);\n- // this.sortOrder = 'asc';\n- //}\n- if (this.sortBy) {\n- this.onSortChange.next({ sortBy: this.sortBy, sortOrder: this.sortOrder });\n- }\n- this.mustRecalculateData = true;\n- }\n- if (changes['inputData']) {\n- this.inputData = changes['inputData'].currentValue || [];\n- this.recalculatePage();\n- this.mustRecalculateData = true;\n- }\n- }\n-\n- ngDoCheck(): any {\n- let changes = this.diff.diff(this.inputData);\n- if (changes) {\n- this.recalculatePage();\n- this.mustRecalculateData = true;\n- }\n- if (this.mustRecalculateData) {\n- this.fillData();\n- this.mustRecalculateData = false;\n- }\n- }\n- private fillData(): void {\n- this.activePage = this.activePage;\n- this.rowsPerPage = this.rowsPerPage;\n+ private fillData() {\nlet offset = (this.activePage - 1) * this.rowsPerPage;\n- let data = this.inputData;\n+ let data = this.md2Data;\nlet sortBy = this.sortBy;\n//if (typeof sortBy === 'string' || sortBy instanceof String) {\n// data = _.orderBy(data, this.caseInsensitiveIteratee(<string>sortBy), [this.sortOrder]);\n@@ -232,77 +253,37 @@ export class Md2Pagination {\nprivate _activePage: number = 1;\n- _onChange = (value: any) => { };\n- _onTouched = () => { };\n-\n- //@Output() change: EventEmitter<Md2PaginationChange> = new EventEmitter<Md2PaginationChange>();\n-\n@Input() rowsPerPageSet: any = [];\n- @Input('md2Table') md2DataTable: Md2DataTable;\n-\n- //@Input()\n- get activePage() { return this._activePage; }\n- set activePage(value: number) {\n- if (this._activePage !== value) {\n- this._activePage = value;\n- }\n- }\n-\n- minRowsPerPage = 0;\n-\n- private mfTable: Md2DataTable;\n+ @Input() md2Table: Md2DataTable;\n_rowsPerPage: number;\n_dataLength: number = 0;\n_lastPage: number;\n- constructor( @Optional() private _dataTable: Md2DataTable) {\n- }\n+ constructor( @Optional() private _dataTable: Md2DataTable) { }\n- ngDoCheck() {//changes: any\n- //if (changes.rowsPerPageSet) {\n- // this.minRowsPerPage = _.min(this.rowsPerPageSet)\n- //}\n- this.mfTable = this.md2DataTable || this._dataTable;\n- this.onPageChangeSubscriber(this.mfTable.getPage());\n- this.mfTable.onPageChange.subscribe(this.onPageChangeSubscriber);\n+ ngDoCheck() {\n+ this.md2Table = this.md2Table || this._dataTable;\n+ this.onPageChangeSubscriber(this.md2Table.getPage());\n+ this.md2Table.onPageChange.subscribe(this.onPageChangeSubscriber);\n}\n_setPage(pageNumber: number): void {\n- this.mfTable.setPage(pageNumber, this._rowsPerPage);\n+ this.md2Table.setPage(pageNumber, this._rowsPerPage);\n}\n_setRows(event: any): void {\nevent.stopPropagation();\n- this.mfTable.setPage(this.activePage, event.target.value);\n+ this.md2Table.setPage(this._activePage, event.target.value);\n}\nprivate onPageChangeSubscriber = (event: PageEvent) => {\n- this.activePage = event.activePage;\n+ this._activePage = event.activePage;\nthis._rowsPerPage = event.rowsPerPage;\nthis._dataLength = event.dataLength;\nthis._lastPage = Math.ceil(this._dataLength / this._rowsPerPage);\n};\n-\n- //_emitChangeEvent(): void {\n- // let event = new Md2PaginationChange();\n- // event.source = this;\n- // event.activePage = this._activePage;\n- // this._onChange(event.activePage);\n- // this.change.emit(event);\n- //}\n-\n- //writeValue(value: number): void {\n- // if (this._activePage !== value) {\n- // this._activePage = value;\n- // }\n- //}\n-\n- //registerOnChange(fn: (value: any) => void): void { this._onChange = fn; }\n-\n- //registerOnTouched(fn: () => {}): void { this._onTouched = fn; }\n-\n}\nexport const MD2_DATA_TABLE_DIRECTIVES: any[] = [\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/pagination.html",
"new_path": "src/lib/data-table/pagination.html",
"diff": "</svg>\n</li>\n</ul>\n-<div class=\"md2-rows-select\" *ngIf=\"rowsPerPageSet.length && _dataLength > minRowsPerPage\">\n+<div class=\"md2-rows-select\" *ngIf=\"rowsPerPageSet.length && _dataLength > 0\">\nRows per page:\n<select (change)=\"_setRows($event)\">\n<option *ngFor=\"let row of rowsPerPageSet\" [selected]=\"_rowsPerPage===row\">{{row}}</option>\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) update core functionality |
530,388 | 13.01.2017 10:57:55 | -19,080 | 6823cb8d741bb4e5c478e17c2e181bde2a301dc4 | chore(datepicker) update style and performance of sort | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.scss",
"new_path": "src/lib/data-table/data-table.scss",
"diff": "@@ -8,19 +8,34 @@ $primary: #106cc8 !default;\n/*\n* Sort\n*/\n-[md2SortBy] span {\n- position: relative;\n- display: block;\n+[md2SortBy] {\nline-height: 24px;\n+ color: rgba(black, 0.54);\nwhite-space: nowrap;\ncursor: pointer;\nuser-select: none;\n-}\n-[md2SortBy] span svg {\n+ svg {\ndisplay: inline-block;\nvertical-align: middle;\nfill: currentColor;\n+ opacity: 0;\n+ }\n+\n+ &:hover:not(.md2-sort-active) {\n+ svg {\n+ color: rgba(black, 0.26);\n+ opacity: 1;\n+ }\n+ }\n+\n+ &.md2-sort-active {\n+ color: rgba(black, 0.87);\n+\n+ svg {\n+ opacity: 1;\n+ }\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -15,7 +15,6 @@ import {\nNgModule,\nModuleWithProviders,\n} from '@angular/core';\n-import { ReplaySubject } from 'rxjs/Rx';\nimport { CommonModule } from '@angular/common';\nexport class Md2PaginationChange {\n@@ -78,7 +77,7 @@ export class Md2DataTable implements OnChanges, DoCheck {\n@Output() sortByChange = new EventEmitter<string | string[]>();\n@Output() sortOrderChange = new EventEmitter<string>();\n- onSortChange = new ReplaySubject<SortEvent>(1);\n+ onSortChange = new EventEmitter<SortEvent>();\nonPageChange = new EventEmitter<PageEvent>();\nconstructor(private differs: IterableDiffers) {\n@@ -213,6 +212,10 @@ export class Md2DataTable implements OnChanges, DoCheck {\nselector: '[md2SortBy]',\ntemplateUrl: 'sort.html',\nstyleUrls: ['data-table.scss'],\n+ host: {\n+ '[class.md2-sort-active]': '_isAsc || _isDesc',\n+ '(click)': '_sort()'\n+ },\nencapsulation: ViewEncapsulation.None\n})\nexport class Md2DataTableSortBy implements OnInit {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/sort.html",
"new_path": "src/lib/data-table/sort.html",
"diff": "-<span (click)=\"_sort()\">\n<ng-content></ng-content>\n- <svg *ngIf=\"_isAsc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7 14l5-5 5 5z\" />\n+<svg *ngIf=\"!_isDesc\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\">\n+ <path d=\"M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z\" />\n</svg>\n- <svg *ngIf=\"_isDesc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7 10l5 5 5-5z\" />\n+<svg *ngIf=\"_isDesc\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\">\n+ <path d=\"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z\" />\n</svg>\n- <svg *ngIf=\"!_isAsc && !_isDesc\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n- <path d=\"M7,10.5l5-5l5,5H7z\" />\n- <path d=\"M7,12.5l5,5l5-5H7z\" />\n- </svg>\n-</span>\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update style and performance of sort |
530,388 | 13.01.2017 15:37:01 | -19,080 | d06c7eecd31220a6e09c39a810e07bc6522728ca | chore(data-table) update performance | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -6,7 +6,6 @@ import {\nOutput,\nOnInit,\nSimpleChange,\n- OnChanges,\nOptional,\nDoCheck,\nIterableDiffers,\n@@ -41,37 +40,70 @@ export interface DataEvent {\nselector: 'table[md2Data]',\nexportAs: 'md2DataTable'\n})\n-export class Md2DataTable implements OnChanges, DoCheck {\n+export class Md2DataTable implements DoCheck {\nprivate diff: IterableDiffer;\nprivate isDataChanged = false;\n-\n+ private _data: Array<any> = [];\nprivate _activePage: number = 1;\n+ private _rowsPerPage: number = 1000;\n+ private _sortBy: string | Array<string> = '';\n+ private _sortOrder: string = 'asc';\n- data: any[];\n+ data: Array<any>;\n- @Input() md2Data: any[] = [];\n- @Input() rowsPerPage: number = 1000;\n- //@Input() activePage: number = 1;\n- @Input() sortBy: string | string[] = '';\n- @Input() sortOrder: string = 'asc';\n+ @Input()\n+ get md2Data() { return this._data; }\n+ set md2Data(value: Array<any>) {\n+ if (this._data !== value) {\n+ this._data = value || [];\n+ this.recalculatePage();\n+ this.isDataChanged = true;\n+ }\n+ }\n@Input()\nget activePage() { return this._activePage; }\nset activePage(value: number) {\n- console.log('Active Page: ' + value);\nif (this._activePage !== value) {\nthis._activePage = value;\n}\n}\n- //@Input()\n- //get rowsPerPage() { return this._rowsPerPage; }\n- //set rowsPerPage(value: number) {\n- // if (this._rowsPerPage !== value) {\n- // this._rowsPerPage = value;\n- // }\n- //}\n+ @Input()\n+ get rowsPerPage() { return this._rowsPerPage; }\n+ set rowsPerPage(value: number) {\n+ if (this._rowsPerPage !== value) {\n+ this._rowsPerPage = value;\n+ this.setPage(this.activePage, value);\n+ this.isDataChanged = true;\n+ }\n+ }\n+\n+ @Input()\n+ get sortBy() { return this._sortBy; }\n+ set sortBy(value: string | Array<string>) {\n+ if (this._sortBy !== value) {\n+ this._sortBy = value;\n+ if (value) {\n+ this.onSortChange.next({ sortBy: this.sortBy, sortOrder: this.sortOrder });\n+ }\n+ this.isDataChanged = true;\n+ }\n+ }\n+\n+ @Input()\n+ get sortOrder() { return this._sortOrder; }\n+ set sortOrder(value: string) {\n+ if (!(value === 'asc' || value === 'desc')) {\n+ console.warn('sortOrder value must be one of [\"asc\", \"desc\"], but is:', value);\n+ value = 'asc';\n+ }\n+ if (this._sortOrder !== value) {\n+ this._sortOrder = value;\n+ this.isDataChanged = true;\n+ }\n+ }\n@Output() activePageChange = new EventEmitter<number>();\n@Output() sortByChange = new EventEmitter<string | string[]>();\n@@ -84,32 +116,7 @@ export class Md2DataTable implements OnChanges, DoCheck {\nthis.diff = differs.find([]).create(null);\n}\n- ngOnChanges(changes: { [key: string]: SimpleChange }): any {\n- console.log('ngOnChanges');\n- if (changes['rowsPerPage']) {\n- this.rowsPerPage = changes['rowsPerPage'].currentValue;//.previousValue;\n- this.setPage(this.activePage, changes['rowsPerPage'].currentValue);\n- this.isDataChanged = true;\n- }\n- if (changes['sortBy'] || changes['sortOrder']) {\n- //if (!_.includes(['asc', 'desc'], this.sortOrder)) {\n- // console.warn('md2-data-table: value md2SortOrder must be one of [\"asc\", \"desc\"], but is:', this.sortOrder);\n- // this.sortOrder = 'asc';\n- //}\n- if (this.sortBy) {\n- this.onSortChange.next({ sortBy: this.sortBy, sortOrder: this.sortOrder });\n- }\n- this.isDataChanged = true;\n- }\n- if (changes['md2Data']) {\n- this.md2Data = changes['md2Data'].currentValue || [];\n- this.recalculatePage();\n- this.isDataChanged = true;\n- }\n- }\n-\nngDoCheck(): any {\n- console.log('ngOnChanges');\nlet changes = this.diff.diff(this.md2Data);\nif (changes) {\nthis.recalculatePage();\n@@ -128,7 +135,7 @@ export class Md2DataTable implements OnChanges, DoCheck {\nsetSort(sortBy: string | string[], sortOrder: string) {\nif (this.sortBy !== sortBy || this.sortOrder !== sortOrder) {\nthis.sortBy = sortBy;\n- this.sortOrder = sortOrder;// _.includes(['asc', 'desc'], sortOrder) ? sortOrder : 'asc';\n+ this.sortOrder = sortOrder;\nthis.isDataChanged = true;\nthis.onSortChange.next({ sortBy: sortBy, sortOrder: sortOrder });\nthis.sortByChange.emit(this.sortBy);\n@@ -137,12 +144,17 @@ export class Md2DataTable implements OnChanges, DoCheck {\n}\ngetPage(): PageEvent {\n- return { activePage: this.activePage, rowsPerPage: this.rowsPerPage, dataLength: this.md2Data.length };\n+ return {\n+ activePage: this.activePage,\n+ rowsPerPage: this.rowsPerPage,\n+ dataLength: this.md2Data.length\n+ };\n}\nsetPage(activePage: number, rowsPerPage: number): void {\nif (this.rowsPerPage !== rowsPerPage || this.activePage !== activePage) {\n- this.activePage = this.activePage !== activePage ? activePage : this.calculateNewActivePage(this.rowsPerPage, rowsPerPage);\n+ this.activePage = this.activePage !== activePage ?\n+ activePage : this.calculateNewActivePage(this.rowsPerPage, rowsPerPage);\nthis.rowsPerPage = rowsPerPage;\nthis.isDataChanged = true;\nthis.onPageChange.emit({\n@@ -172,8 +184,6 @@ export class Md2DataTable implements OnChanges, DoCheck {\n});\n}\n-\n-\nprivate fillData() {\nlet offset = (this.activePage - 1) * this.rowsPerPage;\nlet data = this.md2Data;\n@@ -206,6 +216,7 @@ export class Md2DataTable implements OnChanges, DoCheck {\nreturn value;\n};\n}\n+\n}\n@Component({\n@@ -249,7 +260,7 @@ export class Md2DataTableSortBy implements OnInit {\nselector: 'md2-pagination',\ntemplateUrl: 'pagination.html',\nstyleUrls: ['data-table.css'],\n- //exportAs: 'md2Pagination',\n+ exportAs: 'md2Pagination',\nencapsulation: ViewEncapsulation.None\n})\nexport class Md2Pagination {\n@@ -277,7 +288,7 @@ export class Md2Pagination {\n_setRows(event: any): void {\nevent.stopPropagation();\n- this.md2Table.setPage(this._activePage, event.target.value);\n+ this.md2Table.setPage(this._activePage, parseInt(event.target.value));\n}\nprivate onPageChangeSubscriber = (event: PageEvent) => {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) update performance |
530,388 | 13.01.2017 18:50:53 | -19,080 | 6c0f13f23885741c3ef61751262785472dfacd1b | fix(autocomplete) require ngControl issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/autocomplete/autocomplete.ts",
"new_path": "src/lib/autocomplete/autocomplete.ts",
"diff": "@@ -51,6 +51,12 @@ export const MD2_AUTOCOMPLETE_CONTROL_VALUE_ACCESSOR: any = {\nmulti: true\n};\n+/** Change event object emitted by Md2Autocomplete. */\n+export class Md2AutocompleteChange {\n+ source: Md2Autocomplete;\n+ value: any;\n+}\n+\n@Component({\nmoduleId: module.id,\nselector: 'md2-autocomplete',\n@@ -82,8 +88,9 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\nprivate _required: boolean = false;\nprivate _disabled: boolean = false;\nprivate _isInitialized: boolean = false;\n- private _onTouchedCallback: () => void = noop;\n- private _onChangeCallback: (_: any) => void = noop;\n+\n+ _onChange = (value: any) => { };\n+ _onTouched = () => { };\nprivate _items: Array<any> = [];\n_list: Array<Item> = [];\n@@ -130,8 +137,7 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n}\nif (!this._inputValue) { this._inputValue = ''; }\nif (this._isInitialized) {\n- this._onChangeCallback(value);\n- this.change.emit(value);\n+ this._emitChangeEvent();\n}\n}\n}\n@@ -270,8 +276,7 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n*/\nprivate updateValue() {\nthis._value = this.selectedItem ? this.selectedItem.value : this.selectedItem;\n- this._onChangeCallback(this._value);\n- this.change.emit(this._value);\n+ this._emitChangeEvent();\nthis.onFocus();\n}\n@@ -297,6 +302,7 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n*/\n_handleBlur() {\nthis._inputFocused = false;\n+ this._onTouched();\n}\n/**\n@@ -325,7 +331,15 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n}\n}\n- writeValue(value: any) {\n+ _emitChangeEvent(): void {\n+ let event = new Md2AutocompleteChange();\n+ event.source = this;\n+ event.value = this._value;\n+ this._onChange(event.value);\n+ this.change.emit(event);\n+ }\n+\n+ writeValue(value: any): void {\nif (value !== this._value) {\nthis._value = value;\nthis._inputValue = '';\n@@ -339,9 +353,10 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n}\n}\n- registerOnChange(fn: any) { this._onChangeCallback = fn; }\n+ registerOnChange(fn: (value: any) => void): void { this._onChange = fn; }\n+\n+ registerOnTouched(fn: () => {}): void { this._onTouched = fn; }\n- registerOnTouched(fn: any) { this._onTouchedCallback = fn; }\n}\nexport const MD2_AUTOCOMPLETE_DIRECTIVES = [Md2Autocomplete, HighlightPipe];\n"
}
] | TypeScript | MIT License | promact/md2 | fix(autocomplete) require ngControl issue #57 |
530,388 | 16.01.2017 09:40:11 | -19,080 | 361e0e7da183b8ef25c6d5eaceb43a1c228d69d7 | fix(autocomplete) suggestion list not closing issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/autocomplete/autocomplete.ts",
"new_path": "src/lib/autocomplete/autocomplete.ts",
"diff": "@@ -96,7 +96,7 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\n_list: Array<Item> = [];\nprivate selectedItem: Item = null;\n- private noBlur: boolean = true;\n+ private noBlur: boolean = false;\n_focusedOption: number = 0;\n_inputValue: string = '';\n_inputFocused: boolean = false;\n@@ -257,6 +257,7 @@ export class Md2Autocomplete implements AfterContentInit, ControlValueAccessor {\nthis.selectedItem = this._list[index];\nthis._inputValue = this._list[index].text;\nthis.updateValue();\n+ this._handleMouseLeave();\n}\n/**\n"
}
] | TypeScript | MIT License | promact/md2 | fix(autocomplete) suggestion list not closing issue |
530,388 | 16.01.2017 10:14:32 | -19,080 | 2bf4882fdfe8d4bb4af7ac07b36c58d03fdafd9c | chore(select) update option binding and performance | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.scss",
"new_path": "src/lib/select/select.scss",
"diff": "@@ -58,6 +58,7 @@ md2-select {\n&.md2-floating-placeholder {\ntop: -16px;\nleft: -2px;\n+ text-align: left;\ntransform: scale(0.75);\n}\n@@ -66,6 +67,7 @@ md2-select {\n&.md2-floating-placeholder {\nleft: 2px;\n+ text-align: right;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.ts",
"new_path": "src/lib/select/select.ts",
"diff": "@@ -236,8 +236,8 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nthis._required = coerceBooleanProperty(value);\n}\n- @Output() onOpen = new EventEmitter();\n- @Output() onClose = new EventEmitter();\n+ @Output() onOpen: EventEmitter<void> = new EventEmitter<void>();\n+ @Output() onClose: EventEmitter<void> = new EventEmitter<void>();\nconstructor(private _element: ElementRef, private _renderer: Renderer,\nprivate _viewportRuler: ViewportRuler, @Optional() private _dir: Dir,\n@@ -250,7 +250,15 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nngAfterContentInit() {\nthis._initKeyManager();\nthis._resetOptions();\n- this._changeSubscription = this.options.changes.subscribe(() => this._resetOptions());\n+ this._changeSubscription = this.options.changes.subscribe(() => {\n+ this._resetOptions();\n+\n+ if (this._control) {\n+ // Defer setting the value in order to avoid the \"Expression\n+ // has changed after it was checked\" errors from Angular.\n+ Promise.resolve(null).then(() => this._setSelectionByValue(this._control.value));\n+ }\n+ });\n}\nngOnDestroy() {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(select) update option binding and performance |
530,388 | 16.01.2017 10:44:34 | -19,080 | 533ceaeb5c4c333dd3697ddf49e6366fa96c74ac | fix(datepicker) unable to clear issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -882,6 +882,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nif (this.type !== 'date') {\ndate += this._value.getHours() + ':' + this._value.getMinutes();\n}\n+ } else {\n+ this._value = null;\n+ this._viewValue = null;\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) unable to clear issue #60 |
530,388 | 16.01.2017 11:21:42 | -19,080 | 01ff3947fab5461caf0759571fd07ad45e0051bd | fix(datepicker) min/max date null or undefined to seta as default | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -142,8 +142,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nmoved: false\n};\n- private _minDate: Date = null;\n- private _maxDate: Date = null;\n+ private _min: Date = null;\n+ private _max: Date = null;\n@Output() change: EventEmitter<any> = new EventEmitter<any>();\n@@ -168,15 +168,19 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nget disabled(): boolean { return this._disabled; }\nset disabled(value) { this._disabled = coerceBooleanProperty(value); }\n- @Input() set min(value: string) {\n- this._minDate = new Date(value);\n- this._minDate.setHours(0, 0, 0, 0);\n+ @Input() set min(value: Date) {\n+ if (value && this._dateUtil.isValidDate(value)) {\n+ this._min = new Date(value);\n+ this._min.setHours(0, 0, 0, 0);\nthis.getYears();\n+ } else { this._min = null; }\n}\n- @Input() set max(value: string) {\n- this._maxDate = new Date(value);\n- this._maxDate.setHours(0, 0, 0, 0);\n+ @Input() set max(value: Date) {\n+ if (value && this._dateUtil.isValidDate(value)) {\n+ this._max = new Date(value);\n+ this._max.setHours(0, 0, 0, 0);\nthis.getYears();\n+ } else { this._max = null; }\n}\n@Input()\n@@ -222,11 +226,11 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\nset displayDate(date: Date) {\nif (date && this._dateUtil.isValidDate(date)) {\n- if (this._minDate && this._minDate > date) {\n- date = this._minDate;\n+ if (this._min && this._min > date) {\n+ date = this._min;\n}\n- if (this._maxDate && this._maxDate < date) {\n- date = this._maxDate;\n+ if (this._max && this._max < date) {\n+ date = this._max;\n}\nthis._displayDate = date;\nthis._viewDay = {\n@@ -374,8 +378,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\nprivate getYears() {\n- let startYear = this._minDate ? this._minDate.getFullYear() : 1900,\n- endYear = this._maxDate ? this._maxDate.getFullYear() : this.today.getFullYear() + 100;\n+ let startYear = this._min ? this._min.getFullYear() : 1900,\n+ endYear = this._max ? this._max.getFullYear() : this.today.getFullYear() + 100;\nthis._years = [];\nfor (let i = startYear; i <= endYear; i++) {\nthis._years.push(i);\n@@ -504,8 +508,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n* @return boolean\n*/\n_isBeforeMonth() {\n- return !this._minDate ? true :\n- this._minDate && this._dateUtil.getMonthDistance(this.displayDate, this._minDate) < 0;\n+ return !this._min ? true :\n+ this._min && this._dateUtil.getMonthDistance(this.displayDate, this._min) < 0;\n}\n/**\n@@ -513,8 +517,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n* @return boolean\n*/\n_isAfterMonth() {\n- return !this._maxDate ? true :\n- this._maxDate && this._dateUtil.getMonthDistance(this.displayDate, this._maxDate) > 0;\n+ return !this._max ? true :\n+ this._max && this._dateUtil.getMonthDistance(this.displayDate, this._max) > 0;\n}\n/**\n@@ -523,12 +527,12 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n* @return boolean\n*/\nprivate _isDisabledDate(date: Date): boolean {\n- if (this._minDate && this._maxDate) {\n- return (this._minDate > date) || (this._maxDate < date);\n- } else if (this._minDate) {\n- return (this._minDate > date);\n- } else if (this._maxDate) {\n- return (this._maxDate < date);\n+ if (this._min && this._max) {\n+ return (this._min > date) || (this._max < date);\n+ } else if (this._min) {\n+ return (this._min > date);\n+ } else if (this._max) {\n+ return (this._max < date);\n} else {\nreturn false;\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) min/max date null or undefined to seta as default #37 |
530,388 | 16.01.2017 13:51:37 | -19,080 | 37de66d9890b769dc17451acbb4f792b483a83d9 | feat(datepicker) handle years through keyboard. | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -298,10 +298,18 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nbreak;\ncase PAGE_DOWN:\n+ if (event.shiftKey) {\n+ this.displayDate = this._dateUtil.incrementYears(displayDate, 1);\n+ } else {\nthis.displayDate = this._dateUtil.incrementMonths(displayDate, 1);\n+ }\nbreak;\ncase PAGE_UP:\n+ if (event.shiftKey) {\n+ this.displayDate = this._dateUtil.incrementYears(displayDate, -1);\n+ } else {\nthis.displayDate = this._dateUtil.incrementMonths(displayDate, -1);\n+ }\nbreak;\ncase DOWN_ARROW:\n"
}
] | TypeScript | MIT License | promact/md2 | feat(datepicker) handle years through keyboard. |
530,388 | 16.01.2017 16:03:44 | -19,080 | fd421fc9e60aae9d4256cb2d061ec07db495f0dc | chore(datepicker) update html and styling structure | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "</svg>\n</div>\n</div>\n-<div class=\"md2-datepicker-wrapper\" [class.active]=\"_isDatepickerVisible\">\n+<div class=\"md2-datepicker-panel\" [class.active]=\"_isDatepickerVisible\">\n<div class=\"md2-datepicker-header\">\n- <span class=\"md2-datepicker-year\"\n+ <div class=\"md2-datepicker-header-year\"\n[class.active]=\"_isYearsVisible\"\n[class.hidden]=\"type==='time'\"\n- (click)=\"_showYear()\">{{_viewDay.year}}</span>\n- <span class=\"md2-datepicker-date\"\n+ (click)=\"_showYear()\">{{_viewDay.year}}</div>\n+ <div class=\"md2-datepicker-header-date-time\">\n+ <span class=\"md2-datepicker-header-date\"\n[class.active]=\"_isCalendarVisible && !_isYearsVisible\"\n[class.hidden]=\"type==='time'\"\n(click)=\"_showCalendar()\">{{_viewDay.day.substr(0, 3)}}, {{_viewDay.month.substr(0, 3)}} {{_viewDay.date}}</span>\n- <span class=\"md2-datepicker-time\"\n+ <span class=\"md2-datepicker-header-time\"\n[class.active]=\"!_isCalendarVisible\"\n[class.hidden]=\"type==='date'\">\n- <span class=\"md2-datepicker-hour\"\n+ <span class=\"md2-datepicker-header-hour\"\n[class.active]=\"_isHoursVisible\"\n- (click)=\"_toggleHours(true)\">{{_viewDay.hour}}</span>:<span class=\"md2-datepicker-minute\"\n+ (click)=\"_toggleHours(true)\">{{_viewDay.hour}}</span>:<span class=\"md2-datepicker-header-minute\"\n[class.active]=\"!_isHoursVisible\"\n(click)=\"_toggleHours(false)\">{{_viewDay.minute}}</span>\n</span>\n</div>\n- <div class=\"md2-datepicker-body\">\n- <div class=\"md2-years\" [class.active]=\"_isYearsVisible\">\n- <div class=\"md2-years-wrapper\">\n+ </div>\n+ <div class=\"md2-datepicker-content\">\n+ <div class=\"md2-datepicker-calendar\" [class.active]=\"_isCalendarVisible\">\n+ <div class=\"md2-calendar-years\" [class.active]=\"_isYearsVisible\">\n+ <div class=\"md2-calendar-years-content\">\n<div *ngFor=\"let y of _years\"\n- class=\"md2-year\"\n+ class=\"md2-calendar-year\"\n[class.selected]=\"y === _viewDay.year\"\n(click)=\"_setYear(y)\">{{y}}</div>\n</div>\n</div>\n- <div class=\"md2-datepicker-container\" [class.active]=\"!_isYearsVisible\">\n- <div class=\"md2-calendar\" [class.active]=\"_isCalendarVisible\">\n+ <div class=\"md2-calendar-month\" [class.active]=\"!_isYearsVisible\">\n<div class=\"md2-calendar-controls\">\n<div class=\"md2-calendar-prev-month\"\n[class.disabled]=\"!_isBeforeMonth()\"\n</div>\n<div class=\"md2-calendar-header\">{{_viewDay.month}} {{_viewDay.year}}</div>\n</div>\n- <table class=\"md2-calendar-month\">\n+ <table class=\"md2-calendar-dates\">\n<thead><tr><th *ngFor=\"let d of _days\">{{d.substr(0, 1)}}</th></tr></thead>\n<tbody>\n<tr *ngFor=\"let w of _dates\">\n</tbody>\n</table>\n</div>\n- <div class=\"md2-clock\" [class.active]=\"!_isCalendarVisible\">\n+ </div>\n+ <div class=\"md2-datepicker-clock\" [class.active]=\"!_isCalendarVisible\">\n<!-- (mousedown)=\"onMouseDownClock($event)\"-->\n<div class=\"md2-clock-hand\">\n<svg class=\"md2-clock-svg\" width=\"240\" height=\"240\">\n(click)=\"_onClickMinute($event,m.minute)\">{{m.minute}}</div>\n</div>\n</div>\n- </div>\n- </div>\n- <div class=\"md2-datepicker-footer\">\n+ <div class=\"md2-datepicker-actions\">\n<div class=\"md2-button\" (click)=\"_onBlur()\">Cancel</div>\n<div class=\"md2-button\" (click)=\"_onClickOk()\">Ok</div>\n</div>\n</div>\n+</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "$primary: #106cc8 !default;\n$warn: #f44336 !default;\n+$md2-datepicker-trigger-height: 30px !default;\n+$md2-datepicker-trigger-min-width: 112px !default;\n+$md2-datepicker-arrow-size: 5px !default;\n+$md2-datepicker-arrow-margin: 4px !default;\n+$md2-datepicker-date-cell-size: 40px !default;\n+$md2-datepicker-calendar-height: 300px !default;\n+\nmd2-datepicker {\nposition: relative;\ndisplay: block;\n@@ -113,7 +120,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\nline-height: 26px;\n}\n-.md2-datepicker-wrapper {\n+.md2-datepicker-panel {\nposition: absolute;\ntop: 0;\nleft: 0;\n@@ -134,22 +141,14 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n.md2-datepicker-header {\n- display: block;\n- padding: 20px;\n+ padding: 16px;\ncolor: white;\n- font-size: 28px;\n- line-height: 28px;\nfont-weight: 500;\nbackground: $primary;\n- box-sizing: border-box;\n}\n-.md2-datepicker-year {\n- display: block;\n- height: 16px;\n- margin: 0 0 10px;\n+.md2-datepicker-header-year {\nfont-size: 16px;\n- line-height: 16px;\nopacity: 0.7;\ncursor: pointer;\n@@ -163,11 +162,14 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n+.md2-datepicker-header-date-time {\n+ font-size: 32px;\n+ white-space: nowrap;\n+}\n-\n-.md2-datepicker-date {\n- cursor: pointer;\n+.md2-datepicker-header-date {\nopacity: 0.7;\n+ cursor: pointer;\n&.active {\nopacity: 1;\n@@ -179,68 +181,59 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n-.md2-datepicker-time {\n+.md2-datepicker-header-time {\n+ opacity: 0.7;\ndisplay: inline-block;\n- padding-left: 10px;\n+ padding-left: 8px;\ncursor: pointer;\n- opacity: 0.7;\n&.active {\nopacity: 1;\n+ cursor: default;\n- .md2-datepicker-hour,\n- .md2-datepicker-minute {\n+ .md2-datepicker-header-hour,\n+ .md2-datepicker-header-minute {\nopacity: 0.7;\n+ cursor: pointer;\n&.active {\nopacity: 1;\npointer-events: none;\n}\n- }\n- }\n&.hidden {\ndisplay: none;\n}\n}\n+ }\n-.md2-datepicker-hour,\n-.md2-datepicker-minute {\n- opacity: 1;\n+ &.hidden {\n+ display: none;\n+ }\n}\n-.md2-datepicker-body {\n+.md2-datepicker-content {\nposition: relative;\nwidth: 100%;\n- height: 300px;\n+ padding-top: $md2-datepicker-calendar-height;\noverflow: hidden;\n}\n-.md2-datepicker-footer {\n- text-align: right;\n-\n- .md2-button {\n- display: inline-block;\n- min-width: 64px;\n- margin: 4px 8px 8px 0;\n- padding: 0 12px;\n- font-size: 14px;\n- color: $primary;\n- line-height: 36px;\n- text-align: center;\n- text-transform: uppercase;\n- border-radius: 2px;\n- cursor: pointer;\n- box-sizing: border-box;\n- transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1);\n+.md2-datepicker-calendar {\n+ position: absolute;\n+ top: 0;\n+ right: 100%;\n+ display: block;\n+ width: 100%;\n+ height: $md2-datepicker-calendar-height;\n+ transition: 300ms;\n- &:hover {\n- background: darken(white, 8);\n- }\n+ &.active {\n+ right: 0;\n}\n}\n-.md2-years {\n+.md2-calendar-years {\nposition: absolute;\ntop: 10px;\nright: 100%;\n@@ -257,14 +250,15 @@ md2-datepicker.md2-datepicker-disabled:focus {\nright: 0;\n}\n- .md2-years-wrapper {\n+ .md2-calendar-years-content {\ndisplay: flex;\nflex-direction: column;\njustify-content: center;\nmin-height: 100%;\n}\n+}\n- .md2-year {\n+.md2-calendar-year {\nposition: relative;\ndisplay: block;\nmargin: 0 auto;\n@@ -280,33 +274,19 @@ md2-datepicker.md2-datepicker-disabled:focus {\nfont-weight: 500;\n}\n}\n-}\n-.md2-datepicker-container {\n+.md2-calendar-month {\nposition: absolute;\n- top: 0;\nleft: 100%;\ndisplay: block;\nwidth: 100%;\n- transition: 300ms;\n-\n- &.active {\n- left: 0;\n- }\n-}\n-\n-.md2-calendar {\n- position: absolute;\n- right: 100%;\n- display: block;\n- width: 100%;\nfont-size: 12px;\nfont-weight: 400;\ntext-align: center;\ntransition: 300ms;\n&.active {\n- right: 0;\n+ left: 0;\n}\n}\n@@ -347,7 +327,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\nright: 0;\n}\n-.md2-calendar-month {\n+.md2-calendar-dates {\nmargin: 0 20px;\nth {\n@@ -402,8 +382,9 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n-.md2-clock {\n+.md2-datepicker-clock {\nposition: absolute;\n+ top: 0;\nleft: 100%;\ndisplay: block;\nwidth: 240px;\n@@ -486,3 +467,27 @@ md2-datepicker.md2-datepicker-disabled:focus {\nstroke: none;\nfill: $primary;\n}\n+\n+.md2-datepicker-actions {\n+ text-align: right;\n+\n+ .md2-button {\n+ display: inline-block;\n+ min-width: 64px;\n+ margin: 4px 8px 8px 0;\n+ padding: 0 12px;\n+ font-size: 14px;\n+ color: $primary;\n+ line-height: 36px;\n+ text-align: center;\n+ text-transform: uppercase;\n+ border-radius: 2px;\n+ cursor: pointer;\n+ box-sizing: border-box;\n+ transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1);\n+\n+ &:hover {\n+ background: darken(white, 8);\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -396,8 +396,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _scrollToSelectedYear() {\nsetTimeout(() => {\n- let yearContainer = this.element.nativeElement.querySelector('.md2-years'),\n- selectedYear = this.element.nativeElement.querySelector('.md2-year.selected');\n+ let yearContainer = this.element.nativeElement.querySelector('.md2-calendar-years'),\n+ selectedYear = this.element.nativeElement.querySelector('.md2-calendar-year.selected');\nyearContainer.scrollTop = (selectedYear.offsetTop + 20) - yearContainer.clientHeight / 2;\n}, 0);\n}\n@@ -412,7 +412,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\ndate.getHours(), date.getMinutes());\nthis.generateCalendar();\nthis._isYearsVisible = false;\n- // this.isCalendarVisible = true;\n}\n/**\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update html and styling structure |
530,388 | 16.01.2017 17:00:47 | -19,080 | 1004cda6d2be1921f41e3158c320d19f55f78fb3 | feat(datepicker) responsive | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "<span class=\"md2-datepicker-header-date\"\n[class.active]=\"_isCalendarVisible && !_isYearsVisible\"\n[class.hidden]=\"type==='time'\"\n- (click)=\"_showCalendar()\">{{_viewDay.day.substr(0, 3)}}, {{_viewDay.month.substr(0, 3)}} {{_viewDay.date}}</span>\n+ (click)=\"_showCalendar()\">{{_viewDay.day.substr(0, 3)}}, {{_viewDay.month.substr(0, 3)}} {{_viewDay.date}}</span>\n<span class=\"md2-datepicker-header-time\"\n[class.active]=\"!_isCalendarVisible\"\n[class.hidden]=\"type==='date'\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -144,7 +144,9 @@ md2-datepicker.md2-datepicker-disabled:focus {\npadding: 16px;\ncolor: white;\nfont-weight: 500;\n+ white-space: nowrap;\nbackground: $primary;\n+ box-sizing: border-box;\n}\n.md2-datepicker-header-year {\n@@ -164,7 +166,6 @@ md2-datepicker.md2-datepicker-disabled:focus {\n.md2-datepicker-header-date-time {\nfont-size: 32px;\n- white-space: nowrap;\n}\n.md2-datepicker-header-date {\n@@ -491,3 +492,25 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n}\n+\n+@media (min-width: 600px) {\n+ .md2-datepicker-panel {\n+ display: flex;\n+ width: 430px;\n+ }\n+\n+ .md2-datepicker-header {\n+ width: 130px;\n+ padding-right: 15px;\n+ white-space: normal;\n+ word-wrap: break-word;\n+ }\n+\n+ .md2-datepicker-header-time {\n+ display: block;\n+ padding-left: 0;\n+ }\n+\n+ .md2-datepicker-content {\n+ }\n+}\n"
}
] | TypeScript | MIT License | promact/md2 | feat(datepicker) responsive #32 |
530,389 | 16.01.2017 21:26:02 | -18,000 | e31aa9aabda319c0fd282e0aa9f7de4c2c7f560d | Update dialog.ts
Very strong brakes when modal windows 2 and more | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -46,7 +46,7 @@ export class Md2DialogFooter { }\nstyleUrls: ['dialog.css'],\nhost: {\n'tabindex': '0',\n- '(body:keydown)': '_handleDocumentKeydown($event)'\n+ '(body:keydown.esc)': '_handleDocumentKeydown($event)'\n},\nencapsulation: ViewEncapsulation.None,\n})\n@@ -118,11 +118,9 @@ export class Md2Dialog implements OnDestroy {\n}\n_handleDocumentKeydown(event: KeyboardEvent) {\n- if (event.keyCode === ESCAPE) {\nthis.close();\n}\n}\n-}\nexport const MD2_DIALOG_DIRECTIVES: any[] = [\nMd2Dialog,\n"
}
] | TypeScript | MIT License | promact/md2 | Update dialog.ts
Very strong brakes when modal windows 2 and more |
530,388 | 17.01.2017 11:22:06 | -19,080 | f777e31045213dca7679b3e8a850db2b7434b1cc | feat(date-table) sort by deeply | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -186,16 +186,10 @@ export class Md2DataTable implements DoCheck {\nprivate fillData() {\nlet offset = (this.activePage - 1) * this.rowsPerPage;\nlet data = this.md2Data;\n- let sortBy = this.sortBy;\n- // if (typeof sortBy === 'string' || sortBy instanceof String) {\n- // data = _.orderBy(data, this.caseInsensitiveIteratee(<string>sortBy), [this.sortOrder]);\n- // } else {\n- // data = _.orderBy(data, sortBy, [this.sortOrder]);\n- // }\n- if (sortBy) {\n+ if (this.sortBy) {\ndata = data.sort((a: any, b: any) => {\n- let x = isNaN(a[sortBy + '']) ? a[sortBy + ''].toLowerCase() : a[sortBy + ''];\n- let y = isNaN(b[sortBy + '']) ? b[sortBy + ''].toLowerCase() : b[sortBy + ''];\n+ let x = this.caseInsensitiveIteratee(a);\n+ let y = this.caseInsensitiveIteratee(b);\nreturn (x > y) ? 1 : (y > x) ? -1 : 0;\n});\n}\n@@ -203,17 +197,18 @@ export class Md2DataTable implements DoCheck {\nthis.data = data.slice(offset, offset + this.rowsPerPage);\n}\n- private caseInsensitiveIteratee(sortBy: string) {\n- return (row: any): any => {\n- let value = row;\n- for (let sortByProperty of sortBy.split('.')) {\n+ private caseInsensitiveIteratee(value: any) {\n+ if (typeof this.sortBy === 'string' || this.sortBy instanceof String) {\n+ for (let sortByProperty of this.sortBy.split('.')) {\nvalue = value[sortByProperty];\n}\n+ } else {\n+ value = value[this.sortBy + ''];\n+ }\nif (value && typeof value === 'string' || value instanceof String) {\nreturn value.toLowerCase();\n}\nreturn value;\n- };\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | feat(date-table) sort by deeply |
530,388 | 17.01.2017 12:19:49 | -19,080 | 50eae62f3af7d8866c90dee99c2945d685a42168 | fix(select) styling issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.scss",
"new_path": "src/lib/select/select.scss",
"diff": "@@ -28,7 +28,7 @@ md2-select {\nbackground-image: linear-gradient(to right, rgba(black, 0.26) 0, rgba(black, 0.26) 33%, transparent 0);\nbackground-size: 4px 1px;\nbackground-repeat: repeat-x;\n- border-bottom: transparent;\n+ border-color: transparent;\nbackground-position: 0 bottom;\ncursor: default;\nuser-select: none;\n@@ -36,12 +36,12 @@ md2-select {\nmd2-select:focus:not(.md2-select-disabled) & {\ncolor: $primary;\n- border-bottom: 1px solid $primary;\n+ border-color: $primary;\n}\nmd2-select.ng-invalid.ng-touched:not(.md2-select-disabled) & {\ncolor: $warn;\n- border-bottom: 1px solid $warn;\n+ border-color: $warn;\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(select) styling issue |
530,388 | 17.01.2017 12:39:54 | -19,080 | ae353f7cd6c60b9031578dddc86450dd731d1532 | chore(data-table) set rows per page select dropdown is material | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.scss",
"new_path": "src/lib/data-table/data-table.scss",
"diff": "@@ -44,27 +44,25 @@ $primary: #106cc8 !default;\n*/\nmd2-pagination {\ndisplay: block;\n- color: $primary;\n+ color: rgba(black, 0.54);\nuser-select: none;\n-}\n-md2-pagination::before,\n-md2-pagination::after {\n+ &::before,\n+ &::after {\ndisplay: table;\ncontent: '';\n}\n-md2-pagination::after {\n+ &::after {\nclear: both;\n}\n-md2-pagination .md2-pagination {\n+ .md2-pagination {\ndisplay: inline-block;\nmargin: 8px 0;\npadding: 0;\n-}\n-md2-pagination .md2-pagination li {\n+ li {\nposition: relative;\ndisplay: inline-block;\nwidth: 36px;\n@@ -74,42 +72,48 @@ md2-pagination .md2-pagination li {\nborder-radius: 100px;\ncursor: pointer;\nbox-sizing: border-box;\n-}\n-md2-pagination .md2-pagination li:hover {\n+ &:hover:not(.disabled):not(.active) {\nbackground: rgba(black, 0.12);\n}\n-md2-pagination .md2-pagination li.disabled,\n-md2-pagination .md2-pagination li.disabled:hover {\n+ &.disabled {\npointer-events: none;\nbackground: transparent;\ncursor: default;\nopacity: 0.48;\n}\n-md2-pagination .md2-pagination li.active,\n-md2-pagination .md2-pagination li.active:hover {\n+ &.active {\nbackground: $primary;\ncolor: white;\ncursor: default;\n}\n-md2-pagination .md2-pagination li svg {\n+ svg {\nfill: currentColor;\nmargin-bottom: -7px;\n}\n+ }\n+ }\n-md2-pagination .md2-rows-select {\n+ .md2-rows-select {\ndisplay: inline-block;\nmargin: 8px 0;\npadding: 0;\nfloat: right;\ncolor: rgba(black, 0.54);\nline-height: 36px;\n-}\n-md2-pagination .md2-rows-select select {\n+ md2-select {\n+ display: inline-block;\nborder: 0;\noutline: 0;\n}\n+\n+ .md2-select-trigger {\n+ border-width: 0;\n+ min-width: 40px;\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -14,6 +14,8 @@ import {\nModuleWithProviders,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\n+import { FormsModule } from '@angular/forms';\n+import { Md2SelectModule } from '../select/index';\nexport class Md2PaginationChange {\nsource: Md2Pagination;\n@@ -281,8 +283,7 @@ export class Md2Pagination {\n}\n_setRows(event: any): void {\n- event.stopPropagation();\n- this.md2Table.setPage(this._activePage, parseInt(event.target.value));\n+ this.md2Table.setPage(this._activePage, parseInt(event.value));\n}\nprivate onPageChangeSubscriber = (event: PageEvent) => {\n@@ -301,7 +302,7 @@ export const MD2_DATA_TABLE_DIRECTIVES: any[] = [\n];\n@NgModule({\n- imports: [CommonModule],\n+ imports: [CommonModule, FormsModule, Md2SelectModule.forRoot()],\nexports: MD2_DATA_TABLE_DIRECTIVES,\ndeclarations: MD2_DATA_TABLE_DIRECTIVES,\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/pagination.html",
"new_path": "src/lib/data-table/pagination.html",
"diff": "</ul>\n<div class=\"md2-rows-select\" *ngIf=\"rowsPerPageSet.length && _dataLength > 0\">\nRows per page:\n- <select (change)=\"_setRows($event)\">\n- <option *ngFor=\"let row of rowsPerPageSet\" [selected]=\"_rowsPerPage===row\">{{row}}</option>\n- </select>\n+ <md2-select [(ngModel)]=\"_rowsPerPage\" (change)=\"_setRows($event)\">\n+ <md2-option *ngFor=\"let row of rowsPerPageSet\" [value]=\"row\">{{row}}</md2-option>\n+ </md2-select>\n</div>\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) set rows per page select dropdown is material |
530,388 | 17.01.2017 13:59:51 | -19,080 | 7ea58d6689bd4c423a87572f64467195783ec8d2 | fix(data-table) active page change event while page change after data updates | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -175,8 +175,12 @@ export class Md2DataTable implements DoCheck {\nprivate recalculatePage() {\nlet lastPage = Math.ceil(this.md2Data.length / this.rowsPerPage);\n- this.activePage = lastPage < this.activePage ? lastPage : this.activePage;\n- this.activePage = this.activePage || 1;\n+ if (lastPage < this.activePage) {\n+ this._activePage = lastPage || 1;\n+ setTimeout(() => {\n+ this.activePageChange.emit(this.activePage);\n+ }, 10);\n+ } else { }\nthis.onPageChange.emit({\nactivePage: this.activePage,\n"
}
] | TypeScript | MIT License | promact/md2 | fix(data-table) active page change event while page change after data updates |
530,388 | 17.01.2017 14:03:07 | -19,080 | 7d727e57bedc1c447735bfaa938706426787f50c | chore(data-table) update docs | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/README.md",
"new_path": "src/lib/data-table/README.md",
"diff": "@@ -12,6 +12,14 @@ Data Table is a arrange data in ordering searching and paginate it.\n| `sortBy` | `string` or `Array<string>` | Sort by parameter(s) |\n| `sortOrder` | `string` | Sort order parameters are 'asc' or 'desc' |\n+### Events\n+\n+| Name | Type | Description |\n+| --- | --- | --- |\n+| `activePageChange` | `Event` | Fired when change the active page |\n+| `sortByChange` | `Event` | Fired when change sort by |\n+| `sortOrderChange` | `Event` | Fired when change sort order |\n+\n### Examples\nA Datatable would have the following markup.\n```html\n"
}
] | TypeScript | MIT License | promact/md2 | chore(data-table) update docs |
530,388 | 19.01.2017 22:28:00 | -19,080 | 77ff6bd5547ef6baf78afce3239fe26b62bb2262 | feat(datepicker) added date-locale | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/lib/datepicker/date-locale.ts",
"diff": "+import {\n+ Injectable,\n+} from '@angular/core';\n+\n+/** Date locale info. TODO(mmalerba): Integrate with i18n solution once we know what we're doing. */\n+@Injectable()\n+export class DateLocale {\n+ firstDayOfWeek = 0;\n+\n+ months = [\n+ { full: 'January', short: 'Jan' },\n+ { full: 'February', short: 'Feb' },\n+ { full: 'March', short: 'Mar' },\n+ { full: 'April', short: 'Apr' },\n+ { full: 'May', short: 'May' },\n+ { full: 'June', short: 'Jun' },\n+ { full: 'July', short: 'Jul' },\n+ { full: 'August', short: 'Aug' },\n+ { full: 'September', short: 'Sep' },\n+ { full: 'October', short: 'Oct' },\n+ { full: 'November', short: 'Nov' },\n+ { full: 'December', short: 'Dec' },\n+ ];\n+\n+ days = [\n+ { full: 'Sunday', short: 'Sun', xshort: 'S' },\n+ { full: 'Monday', short: 'Mon', xshort: 'M' },\n+ { full: 'Tuesday', short: 'Tue', xshort: 'T' },\n+ { full: 'Wednesday', short: 'Wed', xshort: 'W' },\n+ { full: 'Thursday', short: 'Thu', xshort: 'T' },\n+ { full: 'Friday', short: 'Fri', xshort: 'F' },\n+ { full: 'Saturday', short: 'Sat', xshort: 'S' },\n+ ];\n+\n+ getDateLabel(d: number) { return `${d}`; }\n+\n+ getMonthLabel(m: number, y: number) { return `${this.months[m].short.toUpperCase()} ${y}`; }\n+\n+ getYearLabel(y: number) { return `${y}`; }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "<div class=\"md2-calendar-header\">{{_viewDay.month}} {{_viewDay.year}}</div>\n</div>\n<table class=\"md2-calendar-dates\">\n- <thead><tr><th *ngFor=\"let d of _days\">{{d.substr(0, 1)}}</th></tr></thead>\n+ <thead><tr><th *ngFor=\"let day of _weekDays\">{{day.xshort}}</th></tr></thead>\n<tbody>\n<tr *ngFor=\"let w of _dates\">\n<td *ngFor=\"let d of w\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -17,6 +17,7 @@ import {\n} from '@angular/forms';\nimport { CommonModule } from '@angular/common';\nimport { Md2DateUtil } from './dateUtil';\n+import { DateLocale } from './date-locale';\nimport {\ncoerceBooleanProperty,\n@@ -80,8 +81,11 @@ let nextId = 0;\n})\nexport class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n- constructor(private _dateUtil: Md2DateUtil, private element: ElementRef,\n+ constructor(private _dateUtil: Md2DateUtil, private _locale: DateLocale, private element: ElementRef,\n@Optional() public _control: NgControl) {\n+\n+ this._weekDays = _locale.days;\n+\nthis.getYears();\nthis.generateClock();\n// this.mouseMoveListener = (event: MouseEvent) => { this.onMouseMoveClock(event); };\n@@ -104,6 +108,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _required: boolean = false;\nprivate _disabled: boolean = false;\nprivate _isInitialized: boolean = false;\n+\n_onChange = (value: any) => { };\n_onTouched = () => { };\n@@ -112,10 +117,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n_isCalendarVisible: boolean;\n_isHoursVisible: boolean = true;\n- private months: Array<string> = ['January', 'February', 'March', 'April',\n- 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\n- _days: Array<string> = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',\n- 'Friday', 'Saturday'];\n+ _weekDays: Array<any>;\n+\n_hours: Array<Object> = [];\n_minutes: Array<Object> = [];\n@@ -235,9 +238,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._displayDate = date;\nthis._viewDay = {\nyear: date.getFullYear(),\n- month: this.months[date.getMonth()],\n+ month: this._locale.months[date.getMonth()].full,\ndate: this._prependZero(date.getDate() + ''),\n- day: this._days[date.getDay()],\n+ day: this._locale.days[date.getDay()].full,\nhour: this._prependZero(date.getHours() + ''),\nminute: this._prependZero(date.getMinutes() + '')\n};\n@@ -916,7 +919,7 @@ export class Md2DatepickerModule {\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2DatepickerModule,\n- providers: [Md2DateUtil]\n+ providers: [Md2DateUtil, DateLocale]\n};\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | feat(datepicker) added date-locale #50 |
530,388 | 22.01.2017 15:54:36 | -19,080 | bcd5ad1b63fa20df51f2a33a3aa34ee32a8bf6dd | chore(datepicker) update structure | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -28,7 +28,7 @@ md2-datepicker {\ncursor: pointer;\n}\n-.md2-datepicker-calendar-icon {\n+.md2-datepicker-icon {\nposition: absolute;\ntop: 21px;\nleft: 0;\n@@ -64,9 +64,8 @@ md2-datepicker {\ncolor: $warn;\nborder-bottom: 1px solid $warn;\n}\n-}\n-md2-datepicker.md2-datepicker-disabled .md2-datepicker-input {\n+ .md2-datepicker-disabled & {\ncolor: rgba(black, 0.38);\nborder-color: transparent;\nbackground-image: linear-gradient(to right, rgba(black, 0.38) 0%, rgba(black, 0.38) 33%, transparent 0%);\n@@ -74,6 +73,7 @@ md2-datepicker.md2-datepicker-disabled .md2-datepicker-input {\nbackground-size: 4px 1px;\nbackground-repeat: repeat-x;\n}\n+}\n.md2-datepicker-placeholder {\nposition: absolute;\n@@ -126,8 +126,9 @@ md2-datepicker.md2-datepicker-disabled:focus {\nleft: 0;\ndisplay: inline-block;\nwidth: 300px;\n- border-radius: 2px;\n+ border-radius: 3px;\nbackground-color: white;\n+ overflow: hidden;\nz-index: 10;\nbox-shadow: 0 2px 6px rgba(black, 0.4);\ntransform: scale(0);\n@@ -147,6 +148,10 @@ md2-datepicker.md2-datepicker-disabled:focus {\nwhite-space: nowrap;\nbackground: $primary;\nbox-sizing: border-box;\n+\n+ .hidden {\n+ display: none;\n+ }\n}\n.md2-datepicker-header-year {\n@@ -158,10 +163,6 @@ md2-datepicker.md2-datepicker-disabled:focus {\nopacity: 1;\npointer-events: none;\n}\n-\n- &.hidden {\n- display: none;\n- }\n}\n.md2-datepicker-header-date-time {\n@@ -176,10 +177,6 @@ md2-datepicker.md2-datepicker-disabled:focus {\nopacity: 1;\npointer-events: none;\n}\n-\n- &.hidden {\n- display: none;\n- }\n}\n.md2-datepicker-header-time {\n@@ -201,16 +198,8 @@ md2-datepicker.md2-datepicker-disabled:focus {\nopacity: 1;\npointer-events: none;\n}\n-\n- &.hidden {\n- display: none;\n- }\n}\n}\n-\n- &.hidden {\n- display: none;\n- }\n}\n.md2-datepicker-content {\n@@ -291,41 +280,33 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n-.md2-calendar-controls {\n- position: relative;\n- display: block;\n- height: 48px;\n- text-align: left;\n-}\n-\n-.md2-calendar-header {\n- height: 48px;\n- line-height: 48px;\n+.md2-calendar-month-header {\n+ display: flex;\n+ justify-content: space-between;\nfont-size: 14px;\n- font-weight: 500;\n+ font-weight: 700;\ntext-align: center;\n-}\n+ line-height: 48px;\n-.md2-calendar-prev-month,\n-.md2-calendar-next-month {\n- position: absolute;\n+ .md2-button {\ndisplay: inline-block;\nwidth: 48px;\nheight: 48px;\npadding: 12px;\n- margin: 0 12px;\n- box-sizing: border-box;\n+ outline: none;\n+ border: 0;\ncursor: pointer;\n+ background: transparent;\n+ box-sizing: border-box;\n- &.disabled {\n- opacity: 0.25;\n- cursor: default;\n- pointer-events: none;\n+ svg {\n+ vertical-align: top;\n}\n}\n-.md2-calendar-next-month {\n- right: 0;\n+ .md2-calendar-month-year-header {\n+ width: 100%;\n+ }\n}\n.md2-calendar-dates {\n@@ -496,11 +477,12 @@ md2-datepicker.md2-datepicker-disabled:focus {\n@media (min-width: 600px) {\n.md2-datepicker-panel {\ndisplay: flex;\n- width: 430px;\n+ width: 450px;\n}\n.md2-datepicker-header {\n- width: 130px;\n+ width: 150px;\n+ min-width: 150px;\npadding-right: 15px;\nwhite-space: normal;\nword-wrap: break-word;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -7,6 +7,8 @@ import {\nOutput,\nOptional,\nEventEmitter,\n+ Renderer,\n+ Self,\nViewEncapsulation,\nNgModule,\nModuleWithProviders\n@@ -81,8 +83,15 @@ let nextId = 0;\n})\nexport class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n- constructor(private _dateUtil: Md2DateUtil, private _locale: DateLocale, private element: ElementRef,\n- @Optional() public _control: NgControl) {\n+ private _panelOpen = false;\n+ private _selected: Date = null;\n+\n+ constructor(private _element: ElementRef, private _renderer: Renderer,\n+ private _dateUtil: Md2DateUtil, private _locale: DateLocale,\n+ @Self() @Optional() public _control: NgControl) {\n+ if (this._control) {\n+ this._control.valueAccessor = this;\n+ }\nthis._weekDays = _locale.days;\n@@ -90,9 +99,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.generateClock();\n// this.mouseMoveListener = (event: MouseEvent) => { this.onMouseMoveClock(event); };\n// this.mouseUpListener = (event: MouseEvent) => { this.onMouseUpClock(event); };\n- if (this._control) {\n- this._control.valueAccessor = this;\n- }\n}\nngAfterContentInit() {\n@@ -100,6 +106,37 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._isCalendarVisible = this.type !== 'time' ? true : false;\n}\n+ @Input()\n+ get selected() { return this._selected; }\n+ set selected(value: Date) { this._selected = value; }\n+\n+ get panelOpen(): boolean {\n+ return this._panelOpen;\n+ }\n+\n+ toggle(): void {\n+ this.panelOpen ? this.close() : this.open();\n+ }\n+\n+ /** Opens the overlay panel. */\n+ open(): void {\n+ if (this.disabled) { return; }\n+ this._panelOpen = true;\n+ }\n+\n+ /** Closes the overlay panel and focuses the host element. */\n+ close(): void {\n+ this._panelOpen = false;\n+ //if (!this._value) {\n+ // this._placeholderState = '';\n+ //}\n+ this._focusHost();\n+ }\n+\n+ private _focusHost(): void {\n+ this._renderer.invokeElementMethod(this._element.nativeElement, 'focus');\n+ }\n+\n// private mouseMoveListener: any;\n// private mouseUpListener: any;\n@@ -130,7 +167,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n_dates: Array<Object> = [];\nprivate today: Date = new Date();\nprivate _displayDate: Date = null;\n- _selectedDate: Date = null;\n_viewDay: IDay = { year: 0, month: '', date: '', day: '', hour: '', minute: '' };\n_viewValue: string = '';\n@@ -399,8 +435,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _scrollToSelectedYear() {\nsetTimeout(() => {\n- let yearContainer = this.element.nativeElement.querySelector('.md2-calendar-years'),\n- selectedYear = this.element.nativeElement.querySelector('.md2-calendar-year.selected');\n+ let yearContainer = this._element.nativeElement.querySelector('.md2-calendar-years'),\n+ selectedYear = this._element.nativeElement.querySelector('.md2-calendar-year.selected');\nyearContainer.scrollTop = (selectedYear.offsetTop + 20) - yearContainer.clientHeight / 2;\n}, 0);\n}\n@@ -423,11 +459,11 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n_showDatepicker() {\nif (this.disabled || this.readonly) { return; }\nthis._isDatepickerVisible = true;\n- this._selectedDate = this.value || new Date(1, 0, 1);\n+ this.selected = this.value || new Date(1, 0, 1);\nthis.displayDate = this.value || this.today;\nthis.generateCalendar();\nthis._resetClock();\n- this.element.nativeElement.focus();\n+ this._element.nativeElement.focus();\n}\n/**\n@@ -496,7 +532,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.value = date;\nthis._onBlur();\n} else {\n- this._selectedDate = date;\n+ this.selected = date;\nthis.displayDate = date;\nthis._isCalendarVisible = false;\nthis._isHoursVisible = true;\n@@ -670,8 +706,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nlet date = this.displayDate;\nthis.displayDate = new Date(date.getFullYear(), date.getMonth(),\ndate.getDate(), date.getHours(), minute);\n- this._selectedDate = this.displayDate;\n- this.value = this._selectedDate;\n+ this.selected = this.displayDate;\n+ this.value = this.displayDate;\nthis._onBlur();\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update structure |
530,388 | 24.01.2017 17:19:57 | -19,080 | b5789fd498d3d86814f1fb572c86be97a42b43d6 | fix(select) option menu width issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.ts",
"new_path": "src/lib/select/select.ts",
"diff": "@@ -204,9 +204,6 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nset placeholder(value: string) {\nthis._placeholder = value;\n-\n- // Must wait to record the trigger width to ensure placeholder width is included.\n- Promise.resolve(null).then(() => this._triggerWidth = this._getWidth());\n}\n@Input()\n@@ -277,6 +274,7 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nif (this.disabled) {\nreturn;\n}\n+ this._triggerWidth = this._getWidth();\nthis._calculateOverlayPosition();\nthis._placeholderState = this._isRtl() ? 'floating-rtl' : 'floating-ltr';\nthis._panelOpen = true;\n"
}
] | TypeScript | MIT License | promact/md2 | fix(select) option menu width issue |
530,388 | 24.01.2017 17:20:23 | -19,080 | a4bbe79734a8dfffc48ce557e53ea49ea861eed6 | fix(tabs) invalid active tab index | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tabs/tabs.ts",
"new_path": "src/lib/tabs/tabs.ts",
"diff": "@@ -150,6 +150,9 @@ export class Md2Tabs implements AfterContentInit {\nsetTimeout(() => {\nconst tabs = this.tabs.toArray();\nif (this.selectedIndex) {\n+ if (this.selectedIndex >= tabs.length) {\n+ this.selectedIndex = 0;\n+ }\ntabs.forEach(tab => tab.active = false);\ntabs[this.selectedIndex].active = true;\nthis.adjustOffset(this.selectedIndex);\n"
}
] | TypeScript | MIT License | promact/md2 | fix(tabs) invalid active tab index |
530,388 | 24.01.2017 23:17:30 | -19,080 | f345330e62cb4ab7cc6240f863f82baf7728cbc0 | chore(datepicker) initially added overlay | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -121,24 +121,12 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n.md2-datepicker-panel {\n- position: absolute;\n- top: 0;\n- left: 0;\n- display: inline-block;\nwidth: 300px;\nborder-radius: 3px;\nbackground-color: white;\noverflow: hidden;\n- z-index: 10;\nbox-shadow: 0 2px 6px rgba(black, 0.4);\n- transform: scale(0);\n- transform-origin: left top;\n- transition: 150ms;\nuser-select: none;\n-\n- &.active {\n- transform: scale(1);\n- }\n}\n.md2-datepicker-header {\n@@ -496,3 +484,43 @@ md2-datepicker.md2-datepicker-disabled:focus {\n.md2-datepicker-content {\n}\n}\n+\n+.cdk-overlay-container, .cdk-global-overlay-wrapper {\n+ pointer-events: none;\n+ top: 0;\n+ left: 0;\n+ height: 100%;\n+ width: 100%;\n+}\n+\n+.cdk-overlay-container {\n+ position: fixed;\n+ z-index: 1000;\n+}\n+\n+.cdk-overlay-pane {\n+ position: absolute;\n+ pointer-events: auto;\n+ box-sizing: border-box;\n+ z-index: 1000;\n+}\n+\n+.cdk-overlay-backdrop {\n+ position: absolute;\n+ top: 0;\n+ bottom: 0;\n+ left: 0;\n+ right: 0;\n+ z-index: 1000;\n+ pointer-events: auto;\n+ transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n+ opacity: 0;\n+}\n+\n+.cdk-overlay-transparent-backdrop {\n+ background: none;\n+}\n+\n+.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\n+ opacity: 0.48;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -20,6 +20,10 @@ import {\nimport { CommonModule } from '@angular/common';\nimport { Md2DateUtil } from './dateUtil';\nimport { DateLocale } from './date-locale';\n+import {\n+ OverlayModule,\n+} from '../core';\n+import { transformPlaceholder, transformPanel, fadeInContent } from '../select/select-animations';\nimport {\ncoerceBooleanProperty,\n@@ -73,12 +77,19 @@ let nextId = 0;\n'role': 'datepicker',\n'[id]': 'id',\n'[class.md2-datepicker-disabled]': 'disabled',\n- '[tabindex]': 'disabled ? -1 : tabindex',\n+ '[attr.tabindex]': 'disabled ? -1 : tabindex',\n'[attr.aria-label]': 'placeholder',\n'[attr.aria-required]': 'required.toString()',\n'[attr.aria-disabled]': 'disabled.toString()',\n'[attr.aria-invalid]': '_control?.invalid || \"false\"',\n+ '(keydown)': '_handleKeydown($event)',\n+ '(blur)': '_onBlur()'\n},\n+ animations: [\n+ transformPlaceholder,\n+ transformPanel,\n+ fadeInContent\n+ ],\nencapsulation: ViewEncapsulation.None\n})\nexport class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n@@ -86,6 +97,24 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _panelOpen = false;\nprivate _selected: Date = null;\n+ _transformOrigin: string = 'top';\n+ _panelDoneAnimating: boolean = false;\n+\n+ _positions = [\n+ {\n+ originX: 'start',\n+ originY: 'top',\n+ overlayX: 'start',\n+ overlayY: 'top',\n+ },\n+ {\n+ originX: 'start',\n+ originY: 'bottom',\n+ overlayX: 'start',\n+ overlayY: 'bottom',\n+ },\n+ ];\n+\nconstructor(private _element: ElementRef, private _renderer: Renderer,\nprivate _dateUtil: Md2DateUtil, private _locale: DateLocale,\n@Self() @Optional() public _control: NgControl) {\n@@ -122,6 +151,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nopen(): void {\nif (this.disabled) { return; }\nthis._panelOpen = true;\n+ this._showDatepicker();\n}\n/** Closes the overlay panel and focuses the host element. */\n@@ -133,6 +163,19 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._focusHost();\n}\n+ _onPanelDone(): void {\n+ if (this.panelOpen) {\n+ //this._focusCorrectOption();\n+ //this.onOpen.emit();\n+ } else {\n+ //this.onClose.emit();\n+ }\n+ }\n+\n+ _onFadeInDone(): void {\n+ this._panelDoneAnimating = this.panelOpen;\n+ }\n+\nprivate _focusHost(): void {\nthis._renderer.invokeElementMethod(this._element.nativeElement, 'focus');\n}\n@@ -149,7 +192,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n_onChange = (value: any) => { };\n_onTouched = () => { };\n- _isDatepickerVisible: boolean;\n_isYearsVisible: boolean;\n_isCalendarVisible: boolean;\n_isHoursVisible: boolean = true;\n@@ -292,17 +334,16 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\n}\n- @HostListener('keydown', ['$event'])\n_handleKeydown(event: KeyboardEvent) {\nif (this.disabled) { return; }\n- if (this._isDatepickerVisible) {\n+ if (this.panelOpen) {\nevent.preventDefault();\nevent.stopPropagation();\nswitch (event.keyCode) {\ncase TAB:\n- case ESCAPE: this._onBlur(); break;\n+ case ESCAPE: this._onBlur(); this.close(); break;\n}\nlet displayDate = this.displayDate;\nif (this._isYearsVisible) {\n@@ -407,14 +448,17 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\n}\n- @HostListener('blur')\n_onBlur() {\n- this._isDatepickerVisible = false;\n- this._isYearsVisible = false;\n- this._isCalendarVisible = this.type !== 'time' ? true : false;\n- this._isHoursVisible = true;\n+ if (!this.panelOpen) {\nthis._onTouched();\n}\n+ //this._isYearsVisible = false;\n+ //this._isCalendarVisible = this.type !== 'time' ? true : false;\n+ //this._isHoursVisible = true;\n+ //this._onTouched();\n+ }\n+\n+\n/**\n* Display Years\n*/\n@@ -458,7 +502,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n*/\n_showDatepicker() {\nif (this.disabled || this.readonly) { return; }\n- this._isDatepickerVisible = true;\nthis.selected = this.value || new Date(1, 0, 1);\nthis.displayDate = this.value || this.today;\nthis.generateCalendar();\n@@ -501,6 +544,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n} else {\nthis.value = this.displayDate;\nthis._onBlur();\n+ this.close();\n}\n}\n@@ -531,6 +575,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nif (this.type === 'date') {\nthis.value = date;\nthis._onBlur();\n+ this.close();\n} else {\nthis.selected = date;\nthis.displayDate = date;\n@@ -709,6 +754,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.selected = this.displayDate;\nthis.value = this.displayDate;\nthis._onBlur();\n+ this.close();\n}\n// private onMouseDownClock(event: MouseEvent) {\n@@ -942,12 +988,124 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nregisterOnTouched(fn: () => {}): void { this._onTouched = fn; }\n+\n+ ///**\n+ // * Calculates the y-offset of the select's overlay panel in relation to the\n+ // * top start corner of the trigger. It has to be adjusted in order for the\n+ // * selected option to be aligned over the trigger when the panel opens.\n+ // */\n+ //private _calculateOverlayOffset(selectedIndex: number, scrollBuffer: number,\n+ // maxScroll: number): number {\n+ // let optionOffsetFromPanelTop: number;\n+\n+ // if (this._scrollTop === 0) {\n+ // optionOffsetFromPanelTop = selectedIndex * SELECT_OPTION_HEIGHT;\n+ // } else if (this._scrollTop === maxScroll) {\n+ // const firstDisplayedIndex = this.options.length - SELECT_MAX_OPTIONS_DISPLAYED;\n+ // const selectedDisplayIndex = selectedIndex - firstDisplayedIndex;\n+\n+ // // Because the panel height is longer than the height of the options alone,\n+ // // there is always extra padding at the top or bottom of the panel. When\n+ // // scrolled to the very bottom, this padding is at the top of the panel and\n+ // // must be added to the offset.\n+ // optionOffsetFromPanelTop =\n+ // selectedDisplayIndex * SELECT_OPTION_HEIGHT + SELECT_PANEL_PADDING_Y;\n+ // } else {\n+ // // If the option was scrolled to the middle of the panel using a scroll buffer,\n+ // // its offset will be the scroll buffer minus the half height that was added to\n+ // // center it.\n+ // optionOffsetFromPanelTop = scrollBuffer - SELECT_OPTION_HEIGHT / 2;\n+ // }\n+\n+ // // The final offset is the option's offset from the top, adjusted for the height\n+ // // difference, multiplied by -1 to ensure that the overlay moves in the correct\n+ // // direction up the page.\n+ // return optionOffsetFromPanelTop * -1 - SELECT_OPTION_HEIGHT_ADJUSTMENT;\n+ //}\n+\n+ ///**\n+ // * Checks that the attempted overlay position will fit within the viewport.\n+ // * If it will not fit, tries to adjust the scroll position and the associated\n+ // * y-offset so the panel can open fully on-screen. If it still won't fit,\n+ // * sets the offset back to 0 to allow the fallback position to take over.\n+ // */\n+ //private _checkOverlayWithinViewport(maxScroll: number): void {\n+ // const viewportRect = this._viewportRuler.getViewportRect();\n+ // const triggerRect = this._getTriggerRect();\n+\n+ // const topSpaceAvailable = triggerRect.top - SELECT_PANEL_VIEWPORT_PADDING;\n+ // const bottomSpaceAvailable =\n+ // viewportRect.height - triggerRect.bottom - SELECT_PANEL_VIEWPORT_PADDING;\n+\n+ // const panelHeightTop = Math.abs(this._offsetY);\n+ // const totalPanelHeight =\n+ // Math.min(this.options.length * SELECT_OPTION_HEIGHT, SELECT_PANEL_MAX_HEIGHT);\n+ // const panelHeightBottom = totalPanelHeight - panelHeightTop - triggerRect.height;\n+\n+ // if (panelHeightBottom > bottomSpaceAvailable) {\n+ // this._adjustPanelUp(panelHeightBottom, bottomSpaceAvailable);\n+ // } else if (panelHeightTop > topSpaceAvailable) {\n+ // this._adjustPanelDown(panelHeightTop, topSpaceAvailable, maxScroll);\n+ // } else {\n+ // this._transformOrigin = this._getOriginBasedOnOption();\n+ // }\n+ //}\n+\n+ ///** Adjusts the overlay panel up to fit in the viewport. */\n+ //private _adjustPanelUp(panelHeightBottom: number, bottomSpaceAvailable: number) {\n+ // const distanceBelowViewport = panelHeightBottom - bottomSpaceAvailable;\n+\n+ // // Scrolls the panel up by the distance it was extending past the boundary, then\n+ // // adjusts the offset by that amount to move the panel up into the viewport.\n+ // this._scrollTop -= distanceBelowViewport;\n+ // this._offsetY -= distanceBelowViewport;\n+ // this._transformOrigin = this._getOriginBasedOnOption();\n+\n+ // // If the panel is scrolled to the very top, it won't be able to fit the panel\n+ // // by scrolling, so set the offset to 0 to allow the fallback position to take\n+ // // effect.\n+ // if (this._scrollTop <= 0) {\n+ // this._scrollTop = 0;\n+ // this._offsetY = 0;\n+ // this._transformOrigin = `50% bottom 0px`;\n+ // }\n+ //}\n+\n+ ///** Adjusts the overlay panel down to fit in the viewport. */\n+ //private _adjustPanelDown(panelHeightTop: number, topSpaceAvailable: number,\n+ // maxScroll: number) {\n+ // const distanceAboveViewport = panelHeightTop - topSpaceAvailable;\n+\n+ // // Scrolls the panel down by the distance it was extending past the boundary, then\n+ // // adjusts the offset by that amount to move the panel down into the viewport.\n+ // this._scrollTop += distanceAboveViewport;\n+ // this._offsetY += distanceAboveViewport;\n+ // this._transformOrigin = this._getOriginBasedOnOption();\n+\n+ // // If the panel is scrolled to the very bottom, it won't be able to fit the\n+ // // panel by scrolling, so set the offset to 0 to allow the fallback position\n+ // // to take effect.\n+ // if (this._scrollTop >= maxScroll) {\n+ // this._scrollTop = maxScroll;\n+ // this._offsetY = 0;\n+ // this._transformOrigin = `50% top 0px`;\n+ // return;\n+ // }\n+ //}\n+\n+ ///** Sets the transform origin point based on the selected option. */\n+ //private _getOriginBasedOnOption(): string {\n+ // const originY =\n+ // Math.abs(this._offsetY) - SELECT_OPTION_HEIGHT_ADJUSTMENT + SELECT_OPTION_HEIGHT / 2;\n+ // return `50% ${originY}px 0px`;\n+ //}\n+\n}\nexport const MD2_DATEPICKER_DIRECTIVES = [Md2Datepicker];\n@NgModule({\n- imports: [CommonModule],\n+ imports: [CommonModule, OverlayModule],\nexports: MD2_DATEPICKER_DIRECTIVES,\ndeclarations: MD2_DATEPICKER_DIRECTIVES,\n})\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) initially added overlay |
530,388 | 26.01.2017 18:47:16 | -19,080 | 8e0269b786f167847e369135250465c50bcf2fe9 | fix(datepicker) ie issue panel open inside view port | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "backdropClass=\"cdk-overlay-transparent-backdrop\" [positions]=\"_positions\">\n<div class=\"md2-datepicker-panel\" [@transformPanel]=\"'showing'\" (@transformPanel.done)=\"_onPanelDone()\"\n(keydown)=\"_handleKeydown($event)\" [style.transformOrigin]=\"_transformOrigin\"\n- [class.md2-datepicker-panel-done-animating]=\"_panelDoneAnimating\">\n+ [class.md2-datepicker-panel-done-animating]=\"_panelDoneAnimating\" tabindex=\"0\">\n<div class=\"md2-datepicker-header\">\n<div class=\"md2-datepicker-header-year\"\n[class.active]=\"_isYearsVisible\"\n</div>\n</div>\n<div class=\"md2-datepicker-actions\">\n- <div class=\"md2-button\" (click)=\"_onBlur()\">Cancel</div>\n+ <div class=\"md2-button\" (click)=\"close()\">Cancel</div>\n<div class=\"md2-button\" (click)=\"_onClickOk()\">Ok</div>\n</div>\n</div>\n-\n-\n- <!--<div class=\"md2-datepicker-content\" [@fadeInContent]=\"'showing'\" (@fadeInContent.done)=\"_onFadeInDone()\">\n- <ng-content></ng-content>\n- Test Panel\n- </div>-->\n</div>\n</template>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -127,6 +127,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\nbackground-color: white;\noverflow: hidden;\nbox-shadow: 0 2px 6px rgba(black, 0.4);\n+ outline: none;\nuser-select: none;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -115,6 +115,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n},\n];\n+ @Output() onOpen: EventEmitter<void> = new EventEmitter<void>();\n+ @Output() onClose: EventEmitter<void> = new EventEmitter<void>();\n+\nconstructor(private _element: ElementRef, private _renderer: Renderer,\nprivate _dateUtil: Md2DateUtil, private _locale: DateLocale,\n@Self() @Optional() public _control: NgControl) {\n@@ -165,10 +168,10 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n_onPanelDone(): void {\nif (this.panelOpen) {\n- //this._focusCorrectOption();\n- //this.onOpen.emit();\n+ this._focusPanel();\n+ this.onOpen.emit();\n} else {\n- //this.onClose.emit();\n+ this.onClose.emit();\n}\n}\n@@ -176,6 +179,11 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._panelDoneAnimating = this.panelOpen;\n}\n+ private _focusPanel(): void {\n+ let el: any = document.querySelectorAll('.md2-datepicker-panel')[0];\n+ el.focus();\n+ }\n+\nprivate _focusHost(): void {\nthis._renderer.invokeElementMethod(this._element.nativeElement, 'focus');\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) ie issue #43, panel open inside view port #58 |
530,388 | 26.01.2017 19:34:57 | -19,080 | a5de60c084f7f390bb639455717e897d95b5f6b6 | fix(datepicker) formatting issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -192,6 +192,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n// private mouseUpListener: any;\nprivate _value: Date = null;\n+ private _format: string = this.type === 'date' ?\n+ 'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n+ 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY';\nprivate _readonly: boolean = false;\nprivate _required: boolean = false;\nprivate _disabled: boolean = false;\n@@ -240,11 +243,17 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n@Input() name: string = '';\n@Input() id: string = 'md2-datepicker-' + (++nextId);\n@Input() placeholder: string;\n- @Input() format: string = this.type === 'date' ?\n- 'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n- 'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY';\n@Input() tabindex: number = 0;\n+ @Input()\n+ get format(): string { return this._format; }\n+ set format(value) {\n+ this._format = value;\n+ if (this._value) {\n+ this._viewValue = this._formatDate(this._value);\n+ }\n+ }\n+\n@Input()\nget readonly(): boolean { return this._readonly; }\nset readonly(value) { this._readonly = coerceBooleanProperty(value); }\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) formatting issue #69 |
530,388 | 28.01.2017 00:38:22 | -19,080 | b9d3a6cb253b19dd096479a6f4af50ec1b5050a4 | chore(datepicker) update performance | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "</svg>\n</div>\n<div class=\"md2-datepicker-input\">\n- <span class=\"md2-datepicker-placeholder\" [class.has-value]=\"value\"> {{ placeholder }} </span>\n+ <span class=\"md2-datepicker-placeholder\" [class.has-value]=\"date\"> {{ placeholder }} </span>\n<span class=\"md2-datepicker-input-text\">{{_viewValue}}</span>\n<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\">\n<path d=\"M7 10l5 5 5-5z\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -41,6 +41,12 @@ import {\nDOWN_ARROW\n} from '../core/core';\n+/** Change event object emitted by Md2Select. */\n+export class Md2DateChange {\n+ source: Md2Datepicker;\n+ date: Date;\n+}\n+\nexport interface IDay {\nyear: number;\nmonth: string;\n@@ -94,6 +100,7 @@ let nextId = 0;\n})\nexport class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n+ private _date: Date = null;\nprivate _panelOpen = false;\nprivate _selected: Date = null;\n@@ -138,6 +145,41 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._isCalendarVisible = this.type !== 'time' ? true : false;\n}\n+ @Input()\n+ get date() { return this._date; }\n+ set date(value: Date) {\n+ this._date = this.coerceDateProperty(value);\n+ if (value && value !== this._date) {\n+ if (this._dateUtil.isValidDate(value)) {\n+ this._date = value;\n+ } else {\n+ if (this.type === 'time') {\n+ this._date = new Date('1-1-1 ' + value);\n+ } else {\n+ this._date = new Date(value);\n+ }\n+ }\n+ this._viewValue = this._formatDate(this._date);\n+ let date = '';\n+ if (this.type !== 'time') {\n+ date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n+ '-' + this._date.getDate();\n+ }\n+ if (this.type === 'datetime') {\n+ date += ' ';\n+ }\n+ if (this.type !== 'date') {\n+ date += this._date.getHours() + ':' + this._date.getMinutes();\n+ }\n+ if (this._isInitialized) {\n+ if (this._control) {\n+ this._onChange(date);\n+ }\n+ this.change.emit(date);\n+ }\n+ }\n+ }\n+\n@Input()\nget selected() { return this._selected; }\nset selected(value: Date) { this._selected = value; }\n@@ -160,7 +202,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n/** Closes the overlay panel and focuses the host element. */\nclose(): void {\nthis._panelOpen = false;\n- //if (!this._value) {\n+ //if (!this._date) {\n// this._placeholderState = '';\n//}\nthis._focusHost();\n@@ -188,10 +230,14 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._renderer.invokeElementMethod(this._element.nativeElement, 'focus');\n}\n+ private coerceDateProperty(value: any, fallbackValue = new Date()): Date {\n+ let timestamp = Date.parse(value);\n+ return isNaN(timestamp) ? fallbackValue : new Date(timestamp);\n+ }\n+\n// private mouseMoveListener: any;\n// private mouseUpListener: any;\n- private _value: Date = null;\nprivate _format: string = this.type === 'date' ?\n'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY';\n@@ -250,8 +296,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nset format(value) {\nif (this._format !== value) {\nthis._format = value || this._format;\n- if (this._viewValue && this._value) {\n- this._viewValue = this._formatDate(this._value);\n+ if (this._viewValue && this._date) {\n+ this._viewValue = this._formatDate(this._date);\n}\n}\n}\n@@ -283,40 +329,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n} else { this._max = null; }\n}\n- @Input()\n- get value(): any { return this._value; }\n- set value(value: any) {\n- if (value && value !== this._value) {\n- if (this._dateUtil.isValidDate(value)) {\n- this._value = value;\n- } else {\n- if (this.type === 'time') {\n- this._value = new Date('1-1-1 ' + value);\n- } else {\n- this._value = new Date(value);\n- }\n- }\n- this._viewValue = this._formatDate(this._value);\n- let date = '';\n- if (this.type !== 'time') {\n- date += this._value.getFullYear() + '-' + (this._value.getMonth() + 1) +\n- '-' + this._value.getDate();\n- }\n- if (this.type === 'datetime') {\n- date += ' ';\n- }\n- if (this.type !== 'date') {\n- date += this._value.getHours() + ':' + this._value.getMinutes();\n- }\n- if (this._isInitialized) {\n- if (this._control) {\n- this._onChange(date);\n- }\n- this.change.emit(date);\n- }\n- }\n- }\n-\nget displayDate(): Date {\nif (this._displayDate && this._dateUtil.isValidDate(this._displayDate)) {\nreturn this._displayDate;\n@@ -521,8 +533,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n*/\n_showDatepicker() {\nif (this.disabled || this.readonly) { return; }\n- this.selected = this.value || new Date(1, 0, 1);\n- this.displayDate = this.value || this.today;\n+ this.selected = this.date || new Date(1, 0, 1);\n+ this.displayDate = this.date || this.today;\nthis.generateCalendar();\nthis._resetClock();\nthis._element.nativeElement.focus();\n@@ -561,7 +573,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._isHoursVisible = false;\nthis._resetClock();\n} else {\n- this.value = this.displayDate;\n+ this.date = this.displayDate;\nthis._onBlur();\nthis.close();\n}\n@@ -592,7 +604,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n*/\nprivate setDate(date: Date) {\nif (this.type === 'date') {\n- this.value = date;\n+ this.date = date;\nthis._onBlur();\nthis.close();\n} else {\n@@ -771,7 +783,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.displayDate = new Date(date.getFullYear(), date.getMonth(),\ndate.getDate(), date.getHours(), minute);\nthis.selected = this.displayDate;\n- this.value = this.displayDate;\n+ this.date = this.displayDate;\nthis._onBlur();\nthis.close();\n}\n@@ -974,31 +986,39 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n};\n}\n+ private _emitChangeEvent(): void {\n+ let event = new Md2DateChange();\n+ event.source = this;\n+ event.date = this._date;\n+ this._onChange(event.date);\n+ this.change.emit(event);\n+ }\n+\nwriteValue(value: any): void {\n- if (value && value !== this._value) {\n+ if (value && value !== this._date) {\nif (this._dateUtil.isValidDate(value)) {\n- this._value = value;\n+ this._date = value;\n} else {\nif (this.type === 'time') {\n- this._value = new Date('1-1-1 ' + value);\n+ this._date = new Date('1-1-1 ' + value);\n} else {\n- this._value = new Date(value);\n+ this._date = new Date(value);\n}\n}\n- this._viewValue = this._formatDate(this._value);\n+ this._viewValue = this._formatDate(this._date);\nlet date = '';\nif (this.type !== 'time') {\n- date += this._value.getFullYear() + '-' + (this._value.getMonth() + 1) +\n- '-' + this._value.getDate();\n+ date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n+ '-' + this._date.getDate();\n}\nif (this.type === 'datetime') {\ndate += ' ';\n}\nif (this.type !== 'date') {\n- date += this._value.getHours() + ':' + this._value.getMinutes();\n+ date += this._date.getHours() + ':' + this._date.getMinutes();\n}\n} else {\n- this._value = null;\n+ this._date = null;\nthis._viewValue = null;\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update performance |
530,388 | 31.01.2017 10:10:33 | -19,080 | a2675cd0d078424c84ce483088bf5bb37cd3921f | chore(datepicker) initialise mouse events for click picker | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "</div>\n</div>\n<div class=\"md2-datepicker-clock\" [class.active]=\"!_isCalendarVisible\">\n- <!-- (mousedown)=\"onMouseDownClock($event)\"-->\n+ <!-- (mousedown)=\"_handleMousedown($event)\"-->\n<div class=\"md2-clock-hand\">\n<svg class=\"md2-clock-svg\" width=\"240\" height=\"240\">\n<g transform=\"translate(120,120)\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -104,6 +104,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _panelOpen = false;\nprivate _selected: Date = null;\n+ private mouseMoveListener: any;\n+ private mouseUpListener: any;\n+\n_transformOrigin: string = 'top';\n_panelDoneAnimating: boolean = false;\n@@ -136,8 +139,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.getYears();\nthis.generateClock();\n- // this.mouseMoveListener = (event: MouseEvent) => { this.onMouseMoveClock(event); };\n- // this.mouseUpListener = (event: MouseEvent) => { this.onMouseUpClock(event); };\n+ this.mouseMoveListener = (event: MouseEvent) => { this._handleMousemove(event); };\n+ this.mouseUpListener = (event: MouseEvent) => { this._handleMouseup(event); };\n}\nngAfterContentInit() {\n@@ -235,8 +238,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nreturn isNaN(timestamp) ? fallbackValue : new Date(timestamp);\n}\n- // private mouseMoveListener: any;\n- // private mouseUpListener: any;\nprivate _format: string = this.type === 'date' ?\n'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n@@ -788,30 +789,59 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis.close();\n}\n- // private onMouseDownClock(event: MouseEvent) {\n- // document.addEventListener('mousemove', this.mouseMoveListener);\n- // document.addEventListener('mouseup', this.mouseUpListener);\n-\n+ _handleMousedown(event: MouseEvent) {\n+ console.log('Down');\n+ document.addEventListener('mousemove', this.mouseMoveListener);\n+ document.addEventListener('mouseup', this.mouseUpListener);\n+ // let offset = this.offset(event.currentTarget)\n+ // this._clock.x = offset.left + this._clock.dialRadius;\n+ // this._clock.y = offset.top + this._clock.dialRadius;\n+ // this._clock.dx = event.pageX - this._clock.x;\n+ // this._clock.dy = event.pageY - this._clock.y;\n+ // let z = Math.sqrt(this._clock.dx * this._clock.dx + this._clock.dy * this._clock.dy);\n+ // if (z < this._clock.outerRadius - this._clock.tickRadius || z > this._clock.outerRadius\n+ // + this._clock.tickRadius) { return; }\n+ // event.preventDefault();\n+ // this.setClockHand(this._clock.dx, this._clock.dy);\n+\n+ // // this.onMouseMoveClock = this.onMouseMoveClock.bind(this);\n+ // // this.onMouseUpClock = this.onMouseUpClock.bind(this);\n+ // document.addEventListener('mousemove', this.onMouseMoveClock);\n+ // document.addEventListener('mouseup', this.onMouseUpClock);\n+\n+ /*\n+ var offset = plate.offset(),\n+ isTouch = /^touch/.test(e.type),\n+ x0 = offset.left + dialRadius,\n+ y0 = offset.top + dialRadius,\n+ dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,\n+ dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,\n+ z = Math.sqrt(dx * dx + dy * dy),\n+ moved = false;\n+\n+ // When clicking on minutes view space, check the mouse position\n+ if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius)) {\n+ return;\n+ }\n+ e.preventDefault();\n+ // Set cursor style of body after 200ms\n+ var movingTimer = setTimeout(function(){\n+ $body.addClass('clockpicker-moving');\n+ }, 200);\n- // // let offset = this.offset(event.currentTarget)\n- // // this._clock.x = offset.left + this._clock.dialRadius;\n- // // this._clock.y = offset.top + this._clock.dialRadius;\n- // // this._clock.dx = event.pageX - this._clock.x;\n- // // this._clock.dy = event.pageY - this._clock.y;\n- // // let z = Math.sqrt(this._clock.dx * this._clock.dx + this._clock.dy * this._clock.dy);\n- // // if (z < this._clock.outerRadius - this._clock.tickRadius || z > this._clock.outerRadius\n- // // + this._clock.tickRadius) { return; }\n- // // event.preventDefault();\n- // // this.setClockHand(this._clock.dx, this._clock.dy);\n+ // Place the canvas to top\n+ if (svgSupported) {\n+ plate.append(self.canvas);\n+ }\n- // // // this.onMouseMoveClock = this.onMouseMoveClock.bind(this);\n- // // // this.onMouseUpClock = this.onMouseUpClock.bind(this);\n- // // document.addEventListener('mousemove', this.onMouseMoveClock);\n- // // document.addEventListener('mouseup', this.onMouseUpClock);\n- // }\n+ // Clock\n+ self.setHand(dx, dy, ! space, true);\n+ */\n+ }\n- // onMouseMoveClock(event: MouseEvent) {\n+ _handleMousemove(event: MouseEvent) {\n+ console.log('move');\n// event.preventDefault();\n// event.stopPropagation();\n// let x = event.pageX - this._clock.x,\n@@ -822,12 +852,26 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n// // // Clicking in chrome on windows will trigger a mousemove event\n// // return;\n// // }\n- // }\n- // onMouseUpClock(event: MouseEvent) {\n+ /*\n+ e.preventDefault();\n+ var isTouch = /^touch/.test(e.type),\n+ x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,\n+ y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;\n+ if (! moved && x === dx && y === dy) {\n+ // Clicking in chrome on windows will trigger a mousemove event\n+ return;\n+ }\n+ moved = true;\n+ self.setHand(x, y, false, true);\n+ */\n+ }\n+\n+ _handleMouseup(event: MouseEvent) {\n+ console.log('Up');\n// event.preventDefault();\n- // document.removeEventListener('mousemove', this.mouseMoveListener);\n- // document.removeEventListener('mouseup', this.mouseUpListener);\n+ document.removeEventListener('mousemove', this.mouseMoveListener);\n+ document.removeEventListener('mouseup', this.mouseUpListener);\n// // let space = false;\n// let x = event.pageX - this._clock.x,\n@@ -866,7 +910,38 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n// clearTimeout(movingTimer);\n// $body.removeClass('clockpicker-moving');\n- // }\n+\n+\n+ /*\n+ $doc.off(mouseupEvent);\n+ e.preventDefault();\n+ var isTouch = /^touch/.test(e.type),\n+ x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,\n+ y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;\n+ if ((space || moved) && x === dx && y === dy) {\n+ self.setHand(x, y);\n+ }\n+ if (self.currentView === 'hours') {\n+ self.toggleView('minutes', duration / 2);\n+ } else {\n+ if (options.autoclose) {\n+ self.minutesView.addClass('clockpicker-dial-out');\n+ setTimeout(function(){\n+ self.done();\n+ }, duration / 2);\n+ }\n+ }\n+ plate.prepend(canvas);\n+\n+ // Reset cursor style of body\n+ clearTimeout(movingTimer);\n+ $body.removeClass('clockpicker-moving');\n+\n+ // Unbind mousemove event\n+ $doc.off(mousemoveEvent);\n+\n+ */\n+ }\n/**\n* reser clock hands\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) initialise mouse events for click picker |
530,388 | 31.01.2017 14:19:29 | -19,080 | fa0177793db0d7c9b142b13ff8343ee044527b1e | chore: update tasks and dependencies | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "/dist\n/tmp\n/deploy\n+/screenshots\n# dependencies\n/node_modules\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@angular/platform-browser-dynamic\": \"^2.2.0\",\n\"@angular/platform-server\": \"^2.2.0\",\n\"@angular/router\": \"^3.2.0\",\n- \"@types/glob\": \"^5.0.29\",\n- \"@types/gulp\": \"^3.8.29\",\n- \"@types/hammerjs\": \"^2.0.30\",\n- \"@types/jasmine\": \"^2.2.31\",\n- \"@types/merge2\": \"0.0.28\",\n- \"@types/minimist\": \"^1.1.28\",\n+ \"@types/glob\": \"^5.0.30\",\n+ \"@types/gulp\": \"^3.8.32\",\n+ \"@types/hammerjs\": \"^2.0.34\",\n+ \"@types/jasmine\": \"^2.5.40\",\n+ \"@types/merge2\": \"^0.3.29\",\n+ \"@types/minimist\": \"^1.2.0\",\n\"@types/node\": \"^6.0.34\",\n- \"@types/protractor\": \"^4.0.0\",\n- \"@types/run-sequence\": \"0.0.27\",\n- \"@types/rx\": \"^2.5.33\",\n- \"@types/selenium-webdriver\": \"2.53.36\",\n- \"axe-core\": \"^2.0.7\",\n- \"axe-webdriverjs\": \"^0.4.0\",\n+ \"@types/run-sequence\": \"^0.0.28\",\n+ \"@types/rx\": \"2.5.33\",\n+ \"axe-core\": \"^2.1.7\",\n+ \"axe-webdriverjs\": \"^0.5.0\",\n\"conventional-changelog\": \"^1.1.0\",\n\"conventional-github-releaser\": \"^1.1.3\",\n\"dgeni\": \"^0.4.2\",\n- \"dgeni-packages\": \"^0.16.2\",\n- \"express\": \"^4.14.0\",\n+ \"dgeni-packages\": \"^0.16.5\",\n\"firebase-admin\": \"^4.0.4\",\n\"firebase-tools\": \"^2.2.1\",\n- \"fs-extra\": \"^0.26.5\",\n- \"glob\": \"^6.0.4\",\n+ \"fs-extra\": \"^1.0.0\",\n+ \"glob\": \"^7.1.1\",\n\"gulp\": \"^3.9.1\",\n\"gulp-autoprefixer\": \"^3.1.1\",\n\"gulp-better-rollup\": \"^1.0.2\",\n\"gulp-bump\": \"^2.4.0\",\n\"gulp-clean\": \"^0.3.2\",\n- \"gulp-clean-css\": \"^2.3.0\",\n+ \"gulp-clean-css\": \"^2.3.2\",\n\"gulp-cli\": \"^1.2.2\",\n\"gulp-connect\": \"^5.0.0\",\n\"gulp-conventional-changelog\": \"^1.1.0\",\n\"gulp-htmlmin\": \"^3.0.0\",\n\"gulp-if\": \"^2.0.2\",\n\"gulp-markdown\": \"^1.2.0\",\n- \"gulp-sass\": \"^2.3.2\",\n+ \"gulp-sass\": \"^3.1.0\",\n\"gulp-shell\": \"^0.5.2\",\n- \"gulp-sourcemaps\": \"^1.6.0\",\n+ \"gulp-sourcemaps\": \"^2.4.0\",\n\"gulp-transform\": \"^1.1.0\",\n\"gulp-typescript\": \"^3.1.3\",\n\"hammerjs\": \"^2.0.8\",\n\"highlight.js\": \"^9.9.0\",\n- \"jasmine-core\": \"^2.4.1\",\n- \"karma\": \"^1.1.1\",\n- \"karma-browserstack-launcher\": \"^1.0.1\",\n- \"karma-chrome-launcher\": \"^1.0.1\",\n+ \"jasmine-core\": \"^2.5.2\",\n+ \"karma\": \"^1.3.0\",\n+ \"karma-browserstack-launcher\": \"^1.1.1\",\n+ \"karma-chrome-launcher\": \"^2.0.0\",\n\"karma-firefox-launcher\": \"^1.0.0\",\n- \"karma-jasmine\": \"^1.0.2\",\n- \"karma-sauce-launcher\": \"^1.0.0\",\n+ \"karma-jasmine\": \"^1.1.0\",\n+ \"karma-sauce-launcher\": \"^1.1.0\",\n\"karma-sourcemap-loader\": \"^0.3.7\",\n\"madge\": \"^0.6.0\",\n\"merge2\": \"^1.0.2\",\n\"minimist\": \"^1.2.0\",\n- \"node-sass\": \"^3.4.2\",\n- \"protractor\": \"^4.0.8\",\n+ \"node-sass\": \"^4.3.0\",\n+ \"protractor\": \"^5.0.0\",\n\"resolve-bin\": \"^0.4.0\",\n\"run-sequence\": \"^1.2.2\",\n\"sass\": \"^0.5.0\",\n- \"selenium-webdriver\": \"2.53.3\",\n- \"strip-ansi\": \"^3.0.0\",\n- \"stylelint\": \"^7.7.0\",\n- \"symlink-or-copy\": \"^1.0.1\",\n- \"travis-after-modes\": \"0.0.6-2\",\n- \"ts-node\": \"^0.7.3\",\n+ \"selenium-webdriver\": \"^3.0.1\",\n+ \"stylelint\": \"^7.7.1\",\n+ \"travis-after-modes\": \"0.0.7\",\n+ \"ts-node\": \"^2.0.0\",\n\"tslint\": \"^3.13.0\",\n- \"typedoc\": \"^0.5.1\",\n\"typescript\": \"~2.0.10\",\n- \"uglify-js\": \"^2.7.5\",\n- \"which\": \"^1.2.4\"\n+ \"uglify-js\": \"^2.7.5\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/dgeni/index.js",
"new_path": "tools/dgeni/index.js",
"diff": "@@ -18,12 +18,12 @@ const templateDir = path.resolve(__dirname, './templates');\n// Package definition for material2 api docs. This only *defines* the package- it does not yet\n// actually *run* anything.\n//\n-// A dgeni package is very similar to an Angular 1 module. Modules contain:\n+// A dgeni package is very similar to an AngularJS module. Modules contain:\n// \"services\" (injectables)\n// \"processors\" (injectables that conform to a specific interface)\n// \"templates\": nunjucks templates that can be used to render content\n//\n-// A dgeni package also has a `config` method, similar to an Angular 1 module.\n+// A dgeni package also has a `config` method, similar to an AngularJS module.\n// A config block can inject any services/processors and configure them before\n// docs processing begins.\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/dgeni/templates/componentGroup.template.html",
"new_path": "tools/dgeni/templates/componentGroup.template.html",
"diff": "-<style>\n- table {\n- border-collapse: collapse;\n- margin: 10px;\n- min-width: 300px;\n- }\n-\n- td, th {\n- border: 1px solid black;\n- padding: 4px;\n- }\n-</style>\n-\n{# Defines macros for reusable templates. #}\n{% macro method(method) -%}\n{% include 'method.template.html' %}\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/constants.ts",
"new_path": "tools/gulp/constants.ts",
"diff": "@@ -26,7 +26,7 @@ export const HTML_MINIFIER_OPTIONS = {\nexport const LICENSE_BANNER = `/**\n* @license Md2 v${MATERIAL_VERSION}\n- * Copyright (c) 2016 Promact, Inc. http://code.promactinfo.com/md2/\n+ * Copyright (c) 2017 Promact, Inc. http://code.promactinfo.com/md2/\n* License: MIT\n*/`;\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/task_helpers.ts",
"new_path": "tools/gulp/task_helpers.ts",
"diff": "import * as child_process from 'child_process';\nimport * as fs from 'fs';\nimport * as gulp from 'gulp';\n-import * as gulpTs from 'gulp-typescript';\nimport * as path from 'path';\nimport {NPM_VENDOR_FILES, PROJECT_ROOT, DIST_ROOT, SASS_AUTOPREFIXER_OPTIONS} from './constants';\n@@ -34,36 +33,9 @@ function _globify(maybeGlob: string, suffix = '**/*') {\n}\n-/** Create a TS Build Task, based on the options. */\n-export function tsBuildTask(tsConfigPath: string, tsConfigName = 'tsconfig.json') {\n- let tsConfigDir = tsConfigPath;\n- if (fs.existsSync(path.join(tsConfigDir, tsConfigName))) {\n- // Append tsconfig.json\n- tsConfigPath = path.join(tsConfigDir, tsConfigName);\n- } else {\n- tsConfigDir = path.dirname(tsConfigDir);\n- }\n-\n- return () => {\n- const tsConfig: any = JSON.parse(fs.readFileSync(tsConfigPath, 'utf-8'));\n- const dest: string = path.join(tsConfigDir, tsConfig['compilerOptions']['outDir']);\n-\n- const tsProject = gulpTs.createProject(tsConfigPath, {\n- typescript: require('typescript')\n- });\n-\n- let pipe = tsProject.src()\n- .pipe(gulpSourcemaps.init())\n- .pipe(tsProject());\n- let dts = pipe.dts.pipe(gulp.dest(dest));\n-\n- return gulpMerge([\n- dts,\n- pipe\n- .pipe(gulpSourcemaps.write('.'))\n- .pipe(gulp.dest(dest))\n- ]);\n- };\n+/** Creates a task that runs the TypeScript compiler */\n+export function tsBuildTask(tsConfigPath: string) {\n+ return execNodeTask('typescript', 'tsc', ['-p', tsConfigPath]);\n}\n@@ -219,13 +191,13 @@ export function openFirebaseDatabase() {\n// Credentials need to be for a Service Account, which can be created in the Firebase console.\nfirebaseAdmin.initializeApp({\ncredential: firebaseAdmin.credential.cert({\n- project_id: 'material2-dashboard',\n- client_email: 'firebase-adminsdk-ch1ob@material2-dashboard.iam.gserviceaccount.com',\n+ project_id: 'md2-dashboard',\n+ client_email: 'firebase-adminsdk-ch1ob@md2-dashboard.iam.gserviceaccount.com',\n// In Travis CI the private key will be incorrect because the line-breaks are escaped.\n// The line-breaks need to persist in the service account private key.\n- private_key: (process.env['MATERIAL2_FIREBASE_PRIVATE_KEY'] || '').replace(/\\\\n/g, '\\n')\n+ private_key: (process.env['MD2_FIREBASE_PRIVATE_KEY'] || '').replace(/\\\\n/g, '\\n')\n}),\n- databaseURL: 'https://material2-dashboard.firebaseio.com'\n+ databaseURL: 'https://md2-dashboard.firebaseio.com'\n});\nreturn firebaseAdmin.database();\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/clean.ts",
"new_path": "tools/gulp/tasks/clean.ts",
"diff": "import {task} from 'gulp';\n+import {DIST_ROOT} from '../constants';\nimport {cleanTask} from '../task_helpers';\n-task('clean', cleanTask('dist'));\n+task('clean', cleanTask(DIST_ROOT));\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/components.ts",
"new_path": "tools/gulp/tasks/components.ts",
"diff": "@@ -37,7 +37,7 @@ task(':watch:components', () => {\n/** Builds component typescript only (ESM output). */\n-task(':build:components:ts', tsBuildTask(COMPONENTS_DIR, 'tsconfig-srcs.json'));\n+task(':build:components:ts', tsBuildTask(path.join(COMPONENTS_DIR, 'tsconfig-srcs.json')));\n/** Builds components typescript for tests (CJS output). */\ntask(':build:components:spec', tsBuildTask(COMPONENTS_DIR));\n@@ -75,6 +75,7 @@ task(':build:components:rollup', () => {\n'rxjs/add/observable/fromEvent': 'Rx.Observable',\n'rxjs/add/observable/forkJoin': 'Rx.Observable',\n'rxjs/add/observable/of': 'Rx.Observable',\n+ 'rxjs/add/observable/merge': 'Rx.Observable',\n'rxjs/add/observable/throw': 'Rx.Observable',\n'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',\n'rxjs/add/operator/map': 'Rx.Observable.prototype',\n@@ -84,6 +85,8 @@ task(':build:components:rollup', () => {\n'rxjs/add/operator/finally': 'Rx.Observable.prototype',\n'rxjs/add/operator/catch': 'Rx.Observable.prototype',\n'rxjs/add/operator/first': 'Rx.Observable.prototype',\n+ 'rxjs/add/operator/startWith': 'Rx.Observable.prototype',\n+ 'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',\n'rxjs/Observable': 'Rx'\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/payload.ts",
"new_path": "tools/gulp/tasks/payload.ts",
"diff": "@@ -8,7 +8,7 @@ import {spawnSync} from 'child_process';\n// Those imports lack types.\nconst uglifyJs = require('uglify-js');\n-const BUNDLE_PATH = join(DIST_COMPONENTS_ROOT, 'bundles', 'material.umd.js');\n+const BUNDLE_PATH = join(DIST_COMPONENTS_ROOT, 'bundles', 'md2.umd.js');\n/** Task which runs test against the size of whole library. */\ntask('payload', ['build:release'], () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/release.ts",
"new_path": "tools/gulp/tasks/release.ts",
"diff": "@@ -10,8 +10,9 @@ import {DIST_COMPONENTS_ROOT} from '../constants';\nconst argv = minimist(process.argv.slice(3));\n-\n-task(':build:release:clean-spec', cleanTask('dist/**/*.spec.*'));\n+/** Removes redundant spec files from the release. TypeScript creates definition files for specs. */\n+// TODO(devversion): tsconfig files should share code and don't generate spec files for releases.\n+task(':build:release:clean-spec', cleanTask('dist/**/*(-|.)spec.*'));\ntask('build:release', function(done: () => void) {\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/unit-test.ts",
"new_path": "tools/gulp/tasks/unit-test.ts",
"diff": "@@ -46,7 +46,11 @@ gulp.task('test:single-run', [':test:deps:inline'], (done: () => void) => {\nnew karma.Server({\nconfigFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),\nsingleRun: true\n- }, done).start();\n+ }, (exitCode: number) => {\n+ // Immediately exit the process if Karma reported errors, because due to\n+ // potential still running tunnel-browsers gulp won't exit properly.\n+ exitCode === 0 ? done() : process.exit(exitCode);\n+ }).start();\n});\n/**\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update tasks and dependencies |
530,388 | 31.01.2017 14:26:59 | -19,080 | 43fb39ee59bd4e1417b64e438daff654eec1e56a | chore: update module with updated core | [
{
"change_type": "MODIFY",
"old_path": "src/lib/module.ts",
"new_path": "src/lib/module.ts",
"diff": "@@ -8,7 +8,7 @@ import {\nOverlayModule,\nA11yModule,\nProjectionModule,\n- DefaultStyleCompatibilityModeModule,\n+ CompatibilityModule,\n} from './core/index';\nimport { Md2AccordionModule } from './accordion/index';\n@@ -52,7 +52,7 @@ const MD2_MODULES = [\nA11yModule,\nPlatformModule,\nProjectionModule,\n- DefaultStyleCompatibilityModeModule,\n+ CompatibilityModule,\nObserveContentModule\n];\n@@ -82,7 +82,7 @@ const MD2_MODULES = [\nProjectionModule.forRoot(),\nRtlModule.forRoot(),\nObserveContentModule.forRoot(),\n- DefaultStyleCompatibilityModeModule.forRoot(),\n+ CompatibilityModule.forRoot(),\n],\nexports: MD2_MODULES,\n})\n@@ -94,6 +94,7 @@ export class Md2RootModule { }\nexports: MD2_MODULES,\n})\nexport class Md2Module {\n+ /** @deprecated */\nstatic forRoot(): ModuleWithProviders {\nreturn { ngModule: Md2RootModule };\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update module with updated core |
530,388 | 31.01.2017 14:28:29 | -19,080 | af1eae38211c2a108f27318262414250f69c7de8 | chore(tooltip) removed default style compatibility | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tooltip/tooltip.ts",
"new_path": "src/lib/tooltip/tooltip.ts",
"diff": "@@ -24,8 +24,7 @@ import {\nOverlayRef,\nComponentPortal,\nOverlayConnectionPosition,\n- OriginConnectionPosition,\n- DefaultStyleCompatibilityModeModule\n+ OriginConnectionPosition\n} from '../core';\nimport { Md2TooltipInvalidPositionError } from './tooltip-errors';\nimport { Observable } from 'rxjs/Observable';\n@@ -370,8 +369,8 @@ export class Md2TooltipComponent {\n@NgModule({\n- imports: [OverlayModule, DefaultStyleCompatibilityModeModule],\n- exports: [Md2Tooltip, Md2TooltipComponent, DefaultStyleCompatibilityModeModule],\n+ imports: [OverlayModule],\n+ exports: [Md2Tooltip, Md2TooltipComponent],\ndeclarations: [Md2Tooltip, Md2TooltipComponent],\nentryComponents: [Md2TooltipComponent],\n})\n"
}
] | TypeScript | MIT License | promact/md2 | chore(tooltip) removed default style compatibility |
530,388 | 31.01.2017 14:35:14 | -19,080 | 502fb7f55939646eabac1821380c7055c713a95e | chore(select) update option as module and core changes | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/index.ts",
"new_path": "src/lib/select/index.ts",
"diff": "import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { Md2Select } from './select';\n-import {Md2Option} from './option';\n+import { Md2OptionModule } from './option';\nimport {\n- DefaultStyleCompatibilityModeModule,\n- OVERLAY_PROVIDERS,\n- MdRippleModule,\n+ CompatibilityModule,\nOverlayModule,\n} from '../core';\nexport * from './select';\n-export {Md2Option} from './option';\n+export * from './option';\nexport { fadeInContent, transformPanel, transformPlaceholder } from './select-animations';\n@NgModule({\n- imports: [CommonModule, OverlayModule, MdRippleModule, DefaultStyleCompatibilityModeModule],\n- exports: [Md2Select, Md2Option, DefaultStyleCompatibilityModeModule],\n- declarations: [Md2Select, Md2Option],\n+ imports: [CommonModule, OverlayModule, Md2OptionModule, CompatibilityModule],\n+ exports: [Md2Select, Md2OptionModule, CompatibilityModule],\n+ declarations: [Md2Select],\n})\nexport class Md2SelectModule {\n+ /** @deprecated */\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2SelectModule,\n- providers: [OVERLAY_PROVIDERS]\n+ providers: []\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/select/option.ts",
"new_path": "src/lib/select/option.ts",
"diff": "@@ -4,9 +4,12 @@ import {\nEventEmitter,\nInput,\nOutput,\n+ NgModule,\n+ ModuleWithProviders,\nRenderer,\nViewEncapsulation\n} from '@angular/core';\n+import { CommonModule } from '@angular/common';\nimport { ENTER, SPACE } from '../core/keyboard/keycodes';\nimport { coerceBooleanProperty } from '../core/coercion/boolean-property';\n@@ -16,6 +19,15 @@ import {coerceBooleanProperty} from '../core/coercion/boolean-property';\n*/\nlet _uniqueIdCounter = 0;\n+/** Event object emitted by MdOption when selected. */\n+export class Md2OptionSelectEvent {\n+ constructor(public source: Md2Option, public isUserInput = false) { }\n+}\n+\n+\n+/**\n+ * Single option inside of a `<md2-select>` element.\n+ */\n@Component({\nmoduleId: module.id,\nselector: 'md2-option',\n@@ -40,7 +52,7 @@ export class Md2Option {\n/** Whether the option is disabled. */\nprivate _disabled: boolean = false;\n- private _id: string = `md2-select-option-${_uniqueIdCounter++}`;\n+ private _id: string = `md2-option-${_uniqueIdCounter++}`;\n/** The unique ID of the option. */\nget id() { return this._id; }\n@@ -48,17 +60,13 @@ export class Md2Option {\n/** The form value of the option. */\n@Input() value: any;\n+ /** Whether the option is disabled. */\n@Input()\n- get disabled() {\n- return this._disabled;\n- }\n-\n- set disabled(value: any) {\n- this._disabled = coerceBooleanProperty(value);\n- }\n+ get disabled() { return this._disabled; }\n+ set disabled(value: any) { this._disabled = coerceBooleanProperty(value); }\n/** Event emitted when the option is selected. */\n- @Output() onSelect = new EventEmitter();\n+ @Output() onSelect = new EventEmitter<Md2OptionSelectEvent>();\nconstructor(private _element: ElementRef, private _renderer: Renderer) { }\n@@ -70,7 +78,6 @@ export class Md2Option {\n/**\n* The displayed value of the option. It is necessary to show the selected option in the\n* select's trigger.\n- * TODO(kara): Add input property alternative for node envs.\n*/\nget viewValue(): string {\nreturn this._getHostElement().textContent.trim();\n@@ -79,7 +86,7 @@ export class Md2Option {\n/** Selects the option. */\nselect(): void {\nthis._selected = true;\n- this.onSelect.emit();\n+ this.onSelect.emit(new Md2OptionSelectEvent(this, false));\n}\n/** Deselects the option. */\n@@ -99,7 +106,6 @@ export class Md2Option {\n}\n}\n-\n/**\n* Selects the option while indicating the selection came from the user. Used to\n* determine if the select's view -> model callback should be invoked.\n@@ -107,7 +113,7 @@ export class Md2Option {\n_selectViaInteraction() {\nif (!this.disabled) {\nthis._selected = true;\n- this.onSelect.emit(true);\n+ this.onSelect.emit(new Md2OptionSelectEvent(this, true));\n}\n}\n@@ -121,3 +127,17 @@ export class Md2Option {\n}\n}\n+\n+@NgModule({\n+ imports: [CommonModule],\n+ exports: [Md2Option],\n+ declarations: [Md2Option]\n+})\n+export class Md2OptionModule {\n+ static forRoot(): ModuleWithProviders {\n+ return {\n+ ngModule: Md2OptionModule,\n+ providers: []\n+ };\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.html",
"new_path": "src/lib/select/select.html",
"diff": "backdropClass=\"cdk-overlay-transparent-backdrop\" [positions]=\"_positions\" [minWidth]=\"_triggerWidth\"\n[offsetY]=\"_offsetY\" [offsetX]=\"_offsetX\" (attach)=\"_setScrollTop()\">\n<div class=\"md2-select-panel\" [@transformPanel]=\"'showing'\" (@transformPanel.done)=\"_onPanelDone()\"\n- (keydown)=\"_keyManager.onKeydown($event)\" [style.transformOrigin]=\"_transformOrigin\" [attr.multiple]=\"multiple\">\n- <div class=\"md2-select-content\" [@fadeInContent]=\"'showing'\">\n+ (keydown)=\"_keyManager.onKeydown($event)\" [style.transformOrigin]=\"_transformOrigin\" [attr.multiple]=\"multiple\"\n+ [class.md2-select-panel-done-animating]=\"_panelDoneAnimating\">\n+ <div class=\"md2-select-content\" [@fadeInContent]=\"'showing'\" (@fadeInContent.done)=\"_onFadeInDone()\">\n<ng-content></ng-content>\n</div>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.ts",
"new_path": "src/lib/select/select.ts",
"diff": "@@ -10,12 +10,13 @@ import {\nOutput,\nQueryList,\nRenderer,\n+ Self,\nViewEncapsulation,\nViewChild,\n} from '@angular/core';\n-import {Md2Option} from './option';\n+import { Md2Option, Md2OptionSelectEvent } from './option';\nimport { ENTER, SPACE } from '../core/keyboard/keycodes';\n-import {ListKeyManager} from '../core/a11y/list-key-manager';\n+import { FocusKeyManager } from '../core/a11y/focus-key-manager';\nimport { Dir } from '../core/rtl/dir';\nimport { Subscription } from 'rxjs/Subscription';\nimport { transformPlaceholder, transformPanel, fadeInContent } from './select-animations';\n@@ -64,10 +65,9 @@ export const SELECT_PANEL_PADDING_Y = 16;\n*/\nexport const SELECT_PANEL_VIEWPORT_PADDING = 8;\n-/** Change event object emitted by Md2Select. */\n+/** Change event object that is emitted when the select value has changed. */\nexport class Md2SelectChange {\n- source: Md2Select;\n- value: any;\n+ constructor(public source: Md2Select, public value: any) { }\n}\n@Component({\n@@ -142,7 +142,7 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n_selectedValueWidth: number;\n/** Manages keyboard events for options in the panel. */\n- _keyManager: ListKeyManager;\n+ _keyManager: FocusKeyManager;\n/** View -> model callback called when value changes */\n_onChange = (value: any) => { };\n@@ -156,6 +156,9 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n/** The value of the select panel's transform-origin property. */\n_transformOrigin: string = 'top';\n+ /** Whether the panel's animation is done. */\n+ _panelDoneAnimating: boolean = false;\n+\n/**\n* The x-offset of the overlay panel in relation to the trigger's top start corner.\n* This must be adjusted to align the selected option text over the trigger text when\n@@ -191,54 +194,54 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n},\n];\n+ /** Trigger that opens the select. */\n@ViewChild('trigger') trigger: ElementRef;\n+\n+ /** Overlay pane containing the options. */\n@ViewChild(ConnectedOverlayDirective) overlayDir: ConnectedOverlayDirective;\n- @ContentChildren(Md2Option) options: QueryList<Md2Option>;\n- @Output() change: EventEmitter<Md2SelectChange> = new EventEmitter<Md2SelectChange>();\n+ /** All of the defined select options. */\n+ @ContentChildren(Md2Option) options: QueryList<Md2Option>;\n+ /** Placeholder to be shown if no value has been selected. */\n@Input()\n- get placeholder() {\n- return this._placeholder;\n- }\n-\n+ get placeholder() { return this._placeholder; }\nset placeholder(value: string) {\nthis._placeholder = value;\n- }\n- @Input()\n- get disabled() {\n- return this._disabled;\n+ // Must wait to record the trigger width to ensure placeholder width is included.\n+ Promise.resolve(null).then(() => this._triggerWidth = this._getWidth());\n}\n+ /** Whether the component is disabled. */\n+ @Input()\n+ get disabled() { return this._disabled; }\nset disabled(value: any) {\nthis._disabled = coerceBooleanProperty(value);\n}\n+ /** Whether the component is multiple. */\n@Input()\n- get multiple() {\n- return this._multiple;\n- }\n-\n- set multiple(value: any) {\n- this._multiple = coerceBooleanProperty(value);\n- }\n+ get multiple() { return this._multiple; }\n+ set multiple(value: any) { this._multiple = coerceBooleanProperty(value); }\n+ /** Whether the component is required. */\n@Input()\n- get required() {\n- return this._required;\n- }\n-\n- set required(value: any) {\n- this._required = coerceBooleanProperty(value);\n- }\n+ get required() { return this._required; }\n+ set required(value: any) { this._required = coerceBooleanProperty(value); }\n+ /** Event emitted when the select has been opened. */\n@Output() onOpen: EventEmitter<void> = new EventEmitter<void>();\n+\n+ /** Event emitted when the select has been closed. */\n@Output() onClose: EventEmitter<void> = new EventEmitter<void>();\n+ /** Event emitted when the selected value has been changed by the user. */\n+ @Output() change: EventEmitter<Md2SelectChange> = new EventEmitter<Md2SelectChange>();\n+\nconstructor(private _element: ElementRef, private _renderer: Renderer,\nprivate _viewportRuler: ViewportRuler, @Optional() private _dir: Dir,\n- @Optional() public _control: NgControl) {\n+ @Self() @Optional() public _control: NgControl) {\nif (this._control) {\nthis._control.valueAccessor = this;\n}\n@@ -289,22 +292,11 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nthis._focusHost();\n}\n- /** Dispatch change event with current select and value. */\n- _emitChangeEvent(): void {\n- let event = new Md2SelectChange();\n- event.source = this;\n- if (this.multiple) {\n- event.value = this._selected.map(option => option.value);\n- } else {\n- event.value = this._selected[0].value;\n- }\n- this._onChange(event.value);\n- this.change.emit(event);\n- }\n-\n/**\n* Sets the select's value. Part of the ControlValueAccessor interface\n* required to integrate with Angular's core forms API.\n+ *\n+ * @param value New value to be written to the model.\n*/\nwriteValue(value: any): void {\nif (!this.options) {\n@@ -323,6 +315,8 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n* Saves a callback function to be invoked when the select's value\n* changes from user input. Part of the ControlValueAccessor interface\n* required to integrate with Angular's core forms API.\n+ *\n+ * @param fn Callback to be triggered when the value changes.\n*/\nregisterOnChange(fn: (value: any) => void): void {\nthis._onChange = fn;\n@@ -332,6 +326,8 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n* Saves a callback function to be invoked when the select is blurred\n* by the user. Part of the ControlValueAccessor interface required\n* to integrate with Angular's core forms API.\n+ *\n+ * @param fn Callback to be triggered when the component has been touched.\n*/\nregisterOnTouched(fn: () => {}): void {\nthis._onTouched = fn;\n@@ -340,6 +336,8 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n/**\n* Disables the select. Part of the ControlValueAccessor interface required\n* to integrate with Angular's core forms API.\n+ *\n+ * @param isDisabled Sets whether the component is disabled.\n*/\nsetDisabledState(isDisabled: boolean): void {\nthis.disabled = isDisabled;\n@@ -374,8 +372,8 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n}\n/**\n- * When the panel is finished animating, emits an event and focuses\n- * an option if the panel is open.\n+ * When the panel element is finished transforming in (though not fading in), it\n+ * emits an event and focuses an option if the panel is open.\n*/\n_onPanelDone(): void {\nif (this.panelOpen) {\n@@ -386,6 +384,14 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n}\n}\n+ /**\n+ * When the panel content is done fading in, the _panelDoneAnimating property is\n+ * set so the proper class can be added to the panel.\n+ */\n+ _onFadeInDone(): void {\n+ this._panelDoneAnimating = this.panelOpen;\n+ }\n+\n/**\n* Calls the touched callback only if the panel is closed. Otherwise, the trigger will\n* \"blur\" to the panel when it opens, causing a false positive.\n@@ -456,7 +462,7 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n/** Sets up a key manager to listen to keyboard events on the overlay panel. */\nprivate _initKeyManager() {\n- this._keyManager = new ListKeyManager(this.options);\n+ this._keyManager = new FocusKeyManager(this.options);\nthis._tabSubscription = this._keyManager.tabOut.subscribe(() => {\nthis.close();\n});\n@@ -472,7 +478,7 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n/** Listens to selection events on each option. */\nprivate _listenToOptions(): void {\nthis.options.forEach((option: Md2Option) => {\n- const sub = option.onSelect.subscribe((isUserInput: boolean) => {\n+ const sub = option.onSelect.subscribe((event: Md2OptionSelectEvent) => {\nif (this.multiple) {\nlet ind = this._selected.indexOf(option);\nif (ind < 0) {\n@@ -490,7 +496,7 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n}\n}\n- if (isUserInput) {\n+ if (event.isUserInput) {\nthis._emitChangeEvent();\n}\n@@ -508,9 +514,21 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nthis._subscriptions = [];\n}\n+ /** Emits an event when the user selects an option. */\n+ _emitChangeEvent(): void {\n+ let value: any;\n+ if (this.multiple) {\n+ value = this._selected.map(option => option.value);\n+ } else {\n+ value = this._selected[0].value;\n+ }\n+ this._onChange(value);\n+ this.change.emit(new Md2SelectChange(this, value));\n+ }\n+\n/** Records option IDs to pass to the aria-owns property. */\nprivate _setOptionIds() {\n- this._optionIds = this.options.map(option => option.id).join(' ');\n+ this._optionIds = this.options.map((option: Md2Option) => option.id).join(' ');\n}\n/** Deselect each option that doesn't match the current selection. */\n@@ -542,9 +560,9 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\n*/\nprivate _focusCorrectOption(): void {\nif (this.selected.length) {\n- this._keyManager.setFocus(this._getOptionIndex(this.selected[0]));\n+ this._keyManager.setActiveItem(this._getOptionIndex(this.selected[0]));\n} else {\n- this._keyManager.focusFirstItem();\n+ this._keyManager.setFirstItemActive();\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(select) update option as module and core changes |
530,388 | 31.01.2017 14:48:58 | -19,080 | c15c11d25c9079da634db268a6c2271eaebb28f3 | chore(core) removed selection module | [
{
"change_type": "MODIFY",
"old_path": "src/lib/core/core.ts",
"new_path": "src/lib/core/core.ts",
"diff": "@@ -111,9 +111,6 @@ export * from './compatibility/compatibility';\n// Animation\nexport * from './animation/animation';\n-// Selection\n-export * from './selection/index';\n-\n// Coercion\nexport {coerceBooleanProperty} from './coercion/boolean-property';\nexport {coerceNumberProperty} from './coercion/number-property';\n"
}
] | TypeScript | MIT License | promact/md2 | chore(core) removed selection module |
530,388 | 01.02.2017 17:59:45 | -19,080 | 866dd215f435727943c13ea4037c0ea6964e8cb1 | chore(datepicker) update overlay | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -300,7 +300,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n.md2-calendar-dates {\n- margin: 0 20px;\n+ margin: 0 auto;\nth {\nwidth: 35px;\n@@ -464,7 +464,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\n}\n}\n-@media (min-width: 600px) {\n+@media (min-width: 480px) {\n.md2-datepicker-panel {\ndisplay: flex;\nwidth: 450px;\n@@ -519,8 +519,8 @@ md2-datepicker.md2-datepicker-disabled:focus {\nopacity: 0;\n}\n-.cdk-overlay-transparent-backdrop {\n- background: none;\n+.cdk-overlay-dark-backdrop {\n+ background: rgba(black, 0.6);\n}\n.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update overlay |
530,388 | 02.02.2017 14:22:26 | -19,080 | dc633a27e35876b0ccbb9d5dfb662557f285f3bb | chore(datepicker) removed readonly property | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/README.md",
"new_path": "src/lib/datepicker/README.md",
"diff": "@@ -7,7 +7,6 @@ Datepicker allow the user to select date and time.\n| Name | Type | Description |\n| --- | --- | --- |\n| `type` | `'date' | 'time' | 'datetime'` | The type of the datepicker |\n-| `readonly` | `boolean` | Whether or not the datepicker is readonly |\n| `required` | `boolean` | Whether or not the datepicker is required |\n| `disabled` | `boolean` | Whether or not the datepicker is disabled |\n| `name` | `number` | Datepicker name. |\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -242,7 +242,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _format: string = this.type === 'date' ?\n'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY';\n- private _readonly: boolean = false;\nprivate _required: boolean = false;\nprivate _disabled: boolean = false;\nprivate _isInitialized: boolean = false;\n@@ -303,10 +302,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\n}\n- @Input()\n- get readonly(): boolean { return this._readonly; }\n- set readonly(value) { this._readonly = coerceBooleanProperty(value); }\n-\n@Input()\nget required(): boolean { return this._required; }\nset required(value) { this._required = coerceBooleanProperty(value); }\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) removed readonly property |
530,388 | 02.02.2017 14:26:50 | -19,080 | 2eea10e696996a8aeeeaca791a80fd4bbbc9fc7e | chore(datepicker) update change and output events | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -43,8 +43,7 @@ import {\n/** Change event object emitted by Md2Select. */\nexport class Md2DateChange {\n- source: Md2Datepicker;\n- date: Date;\n+ constructor(public source: Md2Datepicker, public date: Date) { }\n}\nexport interface IDay {\n@@ -125,9 +124,15 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n},\n];\n+ /** Event emitted when the select has been opened. */\n@Output() onOpen: EventEmitter<void> = new EventEmitter<void>();\n+\n+ /** Event emitted when the select has been closed. */\n@Output() onClose: EventEmitter<void> = new EventEmitter<void>();\n+ /** Event emitted when the selected date has been changed by the user. */\n+ @Output() change: EventEmitter<Md2DateChange> = new EventEmitter<Md2DateChange>();\n+\nconstructor(private _element: ElementRef, private _renderer: Renderer,\nprivate _dateUtil: Md2DateUtil, private _locale: DateLocale,\n@Self() @Optional() public _control: NgControl) {\n@@ -163,23 +168,23 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\n}\nthis._viewValue = this._formatDate(this._date);\n- let date = '';\n- if (this.type !== 'time') {\n- date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n- '-' + this._date.getDate();\n- }\n- if (this.type === 'datetime') {\n- date += ' ';\n- }\n- if (this.type !== 'date') {\n- date += this._date.getHours() + ':' + this._date.getMinutes();\n- }\n- if (this._isInitialized) {\n- if (this._control) {\n- this._onChange(date);\n- }\n- this.change.emit(date);\n- }\n+ //let date = '';\n+ //if (this.type !== 'time') {\n+ // date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n+ // '-' + this._date.getDate();\n+ //}\n+ //if (this.type === 'datetime') {\n+ // date += ' ';\n+ //}\n+ //if (this.type !== 'date') {\n+ // date += this._date.getHours() + ':' + this._date.getMinutes();\n+ //}\n+ //if (this._isInitialized) {\n+ // if (this._control) {\n+ // this._onChange(date);\n+ // }\n+ // this.change.emit(date);\n+ //}\n}\n}\n@@ -209,6 +214,10 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n// this._placeholderState = '';\n//}\nthis._focusHost();\n+\n+ this._isYearsVisible = false;\n+ this._isCalendarVisible = this.type !== 'time' ? true : false;\n+ this._isHoursVisible = true;\n}\n_onPanelDone(): void {\n@@ -283,8 +292,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _min: Date = null;\nprivate _max: Date = null;\n- @Output() change: EventEmitter<any> = new EventEmitter<any>();\n-\n@Input() type: 'date' | 'time' | 'datetime' = 'date';\n@Input() name: string = '';\n@Input() id: string = 'md2-datepicker-' + (++nextId);\n@@ -479,10 +486,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nif (!this.panelOpen) {\nthis._onTouched();\n}\n- //this._isYearsVisible = false;\n- //this._isCalendarVisible = this.type !== 'time' ? true : false;\n- //this._isHoursVisible = true;\n- //this._onTouched();\n}\n@@ -570,6 +573,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._resetClock();\n} else {\nthis.date = this.displayDate;\n+ this._emitChangeEvent();\nthis._onBlur();\nthis.close();\n}\n@@ -601,6 +605,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate setDate(date: Date) {\nif (this.type === 'date') {\nthis.date = date;\n+ this._emitChangeEvent();\nthis._onBlur();\nthis.close();\n} else {\n@@ -780,6 +785,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\ndate.getDate(), date.getHours(), minute);\nthis.selected = this.displayDate;\nthis.date = this.displayDate;\n+ this._emitChangeEvent();\nthis._onBlur();\nthis.close();\n}\n@@ -1056,12 +1062,10 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n};\n}\n- private _emitChangeEvent(): void {\n- let event = new Md2DateChange();\n- event.source = this;\n- event.date = this._date;\n- this._onChange(event.date);\n- this.change.emit(event);\n+ /** Emits an event when the user selects a date. */\n+ _emitChangeEvent(): void {\n+ this._onChange(this.date);\n+ this.change.emit(new Md2DateChange(this, this.date));\n}\nwriteValue(value: any): void {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update change and output events |
530,388 | 02.02.2017 14:31:58 | -19,080 | 468460c05fba69b4563815948aeef30fd6b68224 | fix(datepicker) readonly issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -531,7 +531,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n* Display Datepicker\n*/\n_showDatepicker() {\n- if (this.disabled || this.readonly) { return; }\n+ if (this.disabled) { return; }\nthis.selected = this.date || new Date(1, 0, 1);\nthis.displayDate = this.date || this.today;\nthis.generateCalendar();\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) readonly issue |
530,388 | 02.02.2017 14:55:04 | -19,080 | 67276fb698318617234a1294ac433f37918774f5 | chore(datepicker) added 'openOnFocus' and 'isOpen' APIs to open a calendar | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/README.md",
"new_path": "src/lib/datepicker/README.md",
"diff": "@@ -16,6 +16,8 @@ Datepicker allow the user to select date and time.\n| `placeholder` | `number` | Datepicker placeholder label |\n| `format` | `number` | The date format of datepicker |\n| `tabindex` | `number` | The tabIndex of the datepicker. |\n+| `openOnFocus` | `boolean` | Opend Calendar Whether or not the datepicker is openOnFocus. |\n+| `isOpen` | `number` | Opend Calendar Whether or not the datepicker is isOpen. |\n### Events\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -88,6 +88,7 @@ let nextId = 0;\n'[attr.aria-disabled]': 'disabled.toString()',\n'[attr.aria-invalid]': '_control?.invalid || \"false\"',\n'(keydown)': '_handleKeydown($event)',\n+ '(focus)': '_onFocus()',\n'(blur)': '_onBlur()'\n},\nanimations: [\n@@ -102,6 +103,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nprivate _date: Date = null;\nprivate _panelOpen = false;\nprivate _selected: Date = null;\n+ private _openOnFocus: boolean = false;\nprivate mouseMoveListener: any;\nprivate mouseUpListener: any;\n@@ -192,6 +194,17 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nget selected() { return this._selected; }\nset selected(value: Date) { this._selected = value; }\n+ @Input()\n+ get openOnFocus(): boolean { return this._openOnFocus; }\n+ set openOnFocus(value: boolean) { this._openOnFocus = coerceBooleanProperty(value); }\n+\n+ @Input()\n+ set isOpen(value: boolean) {\n+ if (value && !this.panelOpen) {\n+ this.open();\n+ }\n+ }\n+\nget panelOpen(): boolean {\nreturn this._panelOpen;\n}\n@@ -209,7 +222,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n/** Closes the overlay panel and focuses the host element. */\nclose(): void {\n+ setTimeout(()=>{\nthis._panelOpen = false;\n+ }, 10)\n//if (!this._date) {\n// this._placeholderState = '';\n//}\n@@ -482,6 +497,12 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n}\n}\n+ _onFocus() {\n+ if (!this.panelOpen && this.openOnFocus) {\n+ this.open();\n+ }\n+ }\n+\n_onBlur() {\nif (!this.panelOpen) {\nthis._onTouched();\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) added 'openOnFocus' and 'isOpen' APIs to open a calendar #72 |
530,388 | 07.02.2017 11:16:58 | -19,080 | eb3ca2dcc14627689bdd4b96aa57729dc782b574 | chore(tooltip) added compatibility module and update performance | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tooltip/tooltip.scss",
"new_path": "src/lib/tooltip/tooltip.scss",
"diff": "$md2-tooltip-target-height: 22px;\n+$md2-tooltip-max-width: 250px;\n$md2-tooltip-font-size: 10px;\n$md2-tooltip-margin: 14px;\n$md2-tooltip-horizontal-padding: 8px;\n$md2-tooltip-vertical-padding: ($md2-tooltip-target-height - $md2-tooltip-font-size) / 2;\n-:host {\n+md2-tooltip {\npointer-events: none;\n}\n@@ -14,8 +15,7 @@ $md2-tooltip-vertical-padding: ($md2-tooltip-target-height - $md2-tooltip-font-s\nborder-radius: 2px;\nfont-size: $md2-tooltip-font-size;\nmargin: $md2-tooltip-margin;\n- /*height: $md2-tooltip-target-height;\n- line-height: $md2-tooltip-target-height;*/\n+ max-width: $md2-tooltip-max-width;\nbackground: rgba(97, 97, 97, 0.9);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/tooltip/tooltip.ts",
"new_path": "src/lib/tooltip/tooltip.ts",
"diff": "@@ -15,7 +15,8 @@ import {\nNgZone,\nOptional,\nOnDestroy,\n- ViewEncapsulation\n+ ViewEncapsulation,\n+ ChangeDetectorRef\n} from '@angular/core';\nimport {\nOverlay,\n@@ -24,13 +25,13 @@ import {\nOverlayRef,\nComponentPortal,\nOverlayConnectionPosition,\n- OriginConnectionPosition\n+ OriginConnectionPosition,\n+ CompatibilityModule,\n} from '../core';\nimport { Md2TooltipInvalidPositionError } from './tooltip-errors';\nimport { Observable } from 'rxjs/Observable';\nimport { Subject } from 'rxjs/Subject';\nimport { Dir } from '../core/rtl/dir';\n-import { OVERLAY_PROVIDERS } from '../core/overlay/overlay';\nimport 'rxjs/add/operator/first';\nexport type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';\n@@ -278,7 +279,7 @@ export class Md2TooltipComponent {\n/** Subject for notifying that the tooltip has been hidden from the view */\nprivate _onHide: Subject<any> = new Subject();\n- constructor( @Optional() private _dir: Dir) { }\n+ constructor( @Optional() private _dir: Dir, private _changeDetectorRef: ChangeDetectorRef) { }\n/**\n* Shows the tooltip with an animation originating from the provided origin\n@@ -301,6 +302,10 @@ export class Md2TooltipComponent {\n// If this was set to true immediately, then a body click that triggers show() would\n// trigger interaction and close the tooltip right after it was displayed.\nthis._closeOnInteraction = false;\n+\n+ // Mark for check so if any parent component has set the\n+ // ChangeDetectionStrategy to OnPush it will be checked anyways\n+ this._changeDetectorRef.markForCheck();\nsetTimeout(() => { this._closeOnInteraction = true; }, 0);\n}, delay);\n}\n@@ -318,6 +323,10 @@ export class Md2TooltipComponent {\nthis._hideTimeoutId = setTimeout(() => {\nthis._visibility = 'hidden';\nthis._closeOnInteraction = false;\n+\n+ // Mark for check so if any parent component has set the\n+ // ChangeDetectionStrategy to OnPush it will be checked anyways\n+ this._changeDetectorRef.markForCheck();\n}, delay);\n}\n@@ -369,16 +378,17 @@ export class Md2TooltipComponent {\n@NgModule({\n- imports: [OverlayModule],\n- exports: [Md2Tooltip, Md2TooltipComponent],\n+ imports: [OverlayModule, CompatibilityModule],\n+ exports: [Md2Tooltip, Md2TooltipComponent, CompatibilityModule],\ndeclarations: [Md2Tooltip, Md2TooltipComponent],\nentryComponents: [Md2TooltipComponent],\n})\nexport class Md2TooltipModule {\n+ /** @deprecated */\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2TooltipModule,\n- providers: [OVERLAY_PROVIDERS]\n+ providers: []\n};\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(tooltip) added compatibility module and update performance |
530,396 | 08.02.2017 13:53:01 | -19,080 | cca709f180b97e4365ead713493c07ddd21926a8 | fix(colorpicker) Changes in hsla and rgba color format | [
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/README.md",
"new_path": "src/lib/colorpicker/README.md",
"diff": "@@ -7,6 +7,7 @@ Colorpicker allow the user to select color.\n| Name | Type | Description |\n| --- | --- | --- |\n| `disabled` | `boolean` | Whether or not the colorpicker is disabled |\n+| `format` | `string` | Color format:'hex', 'rgb', 'hsl'.Default :hex |\n| `id` | `number` | The unique ID of this colorpicker. |\n| `tabindex` | `number` | The tabIndex of the colorpicker. |\n@@ -21,3 +22,9 @@ A colorpicker would have the following markup.\n```html\n<md2-colorpicker [(ngModel)]=\"color\"></md2-colorpicker>\n```\n+```html\n+<md2-colorpicker [(ngModel)]=\"color\" format=\"hsla\"></md2-colorpicker>\n+```\n+```html\n+<md2-colorpicker [(ngModel)]=\"color\" [disabled]=\"true\"></md2-colorpicker>\n+```\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/calculateColor.ts",
"new_path": "src/lib/colorpicker/calculateColor.ts",
"diff": "@@ -178,7 +178,7 @@ export class ColorpickerService {\noutputFormat(hsva: Hsva, outputFormat: string) {\nif (hsva.a < 1) {\nswitch (outputFormat) {\n- case 'hsla':\n+ case 'hsl':\nlet hsla = this.hsva2hsla(hsva);\nlet hslaText = new Hsla(Math.round((hsla.h) * 360), Math.round(hsla.s * 100),\nMath.round(hsla.l * 100), Math.round(hsla.a * 100) / 100\n@@ -192,12 +192,12 @@ export class ColorpickerService {\n}\n} else {\nswitch (outputFormat) {\n- case 'hsla':\n+ case 'hsl':\nlet hsla = this.hsva2hsla(hsva);\nlet hslaText = new Hsla(Math.round((hsla.h) * 360), Math.round(hsla.s * 100),\nMath.round(hsla.l * 100), Math.round(hsla.a * 100) / 100);\nreturn 'hsl(' + hslaText.h + ',' + hslaText.s + '%,' + hslaText.l + '%)';\n- case 'rgba':\n+ case 'rgb':\nlet rgba = this.denormalizeRGBA(this.hsvaToRgba(hsva));\nreturn 'rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')';\ndefault:\n@@ -208,10 +208,7 @@ export class ColorpickerService {\nhexText(rgba: Rgba) {\nlet mainText = ((1 << 24) | (rgba.r << 16) | (rgba.g << 8) | rgba.b).toString(16);\nlet hexText = '#' + mainText.substr(1);\n- if (hexText[1] === hexText[2] && hexText[3] === hexText[4] && hexText[5] === hexText[6]) {\n- hexText = '#' + hexText[1] + hexText[3] + hexText[5];\n- }\n- return hexText.toUpperCase();\n+ return hexText.toLowerCase();\n}\ndenormalizeRGBA(rgba: Rgba) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/colorpicker.scss",
"new_path": "src/lib/colorpicker/colorpicker.scss",
"diff": "@@ -3,7 +3,7 @@ $black: black;\nmd2-colorpicker {\nposition: relative;\ndisplay: block;\n- max-width: 200px;\n+ max-width: 215px;\noutline: none;\nbackface-visibility: hidden;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/colorpicker.ts",
"new_path": "src/lib/colorpicker/colorpicker.ts",
"diff": "@@ -224,9 +224,9 @@ export class Md2Colorpicker implements OnInit, ControlValueAccessor {\n}\nthis.sliderDim = new SliderDimension(150, 230, 130, 150);\nthis.slider = new SliderPosition(0, 0, 0, 0);\n- if (this.cFormat === 'rgba') {\n+ if (this.cFormat === 'rgb') {\nthis.format = 1;\n- } else if (this.cFormat === 'hsla') {\n+ } else if (this.cFormat === 'hsl') {\nthis.format = 2;\n} else {\nthis.format = 0;\n"
}
] | TypeScript | MIT License | promact/md2 | fix(colorpicker) Changes in hsla and rgba color format |
530,388 | 08.02.2017 15:29:34 | -19,080 | 61db2763e28db2583f79ec6ab39fc2fd36bb5f64 | chore(datepicker) update overlay service with dark backdrop | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -500,6 +500,12 @@ md2-datepicker.md2-datepicker-disabled:focus {\nz-index: 1000;\n}\n+.cdk-global-overlay-wrapper {\n+ display: flex;\n+ position: absolute;\n+ z-index: 1000;\n+}\n+\n.cdk-overlay-pane {\nposition: absolute;\npointer-events: auto;\n@@ -519,10 +525,10 @@ md2-datepicker.md2-datepicker-disabled:focus {\nopacity: 0;\n}\n-.cdk-overlay-dark-backdrop {\n- background: rgba(black, 0.6);\n-}\n-\n.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\nopacity: 0.48;\n}\n+\n+.cdk-overlay-dark-backdrop {\n+ background: rgba(black, 0.6);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -4,11 +4,14 @@ import {\nElementRef,\nHostListener,\nInput,\n+ OnDestroy,\nOutput,\nOptional,\nEventEmitter,\nRenderer,\nSelf,\n+ ViewChildren,\n+ QueryList,\nViewEncapsulation,\nNgModule,\nModuleWithProviders\n@@ -20,11 +23,6 @@ import {\nimport { CommonModule } from '@angular/common';\nimport { Md2DateUtil } from './dateUtil';\nimport { DateLocale } from './date-locale';\n-import {\n- OverlayModule,\n-} from '../core';\n-import { transformPlaceholder, transformPanel, fadeInContent } from '../select/select-animations';\n-\nimport {\ncoerceBooleanProperty,\nENTER,\n@@ -38,8 +36,17 @@ import {\nLEFT_ARROW,\nRIGHT_ARROW,\nUP_ARROW,\n- DOWN_ARROW\n-} from '../core/core';\n+ DOWN_ARROW,\n+ Overlay,\n+ OverlayState,\n+ OverlayRef,\n+ OverlayModule,\n+ Portal,\n+ TemplatePortalDirective,\n+ PortalModule\n+} from '../core';\n+import { transformPlaceholder, transformPanel, fadeInContent } from '../select/select-animations';\n+import { Subscription } from 'rxjs/Subscription';\n/** Change event object emitted by Md2Select. */\nexport class Md2DateChange {\n@@ -98,7 +105,10 @@ let nextId = 0;\n],\nencapsulation: ViewEncapsulation.None\n})\n-export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n+export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueAccessor {\n+\n+ private _overlayRef: OverlayRef;\n+ private _backdropSubscription: Subscription;\nprivate _date: Date = null;\nprivate _panelOpen = false;\n@@ -126,6 +136,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n},\n];\n+ @ViewChildren(TemplatePortalDirective) templatePortals: QueryList<Portal<any>>;\n+\n/** Event emitted when the select has been opened. */\n@Output() onOpen: EventEmitter<void> = new EventEmitter<void>();\n@@ -135,7 +147,7 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n/** Event emitted when the selected date has been changed by the user. */\n@Output() change: EventEmitter<Md2DateChange> = new EventEmitter<Md2DateChange>();\n- constructor(private _element: ElementRef, private _renderer: Renderer,\n+ constructor(private _element: ElementRef, private overlay: Overlay, private _renderer: Renderer,\nprivate _dateUtil: Md2DateUtil, private _locale: DateLocale,\n@Self() @Optional() public _control: NgControl) {\nif (this._control) {\n@@ -155,6 +167,8 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._isCalendarVisible = this.type !== 'time' ? true : false;\n}\n+ ngOnDestroy() { this.destroyPanel(); }\n+\n@Input()\nget date() { return this._date; }\nset date(value: Date) {\n@@ -216,6 +230,9 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n/** Opens the overlay panel. */\nopen(): void {\nif (this.disabled) { return; }\n+ this._createOverlay();\n+ this._overlayRef.attach(this.templatePortals.first);\n+ this._subscribeToBackdrop();\nthis._panelOpen = true;\nthis._showDatepicker();\n}\n@@ -228,6 +245,10 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n//if (!this._date) {\n// this._placeholderState = '';\n//}\n+ if (this._overlayRef) {\n+ this._overlayRef.detach();\n+ this._backdropSubscription.unsubscribe();\n+ }\nthis._focusHost();\nthis._isYearsVisible = false;\n@@ -235,6 +256,16 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nthis._isHoursVisible = true;\n}\n+ /** Removes the panel from the DOM. */\n+ destroyPanel(): void {\n+ if (this._overlayRef) {\n+ this._overlayRef.dispose();\n+ this._overlayRef = null;\n+\n+ this._cleanUpSubscriptions();\n+ }\n+ }\n+\n_onPanelDone(): void {\nif (this.panelOpen) {\nthis._focusPanel();\n@@ -262,7 +293,6 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\nreturn isNaN(timestamp) ? fallbackValue : new Date(timestamp);\n}\n-\nprivate _format: string = this.type === 'date' ?\n'DD/MM/YYYY' : this.type === 'time' ? 'HH:mm' : this.type === 'datetime' ?\n'DD/MM/YYYY HH:mm' : 'DD/MM/YYYY';\n@@ -1234,12 +1264,42 @@ export class Md2Datepicker implements AfterContentInit, ControlValueAccessor {\n// return `50% ${originY}px 0px`;\n//}\n+ private _subscribeToBackdrop(): void {\n+ this._backdropSubscription = this._overlayRef.backdropClick().subscribe(() => {\n+ this.close();\n+ });\n+ }\n+\n+ /**\n+ * This method creates the overlay from the provided panel's template and saves its\n+ * OverlayRef so that it can be attached to the DOM when open is called.\n+ */\n+ private _createOverlay(): void {\n+ if (!this._overlayRef) {\n+ let config = new OverlayState();\n+ config.positionStrategy = this.overlay.position()\n+ .global()\n+ .centerHorizontally()\n+ .centerVertically();\n+ config.hasBackdrop = true;\n+ config.backdropClass = 'cdk-overlay-dark-backdrop';\n+\n+ this._overlayRef = this.overlay.create(config);\n+ }\n+ }\n+\n+ private _cleanUpSubscriptions(): void {\n+ if (this._backdropSubscription) {\n+ this._backdropSubscription.unsubscribe();\n+ }\n+ }\n+\n}\nexport const MD2_DATEPICKER_DIRECTIVES = [Md2Datepicker];\n@NgModule({\n- imports: [CommonModule, OverlayModule],\n+ imports: [CommonModule, OverlayModule, PortalModule],\nexports: MD2_DATEPICKER_DIRECTIVES,\ndeclarations: MD2_DATEPICKER_DIRECTIVES,\n})\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update overlay service with dark backdrop |
530,388 | 08.02.2017 16:36:22 | -19,080 | fafbebd6d19cc62c5d293ea11c305fd4702dcc43 | chore(datepicker) update animation and performance | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/lib/datepicker/datepicker-animations.ts",
"diff": "+import {\n+ animate,\n+ AnimationEntryMetadata,\n+ state,\n+ style,\n+ transition,\n+ trigger,\n+} from '@angular/core';\n+\n+/**\n+ * This animation fades in the background color and text content of the\n+ * select's options. It is time delayed to occur 100ms after the overlay\n+ * panel has transformed in.\n+ */\n+export const fadeInContent: AnimationEntryMetadata = trigger('fadeInContent', [\n+ state('showing', style({ opacity: 1 })),\n+ transition('void => showing', [\n+ style({ opacity: 0 }),\n+ animate(`150ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)`)\n+ ])\n+]);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.html",
"new_path": "src/lib/datepicker/datepicker.html",
"diff": "</div>\n</div>\n<template portal>\n- <div class=\"md2-datepicker-panel\" [@transformPanel]=\"'showing'\" (@transformPanel.done)=\"_onPanelDone()\"\n+ <div class=\"md2-datepicker-panel\" [@fadeInContent]=\"'showing'\" (@fadeInContent.done)=\"_onPanelDone()\"\n(keydown)=\"_handleKeydown($event)\" [style.transformOrigin]=\"_transformOrigin\"\n[class.md2-datepicker-panel-done-animating]=\"_panelDoneAnimating\" tabindex=\"0\">\n<div class=\"md2-datepicker-header\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -126,7 +126,7 @@ md2-datepicker.md2-datepicker-disabled:focus {\nborder-radius: 3px;\nbackground-color: white;\noverflow: hidden;\n- box-shadow: 0 2px 6px rgba(black, 0.4);\n+ box-shadow: 0 11px 15px -7px rgba(black, 0.2), 0 24px 38px 3px rgba(black, 0.14), 0 9px 46px 8px rgba(black, 0.12);\noutline: none;\nuser-select: none;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -45,7 +45,7 @@ import {\nTemplatePortalDirective,\nPortalModule\n} from '../core';\n-import { transformPlaceholder, transformPanel, fadeInContent } from '../select/select-animations';\n+import { fadeInContent } from './datepicker-animations';\nimport { Subscription } from 'rxjs/Subscription';\n/** Change event object emitted by Md2Select. */\n@@ -99,8 +99,6 @@ let nextId = 0;\n'(blur)': '_onBlur()'\n},\nanimations: [\n- transformPlaceholder,\n- transformPanel,\nfadeInContent\n],\nencapsulation: ViewEncapsulation.None\n@@ -121,21 +119,6 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\n_transformOrigin: string = 'top';\n_panelDoneAnimating: boolean = false;\n- _positions = [\n- {\n- originX: 'start',\n- originY: 'top',\n- overlayX: 'start',\n- overlayY: 'top',\n- },\n- {\n- originX: 'start',\n- originY: 'bottom',\n- overlayX: 'start',\n- overlayY: 'bottom',\n- },\n- ];\n-\n@ViewChildren(TemplatePortalDirective) templatePortals: QueryList<Portal<any>>;\n/** Event emitted when the select has been opened. */\n@@ -241,7 +224,7 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\nclose(): void {\nsetTimeout(() => {\nthis._panelOpen = false;\n- }, 10)\n+ }, 10);\n//if (!this._date) {\n// this._placeholderState = '';\n//}\n@@ -1152,118 +1135,6 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\nregisterOnTouched(fn: () => {}): void { this._onTouched = fn; }\n-\n- ///**\n- // * Calculates the y-offset of the select's overlay panel in relation to the\n- // * top start corner of the trigger. It has to be adjusted in order for the\n- // * selected option to be aligned over the trigger when the panel opens.\n- // */\n- //private _calculateOverlayOffset(selectedIndex: number, scrollBuffer: number,\n- // maxScroll: number): number {\n- // let optionOffsetFromPanelTop: number;\n-\n- // if (this._scrollTop === 0) {\n- // optionOffsetFromPanelTop = selectedIndex * SELECT_OPTION_HEIGHT;\n- // } else if (this._scrollTop === maxScroll) {\n- // const firstDisplayedIndex = this.options.length - SELECT_MAX_OPTIONS_DISPLAYED;\n- // const selectedDisplayIndex = selectedIndex - firstDisplayedIndex;\n-\n- // // Because the panel height is longer than the height of the options alone,\n- // // there is always extra padding at the top or bottom of the panel. When\n- // // scrolled to the very bottom, this padding is at the top of the panel and\n- // // must be added to the offset.\n- // optionOffsetFromPanelTop =\n- // selectedDisplayIndex * SELECT_OPTION_HEIGHT + SELECT_PANEL_PADDING_Y;\n- // } else {\n- // // If the option was scrolled to the middle of the panel using a scroll buffer,\n- // // its offset will be the scroll buffer minus the half height that was added to\n- // // center it.\n- // optionOffsetFromPanelTop = scrollBuffer - SELECT_OPTION_HEIGHT / 2;\n- // }\n-\n- // // The final offset is the option's offset from the top, adjusted for the height\n- // // difference, multiplied by -1 to ensure that the overlay moves in the correct\n- // // direction up the page.\n- // return optionOffsetFromPanelTop * -1 - SELECT_OPTION_HEIGHT_ADJUSTMENT;\n- //}\n-\n- ///**\n- // * Checks that the attempted overlay position will fit within the viewport.\n- // * If it will not fit, tries to adjust the scroll position and the associated\n- // * y-offset so the panel can open fully on-screen. If it still won't fit,\n- // * sets the offset back to 0 to allow the fallback position to take over.\n- // */\n- //private _checkOverlayWithinViewport(maxScroll: number): void {\n- // const viewportRect = this._viewportRuler.getViewportRect();\n- // const triggerRect = this._getTriggerRect();\n-\n- // const topSpaceAvailable = triggerRect.top - SELECT_PANEL_VIEWPORT_PADDING;\n- // const bottomSpaceAvailable =\n- // viewportRect.height - triggerRect.bottom - SELECT_PANEL_VIEWPORT_PADDING;\n-\n- // const panelHeightTop = Math.abs(this._offsetY);\n- // const totalPanelHeight =\n- // Math.min(this.options.length * SELECT_OPTION_HEIGHT, SELECT_PANEL_MAX_HEIGHT);\n- // const panelHeightBottom = totalPanelHeight - panelHeightTop - triggerRect.height;\n-\n- // if (panelHeightBottom > bottomSpaceAvailable) {\n- // this._adjustPanelUp(panelHeightBottom, bottomSpaceAvailable);\n- // } else if (panelHeightTop > topSpaceAvailable) {\n- // this._adjustPanelDown(panelHeightTop, topSpaceAvailable, maxScroll);\n- // } else {\n- // this._transformOrigin = this._getOriginBasedOnOption();\n- // }\n- //}\n-\n- ///** Adjusts the overlay panel up to fit in the viewport. */\n- //private _adjustPanelUp(panelHeightBottom: number, bottomSpaceAvailable: number) {\n- // const distanceBelowViewport = panelHeightBottom - bottomSpaceAvailable;\n-\n- // // Scrolls the panel up by the distance it was extending past the boundary, then\n- // // adjusts the offset by that amount to move the panel up into the viewport.\n- // this._scrollTop -= distanceBelowViewport;\n- // this._offsetY -= distanceBelowViewport;\n- // this._transformOrigin = this._getOriginBasedOnOption();\n-\n- // // If the panel is scrolled to the very top, it won't be able to fit the panel\n- // // by scrolling, so set the offset to 0 to allow the fallback position to take\n- // // effect.\n- // if (this._scrollTop <= 0) {\n- // this._scrollTop = 0;\n- // this._offsetY = 0;\n- // this._transformOrigin = `50% bottom 0px`;\n- // }\n- //}\n-\n- ///** Adjusts the overlay panel down to fit in the viewport. */\n- //private _adjustPanelDown(panelHeightTop: number, topSpaceAvailable: number,\n- // maxScroll: number) {\n- // const distanceAboveViewport = panelHeightTop - topSpaceAvailable;\n-\n- // // Scrolls the panel down by the distance it was extending past the boundary, then\n- // // adjusts the offset by that amount to move the panel down into the viewport.\n- // this._scrollTop += distanceAboveViewport;\n- // this._offsetY += distanceAboveViewport;\n- // this._transformOrigin = this._getOriginBasedOnOption();\n-\n- // // If the panel is scrolled to the very bottom, it won't be able to fit the\n- // // panel by scrolling, so set the offset to 0 to allow the fallback position\n- // // to take effect.\n- // if (this._scrollTop >= maxScroll) {\n- // this._scrollTop = maxScroll;\n- // this._offsetY = 0;\n- // this._transformOrigin = `50% top 0px`;\n- // return;\n- // }\n- //}\n-\n- ///** Sets the transform origin point based on the selected option. */\n- //private _getOriginBasedOnOption(): string {\n- // const originY =\n- // Math.abs(this._offsetY) - SELECT_OPTION_HEIGHT_ADJUSTMENT + SELECT_OPTION_HEIGHT / 2;\n- // return `50% ${originY}px 0px`;\n- //}\n-\nprivate _subscribeToBackdrop(): void {\nthis._backdropSubscription = this._overlayRef.backdropClick().subscribe(() => {\nthis.close();\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker) update animation and performance |
530,388 | 08.02.2017 16:56:32 | -19,080 | 5da00de4cc856a69f83a7163cecb89fd619fc35c | fix(datepicker) focus host issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -224,7 +224,6 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\nclose(): void {\nsetTimeout(() => {\nthis._panelOpen = false;\n- }, 10);\n//if (!this._date) {\n// this._placeholderState = '';\n//}\n@@ -237,6 +236,7 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\nthis._isYearsVisible = false;\nthis._isCalendarVisible = this.type !== 'time' ? true : false;\nthis._isHoursVisible = true;\n+ }, 10);\n}\n/** Removes the panel from the DOM. */\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) focus host issue |
530,388 | 08.02.2017 17:19:22 | -19,080 | fa57fabdc77e6cb7c38d01ee4dbd7df7a3ce8f94 | fix(datepicker) keydown to open | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -504,7 +504,7 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\ncase SPACE:\nevent.preventDefault();\nevent.stopPropagation();\n- this._showDatepicker();\n+ this.open();\nbreak;\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) keydown to open |
530,388 | 09.02.2017 19:00:50 | -19,080 | c0f79c03aaad97265f516e7df9c76e06ec98b78f | chore(tabs) update change event | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tabs/tabs.ts",
"new_path": "src/lib/tabs/tabs.ts",
"diff": "@@ -16,9 +16,9 @@ import {\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\n-export class Md2TabChangeEvent {\n- index: number;\n- tab: Md2Tab;\n+/** Change event object that is emitted when the tab has changed. */\n+export class Md2TabChange {\n+ constructor(public tab: Md2Tab, public index: number) { }\n}\n@Directive({ selector: '[md2Transclude]' })\n@@ -109,7 +109,7 @@ export class Md2Tabs implements AfterContentInit {\n}\n}\nif (this._isInitialized) {\n- this.change.emit(this._createChangeEvent(value));\n+ this._emitChangeEvent();\n}\n}\n}\n@@ -136,7 +136,7 @@ export class Md2Tabs implements AfterContentInit {\nreturn elements;\n}\n- @Output() change: EventEmitter<Md2TabChangeEvent> = new EventEmitter<Md2TabChangeEvent>();\n+ @Output() change: EventEmitter<Md2TabChange> = new EventEmitter<Md2TabChange>();\nconstructor(private elementRef: ElementRef) { }\n@@ -180,18 +180,9 @@ export class Md2Tabs implements AfterContentInit {\nthis._inkBarWidth = tab.offsetWidth + 'px';\n}\n- /**\n- * Create Change Event\n- * @param index\n- * @return event of Md2TabChangeEvent\n- */\n- private _createChangeEvent(index: number): Md2TabChangeEvent {\n- const event = new Md2TabChangeEvent;\n- event.index = index;\n- if (this.tabs && this.tabs.length) {\n- event.tab = this.tabs.toArray()[index];\n- }\n- return event;\n+ /** Emits an event when the user selects an option. */\n+ _emitChangeEvent(): void {\n+ this.change.emit(new Md2TabChange(this.tabs.toArray()[this._selectedIndex], this._selectedIndex));\n}\n/**\n"
}
] | TypeScript | MIT License | promact/md2 | chore(tabs) update change event |
530,388 | 10.02.2017 15:38:00 | -19,080 | fd83c71df8b83ce874c5e680c98fed9eabecbe83 | chore(tabs) added selectedIndexChange event | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tabs/README.md",
"new_path": "src/lib/tabs/README.md",
"diff": "@@ -13,6 +13,7 @@ Tabs allow the user to organize their content by labels such that only one tab i\n| Name | Type | Description |\n| --- | --- | --- |\n| `change` | `Event` | Fired when changed tab |\n+| `selectedIndexChange` | `Event` | Fired when changed tab with number of selected tab index |\n## `<md2-tab>`\n### Properties of Tab\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/tabs/tabs.ts",
"new_path": "src/lib/tabs/tabs.ts",
"diff": "@@ -95,9 +95,10 @@ export class Md2Tabs implements AfterContentInit {\n@Input() class: string;\n@Input()\n+ get selectedIndex() { return this._selectedIndex; }\nset selectedIndex(value: any) {\nif (typeof value === 'string') { value = parseInt(value); }\n- if (value != this._selectedIndex) {\n+ if (value !== this._selectedIndex) {\nthis._selectedIndex = value;\nthis.adjustOffset(value);\nthis._updateInkBar();\n@@ -110,10 +111,10 @@ export class Md2Tabs implements AfterContentInit {\n}\nif (this._isInitialized) {\nthis._emitChangeEvent();\n+ this.selectedIndexChange.emit(value);\n}\n}\n}\n- get selectedIndex() { return this._selectedIndex; }\nget focusIndex(): number { return this._focusIndex; }\nset focusIndex(value: number) {\n@@ -137,6 +138,7 @@ export class Md2Tabs implements AfterContentInit {\n}\n@Output() change: EventEmitter<Md2TabChange> = new EventEmitter<Md2TabChange>();\n+ @Output() selectedIndexChange: EventEmitter<number> = new EventEmitter<number>();\nconstructor(private elementRef: ElementRef) { }\n"
}
] | TypeScript | MIT License | promact/md2 | chore(tabs) added selectedIndexChange event |
530,388 | 10.02.2017 15:40:23 | -19,080 | 9e5a13171b8e45e604c2f23eafdb3d215b524abf | fix(dialog-demo) updated bindings | [
{
"change_type": "MODIFY",
"old_path": "src/demo-app/dialog/dialog-demo.html",
"new_path": "src/demo-app/dialog/dialog-demo.html",
"diff": "<button button=\"primary\" (click)=\"confirm.show()\">\nConfirm Dialog\n</button>\n- <md2-dialog #custom1 title=\"{{dialogHeader}}\">\n+ <md2-dialog #custom1 [title]=\"dialogHeader\">\n<input type=\"text\" class=\"md2-input\" [(ngModel)]=\"dialogHeader\" />\n<p>\nThe mango is a juicy stone fruit belonging to the genus Mangifera, consisting of numerous\ndecorations at weddings, public celebrations, and religious ceremonies.\n</p>\n</md2-dialog>\n- <md2-dialog #custom title=\"{{dialogHeader}}\">\n+ <md2-dialog #custom [title]=\"dialogHeader\">\n<button button=\"primary\" flex=\"auto\" (click)=\"custom1.show()\">\nCustom Dialog\n</button>\n"
}
] | TypeScript | MIT License | promact/md2 | fix(dialog-demo) updated bindings |
530,388 | 14.02.2017 09:56:56 | -19,080 | 07e098a9e6b4b473ca732c86957a9377a7228026 | chore(dialog) update events and performance | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/README.md",
"new_path": "src/lib/dialog/README.md",
"diff": "@@ -15,6 +15,14 @@ Dialog allow the user to display content in popup.\n| `open()`/`show()` | Open a Dialog. |\n| `close()` | Close a Dialog. |\n+### Events\n+\n+| Name | Type | Description |\n+| --- | --- | --- |\n+| `onOpen` | `Event` | Fired when open the dialog |\n+| `onClose` | `Event` | Fired when close the dialog |\n+| `onCancel` | `Event` | Fired when cancel the dialog |\n+\n### Examples\nA dialog would have the following markup.\n```html\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -18,7 +18,8 @@ import {\nOVERLAY_PROVIDERS,\nOverlayState,\nOverlayRef,\n- TemplatePortal,\n+ OverlayModule,\n+ TemplatePortalDirective,\nESCAPE\n} from '../core/core';\n@@ -27,7 +28,7 @@ import 'rxjs/add/operator/first';\nimport { Animate } from './animate';\n@Directive({ selector: '[md2DialogPortal]' })\n-export class Md2DialogPortal extends TemplatePortal {\n+export class Md2DialogPortal extends TemplatePortalDirective {\nconstructor(templateRef: TemplateRef<any>, viewContainerRef: ViewContainerRef) {\nsuper(templateRef, viewContainerRef);\n}\n@@ -53,7 +54,7 @@ export class Md2DialogFooter { }\nexport class Md2Dialog implements OnDestroy {\nconstructor(private _overlay: Overlay) { }\n- @Output() onShow: EventEmitter<Md2Dialog> = new EventEmitter<Md2Dialog>();\n+ @Output() onOpen: EventEmitter<Md2Dialog> = new EventEmitter<Md2Dialog>();\n@Output() onClose: EventEmitter<any> = new EventEmitter<any>();\n@Output() onCancel: EventEmitter<any> = new EventEmitter<any>();\n@@ -91,7 +92,7 @@ export class Md2Dialog implements OnDestroy {\n.then(() => Animate.wait())\n.then(() => {\nthis._isOpened = true;\n- this.onShow.emit(this);\n+ this.onOpen.emit(this);\nreturn this;\n});\n}\n@@ -129,10 +130,8 @@ export const MD2_DIALOG_DIRECTIVES: any[] = [\nMd2DialogPortal\n];\n-export const MD2_DIALOG_PROVIDERS: any[] = [Overlay, OVERLAY_PROVIDERS];\n-\n@NgModule({\n- imports: [CommonModule],\n+ imports: [CommonModule, OverlayModule],\nexports: MD2_DIALOG_DIRECTIVES,\ndeclarations: MD2_DIALOG_DIRECTIVES,\n})\n@@ -140,7 +139,7 @@ export class Md2DialogModule {\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2DialogModule,\n- providers: MD2_DIALOG_PROVIDERS\n+ providers: []\n};\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(dialog) update events and performance |
530,388 | 14.02.2017 10:42:25 | -19,080 | 3448a763fba3b90440065dac0f8fba0966343571 | fix(datepicker) time format NAN issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -167,23 +167,6 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\n}\n}\nthis._viewValue = this._formatDate(this._date);\n- //let date = '';\n- //if (this.type !== 'time') {\n- // date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n- // '-' + this._date.getDate();\n- //}\n- //if (this.type === 'datetime') {\n- // date += ' ';\n- //}\n- //if (this.type !== 'date') {\n- // date += this._date.getHours() + ':' + this._date.getMinutes();\n- //}\n- //if (this._isInitialized) {\n- // if (this._control) {\n- // this._onChange(date);\n- // }\n- // this.change.emit(date);\n- //}\n}\n}\n@@ -1108,23 +1091,14 @@ export class Md2Datepicker implements AfterContentInit, OnDestroy, ControlValueA\nthis._date = value;\n} else {\nif (this.type === 'time') {\n- this._date = new Date('1-1-1 ' + value);\n+ this._date = new Date();\n+ this._date.setHours(value.substring(0, 2));\n+ this._date.setMinutes(value.substring(3, 5));\n} else {\nthis._date = new Date(value);\n}\n}\nthis._viewValue = this._formatDate(this._date);\n- let date = '';\n- if (this.type !== 'time') {\n- date += this._date.getFullYear() + '-' + (this._date.getMonth() + 1) +\n- '-' + this._date.getDate();\n- }\n- if (this.type === 'datetime') {\n- date += ' ';\n- }\n- if (this.type !== 'date') {\n- date += this._date.getHours() + ':' + this._date.getMinutes();\n- }\n} else {\nthis._date = null;\nthis._viewValue = null;\n"
}
] | TypeScript | MIT License | promact/md2 | fix(datepicker) time format NAN issue #78 |
530,388 | 14.02.2017 11:21:59 | -19,080 | 5fb6bda8c0fc8836157f1d5ea3a261532b2269c7 | docs: added reference of chips | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -44,6 +44,7 @@ export class AppModule { }\n- [md2-accordion](https://github.com/Promact/md2/tree/master/src/lib/accordion)\n- [md2-autocomplete](https://github.com/Promact/md2/tree/master/src/lib/autocomplete)\n+- [md2-chips](https://github.com/Promact/md2/tree/master/src/lib/chips)\n- [md2-collapse](https://github.com/Promact/md2/tree/master/src/lib/collapse)\n- [md2-colorpicker](https://github.com/Promact/md2/tree/master/src/lib/colorpicker)\n- [md2-data-table](https://github.com/Promact/md2/tree/master/src/lib/data-table)\n"
}
] | TypeScript | MIT License | promact/md2 | docs: added reference of chips |
530,388 | 14.02.2017 11:37:15 | -19,080 | 63f999f3e7f54650c20078bc827d801568766410 | fix(core) styling issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/core/theming/_all-theme.scss",
"new_path": "src/lib/core/theming/_all-theme.scss",
"diff": "// Import all the theming functionality.\n@import '../core';\n-@import '../../autocomplete/autocomplete-theme';\n-@import '../../button/button-theme';\n-@import '../../button-toggle/button-toggle-theme';\n-@import '../../card/card-theme';\n-@import '../../checkbox/checkbox-theme';\n-@import '../../chips/chips-theme';\n-@import '../../dialog/dialog-theme';\n-@import '../../grid-list/grid-list-theme';\n-@import '../../icon/icon-theme';\n-@import '../../input/input-theme';\n-@import '../../list/list-theme';\n-@import '../../menu/menu-theme';\n-@import '../../progress-bar/progress-bar-theme';\n-@import '../../progress-spinner/progress-spinner-theme';\n-@import '../../radio/radio-theme';\n-@import '../../select/select-theme';\n-@import '../../sidenav/sidenav-theme';\n-@import '../../slide-toggle/slide-toggle-theme';\n-@import '../../slider/slider-theme';\n-@import '../../tabs/tabs-theme';\n-@import '../../toolbar/toolbar-theme';\n-@import '../../tooltip/tooltip-theme';\n// Create a theme.\n@mixin angular-material-theme($theme) {\n@include mat-core-theme($theme);\n- @include mat-autocomplete-theme($theme);\n- @include mat-button-theme($theme);\n- @include mat-button-toggle-theme($theme);\n- @include mat-card-theme($theme);\n- @include mat-checkbox-theme($theme);\n- @include mat-chips-theme($theme);\n- @include mat-dialog-theme($theme);\n- @include mat-grid-list-theme($theme);\n- @include mat-icon-theme($theme);\n- @include mat-input-theme($theme);\n- @include mat-list-theme($theme);\n- @include mat-menu-theme($theme);\n- @include mat-progress-bar-theme($theme);\n- @include mat-progress-spinner-theme($theme);\n- @include mat-radio-theme($theme);\n- @include mat-select-theme($theme);\n- @include mat-sidenav-theme($theme);\n- @include mat-slide-toggle-theme($theme);\n- @include mat-slider-theme($theme);\n- @include mat-tabs-theme($theme);\n- @include mat-toolbar-theme($theme);\n- @include mat-tooltip-theme($theme);\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(core) styling issue |
530,388 | 14.02.2017 11:41:39 | -19,080 | 447ba282f99fc8319f8e55944e849217774440f8 | chore(tooltip) added scrolling and fixed performance issues | [
{
"change_type": "MODIFY",
"old_path": "src/lib/tooltip/tooltip.ts",
"new_path": "src/lib/tooltip/tooltip.ts",
"diff": "@@ -15,6 +15,7 @@ import {\nNgZone,\nOptional,\nOnDestroy,\n+ OnInit,\nViewEncapsulation,\nChangeDetectorRef\n} from '@angular/core';\n@@ -33,12 +34,17 @@ import { Observable } from 'rxjs/Observable';\nimport { Subject } from 'rxjs/Subject';\nimport { Dir } from '../core/rtl/dir';\nimport 'rxjs/add/operator/first';\n+import { ScrollDispatcher } from '../core/overlay/scroll/scroll-dispatcher';\n+import { Subscription } from 'rxjs/Subscription';\nexport type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';\n/** Time in ms to delay before changing the tooltip visibility to hidden */\nexport const TOUCHEND_HIDE_DELAY = 1500;\n+/** Time in ms to throttle repositioning after scroll events. */\n+export const SCROLL_THROTTLE_MS = 20;\n+\n/**\n* Directive that attaches a material design tooltip to the host element. Animates the showing and\n* hiding of a tooltip provided position (defaults to below the element).\n@@ -55,9 +61,10 @@ export const TOUCHEND_HIDE_DELAY = 1500;\n},\nexportAs: 'md2Tooltip',\n})\n-export class Md2Tooltip implements OnDestroy {\n+export class Md2Tooltip implements OnInit, OnDestroy {\n_overlayRef: OverlayRef;\n_tooltipInstance: Md2TooltipComponent;\n+ scrollSubscription: Subscription;\nprivate _position: TooltipPosition = 'below';\n@@ -94,11 +101,22 @@ export class Md2Tooltip implements OnDestroy {\n}\nconstructor(private _overlay: Overlay,\n+ private _scrollDispatcher: ScrollDispatcher,\nprivate _elementRef: ElementRef,\nprivate _viewContainerRef: ViewContainerRef,\nprivate _ngZone: NgZone,\n@Optional() private _dir: Dir) { }\n+ ngOnInit() {\n+ // When a scroll on the page occurs, update the position in case this tooltip needs\n+ // to be repositioned.\n+ this.scrollSubscription = this._scrollDispatcher.scrolled(SCROLL_THROTTLE_MS).subscribe(() => {\n+ if (this._overlayRef) {\n+ this._overlayRef.updatePosition();\n+ }\n+ });\n+ }\n+\n/**\n* Dispose the tooltip when destroyed.\n*/\n@@ -106,6 +124,8 @@ export class Md2Tooltip implements OnDestroy {\nif (this._tooltipInstance) {\nthis._disposeTooltip();\n}\n+\n+ this.scrollSubscription.unsubscribe();\n}\n/** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */\n@@ -156,7 +176,18 @@ export class Md2Tooltip implements OnDestroy {\nprivate _createOverlay(): void {\nlet origin = this._getOrigin();\nlet position = this._getOverlayPosition();\n+\n+ // Create connected position strategy that listens for scroll events to reposition.\n+ // After position changes occur and the overlay is clipped by a parent scrollable then\n+ // close the tooltip.\nlet strategy = this._overlay.position().connectedTo(this._elementRef, origin, position);\n+ strategy.withScrollableContainers(this._scrollDispatcher.getScrollContainers(this._elementRef));\n+ strategy.onPositionChange.subscribe(change => {\n+ if (change.scrollableViewProperties.isOverlayClipped &&\n+ this._tooltipInstance && this._tooltipInstance.isVisible()) {\n+ this.hide(0);\n+ }\n+ });\nlet config = new OverlayState();\nconfig.positionStrategy = strategy;\n"
}
] | TypeScript | MIT License | promact/md2 | chore(tooltip) added scrolling and fixed performance issues |
530,388 | 14.02.2017 11:45:20 | -19,080 | 49c883d8c9ff98bb1b150a87c4af158904f6b015 | chore: updated lint configs | [
{
"change_type": "MODIFY",
"old_path": "stylelint-config.json",
"new_path": "stylelint-config.json",
"diff": "\"declaration-block-no-duplicate-properties\": [ true, {\n\"ignore\": [\"consecutive-duplicates-with-different-values\"]\n}],\n- \"declaration-block-no-ignored-properties\": true,\n\"declaration-block-trailing-semicolon\": \"always\",\n\"declaration-block-single-line-max-declarations\": 1,\n\"declaration-block-semicolon-space-before\": \"never\",\n"
},
{
"change_type": "MODIFY",
"old_path": "tslint.json",
"new_path": "tslint.json",
"diff": "{\n+ \"rulesDirectory\": [\"node_modules/tslint-no-unused-var\"],\n\"rules\": {\n\"max-line-length\": [true, 100],\n- \"no-inferrable-types\": true,\n+ // Disable this flag because of SHA tslint#48b0c597f9257712c7d1f04b55ed0aa60e333f6a\n+ // TSLint now shows warnings if types for properties are inferred. This rule needs to be\n+ // disabled because all properties need to have explicit types set to work for Dgeni.\n+ \"no-inferrable-types\": false,\n\"class-name\": true,\n\"comment-format\": [\ntrue,\n\"no-bitwise\": true,\n\"no-shadowed-variable\": true,\n\"no-unused-expression\": true,\n- \"no-unused-variable\": [true, {\"ignore-pattern\": \"^(_.*)$\"}],\n+ \"no-unused-var\": [true, {\"ignore-pattern\": \"^(_.*)$\"}],\n\"one-line\": [\ntrue,\n\"check-catch\",\n"
}
] | TypeScript | MIT License | promact/md2 | chore: updated lint configs |
530,388 | 14.02.2017 12:10:30 | -19,080 | b1e859f6682d530d12d77468fc324750ea31aca9 | chore: update tasks | [
{
"change_type": "MODIFY",
"old_path": "tools/dgeni/index.js",
"new_path": "tools/dgeni/index.js",
"diff": "@@ -12,7 +12,7 @@ const typescriptPackage = require('dgeni-packages/typescript');\n// Project configuration.\nconst projectRootDir = path.resolve(__dirname, '../..');\nconst sourceDir = path.resolve(projectRootDir, 'src/lib');\n-const outputDir = path.resolve(projectRootDir, 'dist/docs');\n+const outputDir = path.resolve(projectRootDir, 'dist/docs/api');\nconst templateDir = path.resolve(__dirname, './templates');\n// Package definition for material2 api docs. This only *defines* the package- it does not yet\n@@ -142,10 +142,3 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)\nmodule.exports = apiDocsPackage;\n\\ No newline at end of file\n-\n-// Run the dgeni pipeline, generating documentation.\n-// TODO(jelbourn): remove this once the process is more final in favor of gulp.\n-let dgeni = new Dgeni([apiDocsPackage]);\n-dgeni.generate().then(docs => {\n- console.log(docs);\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/constants.ts",
"new_path": "tools/gulp/constants.ts",
"diff": "@@ -31,7 +31,8 @@ export const LICENSE_BANNER = `/**\n*/`;\nexport const NPM_VENDOR_FILES = [\n- '@angular', 'core-js/client', 'hammerjs', 'rxjs', 'systemjs/dist', 'zone.js/dist'\n+ '@angular', 'core-js/client', 'hammerjs', 'rxjs', 'systemjs/dist',\n+ 'zone.js/dist', 'web-animations-js'\n];\nexport const COMPONENTS_DIR = join(SOURCE_ROOT, 'lib');\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/components.ts",
"new_path": "tools/gulp/tasks/components.ts",
"diff": "@@ -77,6 +77,7 @@ task(':build:components:rollup', () => {\n'rxjs/add/observable/of': 'Rx.Observable',\n'rxjs/add/observable/merge': 'Rx.Observable',\n'rxjs/add/observable/throw': 'Rx.Observable',\n+ 'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',\n'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',\n'rxjs/add/operator/map': 'Rx.Observable.prototype',\n'rxjs/add/operator/filter': 'Rx.Observable.prototype',\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/docs.ts",
"new_path": "tools/gulp/tasks/docs.ts",
"diff": "import gulp = require('gulp');\nconst markdown = require('gulp-markdown');\nconst transform = require('gulp-transform');\n+const highlight = require('gulp-highlight-files');\n+const rename = require('gulp-rename');\n+const flatten = require('gulp-flatten');\nconst hljs = require('highlight.js');\nimport {task} from 'gulp';\nimport * as path from 'path';\n@@ -11,7 +14,14 @@ import * as path from 'path';\n// viewer.\nconst EXAMPLE_PATTERN = /<!--\\W*example\\(([^)]+)\\)\\W*-->/g;\n-gulp.task('docs', () => {\n+// Markdown files can contain links to other markdown files.\n+// Most of those links don't work in the Material docs, because the paths are invalid in the\n+// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.\n+const LINK_PATTERN = /(<a[^>]*) href=\"([^\"]*)\"/g;\n+\n+gulp.task('docs', ['markdown-docs', 'highlight-docs', 'api-docs'])\n+\n+gulp.task('markdown-docs', () => {\nreturn gulp.src(['src/lib/**/*.md', 'guides/*.md'])\n.pipe(markdown({\n// Add syntax highlight using highlight.js\n@@ -25,15 +35,60 @@ gulp.task('docs', () => {\nreturn code;\n}\n}))\n- .pipe(transform((content: string) =>\n- content.toString().replace(EXAMPLE_PATTERN, (match: string, name: string) =>\n- `<div md2-docs-example=\"${name}\"></div>`)))\n- .pipe(gulp.dest('dist/docs'));\n+ .pipe(transform(transformMarkdownFiles))\n+ .pipe(gulp.dest('dist/docs/markdown'));\n+});\n+\n+gulp.task('highlight-docs', () => {\n+ // rename files to fit format: [filename]-[filetype].html\n+ const renameFile = (path: any) => {\n+ const extension = path.extname.slice(1);\n+ path.basename = `${path.basename}-${extension}`;\n+ };\n+\n+ return gulp.src('src/examples/**/*.+(html|css|ts)')\n+ .pipe(flatten())\n+ .pipe(rename(renameFile))\n+ .pipe(highlight())\n+ .pipe(gulp.dest('dist/docs/examples'));\n});\n-task('api', () => {\n+task('api-docs', () => {\nconst Dgeni = require('dgeni');\nconst docsPackage = require(path.resolve(__dirname, '../../dgeni'));\nconst dgeni = new Dgeni([docsPackage]);\nreturn dgeni.generate();\n});\n+\n+/** Updates the markdown file's content to work inside of the docs app. */\n+function transformMarkdownFiles(buffer: Buffer, file: any): string {\n+ let content = buffer.toString('utf-8');\n+\n+ /* Replace <!-- example(..) --> comments with HTML elements. */\n+ content = content.replace(EXAMPLE_PATTERN, (match: string, name: string) =>\n+ `<div material-docs-example=\"${name}\"></div>`\n+ );\n+\n+ /* Replaces the URL in anchor elements inside of compiled markdown files. */\n+ content = content.replace(LINK_PATTERN, (match: string, head: string, link: string) =>\n+ // The head is the first match of the RegExp and is necessary to ensure that the RegExp matches\n+ // an anchor element. The head will be then used to re-create the existing anchor element.\n+ // If the head is not prepended to the replaced value, then the first match will be lost.\n+ `${head} href=\"${fixMarkdownDocLinks(link, file.path)}\"`\n+ );\n+\n+ return content;\n+}\n+\n+/** Fixes paths in the markdown files to work in the material-docs-io. */\n+function fixMarkdownDocLinks(link: string, filePath: string): string {\n+ if (link.startsWith('http') && filePath.indexOf('guides/') === -1) {\n+ return link;\n+ }\n+\n+ let baseName = path.basename(link, path.extname(link));\n+\n+ // Temporary link the file to the /guide URL because that's the route where the\n+ // guides can be loaded in the Material docs.\n+ return `guide/${baseName}`;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/lint.ts",
"new_path": "tools/gulp/tasks/lint.ts",
"diff": "import gulp = require('gulp');\nimport { execNodeTask } from '../task_helpers';\n-\ngulp.task('lint', ['tslint', 'stylelint', 'madge']);\n+\n+/** Task that runs madge to detect circular dependencies. */\ngulp.task('madge', ['build:release'], execNodeTask('madge', ['--circular', './dist']));\n+\n+/** Task to lint Angular Material's scss stylesheets. */\ngulp.task('stylelint', execNodeTask(\n'stylelint', ['src/**/*.scss', '--config', 'stylelint-config.json', '--syntax', 'scss']\n));\n+\n+/** Task to run TSLint against the e2e/ and src/ directories. */\ngulp.task('tslint', execNodeTask('tslint', ['-c', 'tslint.json', 'src/**/*.ts']));\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/gulp/tasks/release.ts",
"new_path": "tools/gulp/tasks/release.ts",
"diff": "@@ -12,7 +12,7 @@ const argv = minimist(process.argv.slice(3));\n/** Removes redundant spec files from the release. TypeScript creates definition files for specs. */\n// TODO(devversion): tsconfig files should share code and don't generate spec files for releases.\n-task(':build:release:clean-spec', cleanTask('dist/**/*(-|.)spec.*'));\n+task(':build:release:clean-spec', cleanTask('dist/**/*+(-|.)spec.*'));\ntask('build:release', function(done: () => void) {\n"
}
] | TypeScript | MIT License | promact/md2 | chore: update tasks |
530,388 | 14.02.2017 14:36:18 | -19,080 | 9c9cf602e77d9cf7bee13eba82c0168ef704a943 | fix(accordion) open multiple accordion-tabs on initialise time event multiple is false | [
{
"change_type": "MODIFY",
"old_path": "src/lib/accordion/accordiontab.ts",
"new_path": "src/lib/accordion/accordiontab.ts",
"diff": "@@ -5,6 +5,7 @@ import {\nViewEncapsulation\n} from '@angular/core';\nimport { Md2Accordion } from './accordionpanel';\n+import { coerceBooleanProperty } from '../core';\n@Directive({ selector: 'md2-accordion-header' })\nexport class Md2AccordionHeader { }\n@@ -32,11 +33,25 @@ export class Md2AccordionHeader { }\n})\nexport class Md2AccordionTab {\n+ private _disabled: boolean = false;\n+ private _active: boolean = false;\n+\n@Input() header: string;\n- @Input() active: boolean;\n+ @Input()\n+ get active(): boolean { return this._active; }\n+ set active(value) {\n+ this._active = coerceBooleanProperty(value);\n+ if (this._active) {\n+ for (var i = 0; i < this._accordion.tabs.length; i++) {\n+ if (this._accordion.tabs[i] !== this) { this._accordion.tabs[i].active = false; }\n+ }\n+ }\n+ }\n- @Input() disabled: boolean;\n+ @Input()\n+ get disabled(): boolean { return this._disabled; }\n+ set disabled(value) { this._disabled = coerceBooleanProperty(value); }\nconstructor(private _accordion: Md2Accordion) {\nthis._accordion.addTab(this);\n@@ -62,10 +77,10 @@ export class Md2AccordionTab {\nfor (let i = 0; i < this._accordion.tabs.length; i++) {\nthis._accordion.tabs[i].active = false;\n}\n- this.active = true;\n+ this._active = true;\nthis._accordion.open.emit({ originalEvent: event, index: index });\n} else {\n- this.active = true;\n+ this._active = true;\nthis._accordion.open.emit({ originalEvent: event, index: index });\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(accordion) open multiple accordion-tabs on initialise time event multiple is false #64 |
530,388 | 15.02.2017 18:13:18 | -19,080 | 2a4f9c21d27ba8e1f73a922475298de6b73e41c6 | chore(dialog) update performance and implementations | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.html",
"new_path": "src/lib/dialog/dialog.html",
"diff": "<template md2DialogPortal>\n- <div class=\"md2-dialog-backdrop\" (click)=\"close()\"></div>\n- <div class=\"md2-dialog\" [class.open]=\"_isOpened\">\n- <div class=\"md2-dialog-container\" [@zoomInContent]=\"'in'\">\n+ <div class=\"md2-dialog-panel\" [@zoomInContent]=\"'in'\" (@zoomInContent.done)=\"_onPanelDone()\">\n+ <div class=\"md2-dialog-content\">\n<div class=\"md2-dialog-header\">\n<button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"close()\">×</button>\n<h2 *ngIf=\"dialogTitle\" class=\"md2-dialog-title\" id=\"myDialogLabel\" [innerHtml]=\"dialogTitle\"></h2>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.scss",
"new_path": "src/lib/dialog/dialog.scss",
"diff": "-.md2-dialog-open {\n- overflow-y: hidden;\n-}\n-\n-.md2-dialog {\n- position: fixed;\n- top: 0;\n- right: 0;\n- bottom: 0;\n- left: 0;\n- z-index: 1050;\n- display: none;\n- overflow-x: hidden;\n- overflow-y: scroll;\n- -webkit-overflow-scrolling: touch;\n- outline: 0;\n-}\n-\n-.md2-dialog.open {\n- display: block;\n-}\n-\n-.md2-dialog .md2-dialog-container {\n+.md2-dialog-panel {\nposition: relative;\n- width: auto;\n- margin: 15px;\n- background-color: #fff;\n- pointer-events: auto;\n- background-clip: padding-box;\n- border-radius: 0 0 4px 4px;\n- outline: 0;\n- box-shadow: 0 7px 8px -4px rgba(0, 0, 0, 0.2), 0 13px 19px 2px rgba(0, 0, 0, 0.14), 0 5px 24px 4px rgba(0, 0, 0, 0.12);\n- transition: 300ms;\n- transform: scale(0.1);\n-}\n-\n-.md2-dialog.open .md2-dialog-container {\n- transform: scale(1);\n-}\n-\n-@media (min-width: 768px) {\n- .md2-dialog .md2-dialog-container {\n+ max-width: 90vw;\nwidth: 600px;\n- margin: 30px auto;\n+ border-radius: 3px;\n+ background-color: white;\n+ overflow: hidden;\n+ box-shadow: 0 11px 15px -7px rgba(black, 0.2), 0 24px 38px 3px rgba(black, 0.14), 0 9px 46px 8px rgba(black, 0.12);\n}\n+\n+.md2-dialog-content {\n}\n.md2-dialog-header {\n.md2-dialog-body {\nposition: relative;\n+ max-height: 65vh;\npadding: 16px;\n+ overflow-y: auto;\n}\n.md2-dialog-footer,\n@@ -129,25 +97,48 @@ md2-dialog-footer {\nborder-top: 1px solid rgba(0, 0, 0, 0.12);\n}\n-.md2-dialog-backdrop {\n+.cdk-overlay-container, .cdk-global-overlay-wrapper {\n+ pointer-events: none;\n+ top: 0;\n+ left: 0;\n+ height: 100%;\n+ width: 100%;\n+}\n+\n+.cdk-overlay-container {\nposition: fixed;\n+ z-index: 1000;\n+}\n+\n+.cdk-global-overlay-wrapper {\n+ display: flex;\n+ position: absolute;\n+ z-index: 1000;\n+}\n+\n+.cdk-overlay-pane {\n+ position: absolute;\n+ pointer-events: auto;\n+ box-sizing: border-box;\n+ z-index: 1000;\n+}\n+\n+.cdk-overlay-backdrop {\n+ position: absolute;\ntop: 0;\nbottom: 0;\nleft: 0;\nright: 0;\n- z-index: 1;\n+ z-index: 1000;\npointer-events: auto;\ntransition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n- background: #212121;\n+ opacity: 0;\n+}\n+\n+.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\nopacity: 0.48;\n}\n-.cdk-overlay-container {\n- position: fixed;\n- pointer-events: none;\n- top: 0;\n- left: 0;\n- height: 100%;\n- width: 100%;\n- z-index: 1000;\n+.cdk-overlay-dark-backdrop {\n+ background: rgba(black, 0.6);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -15,13 +15,12 @@ import {\nimport { CommonModule } from '@angular/common';\nimport {\nOverlay,\n- OVERLAY_PROVIDERS,\nOverlayState,\nOverlayRef,\nOverlayModule,\n- TemplatePortalDirective,\n- ESCAPE\n+ TemplatePortalDirective\n} from '../core/core';\n+import { Subscription } from 'rxjs/Subscription';\nimport 'rxjs/add/operator/first';\n@@ -47,12 +46,17 @@ export class Md2DialogFooter { }\nstyleUrls: ['dialog.css'],\nhost: {\n'tabindex': '0',\n- '(body:keydown.esc)': '_handleDocumentKeydown($event)'\n+ '(body:keydown.esc)': '_handleEscKeydown($event)'\n},\nanimations: [zoomInContent],\nencapsulation: ViewEncapsulation.None,\n})\nexport class Md2Dialog implements OnDestroy {\n+\n+ private _panelOpen = false;\n+ private _overlayRef: OverlayRef = null;\n+ private _backdropSubscription: Subscription;\n+\nconstructor(private _overlay: Overlay) { }\n@Output() onOpen: EventEmitter<Md2Dialog> = new EventEmitter<Md2Dialog>();\n@@ -62,61 +66,96 @@ export class Md2Dialog implements OnDestroy {\n/** The portal to send the dialog content through */\n@ViewChild(Md2DialogPortal) _portal: Md2DialogPortal;\n- /** Is the dialog active? */\n- _isOpened: boolean = false;\n-\n@Input('title') dialogTitle: string;\n- /** Overlay configuration for positioning the dialog */\n- @Input() config = new OverlayState();\n-\n- /** @internal */\n- private _overlayRef: OverlayRef = null;\nngOnDestroy(): any {\nreturn this.close();\n}\n/** Show the dialog */\n- show(): Promise<Md2Dialog> {\n- return this.open();\n+ show(): void {\n+ this.open();\n}\n/** Open the dialog */\n- open(): Promise<Md2Dialog> {\n- return this.close()\n- .then(() => this._overlay.create(this.config))\n- .then((ref: OverlayRef) => {\n- this._overlayRef = ref;\n- return ref.attach(this._portal);\n- })\n- .then(() => {\n- this._isOpened = true;\n- this.onOpen.emit(this);\n- return this;\n- });\n+ open(): void {\n+ if (!this._panelOpen) {\n+ this._createOverlay();\n+ this._overlayRef.attach(this._portal);\n+ this._subscribeToBackdrop();\n+ this._panelOpen = true;\n+ }\n}\n/** Close the dialog */\n- close(result: any = true, cancel: boolean = false): Promise<Md2Dialog> {\n- if (!this._overlayRef) {\n- return Promise.resolve<Md2Dialog>(this);\n+ close(result: any = true, cancel: boolean = false): void {\n+ this._panelOpen = false;\n+ if (this._overlayRef) {\n+ this._overlayRef.detach();\n+ this._backdropSubscription.unsubscribe();\n+ }\n+\n+ //if (!this._overlayRef) {\n+ // return;\n+ //}\n+ //this._panelOpen = false;\n+ //this._overlayRef.detach();\n+ //this._overlayRef.dispose();\n+ //this._overlayRef = null;\n+ //if (cancel) {\n+ // this.onCancel.emit(result);\n+ //}\n}\n- this._isOpened = false;\n- this._overlayRef.detach()\n+\n+ /** Removes the panel from the DOM. */\n+ destroyPanel(): void {\n+ if (this._overlayRef) {\nthis._overlayRef.dispose();\nthis._overlayRef = null;\n- if (cancel) {\n- this.onCancel.emit(result);\n+\n+ this._cleanUpSubscriptions();\n+ }\n+ }\n+\n+ _onPanelDone(): void {\n+ if (this._panelOpen) {\n+ this.onOpen.emit(this);\n} else {\n- this.onClose.emit(result);\n+ this.onClose.emit();\n+ }\n}\n- return Promise.resolve<Md2Dialog>(this);\n+\n+ _handleEscKeydown(event: KeyboardEvent) {\n+ this.close();\n}\n- _handleDocumentKeydown(event: KeyboardEvent) {\n+ private _subscribeToBackdrop(): void {\n+ this._backdropSubscription = this._overlayRef.backdropClick().subscribe(() => {\nthis.close();\n+ });\n}\n+\n+ private _createOverlay(): void {\n+ if (!this._overlayRef) {\n+ let config = new OverlayState();\n+ config.positionStrategy = this._overlay.position()\n+ .global()\n+ .centerHorizontally()\n+ .centerVertically();\n+ config.hasBackdrop = true;\n+ config.backdropClass = 'cdk-overlay-dark-backdrop';\n+\n+ this._overlayRef = this._overlay.create(config);\n+ }\n+ }\n+\n+ private _cleanUpSubscriptions(): void {\n+ if (this._backdropSubscription) {\n+ this._backdropSubscription.unsubscribe();\n+ }\n+ }\n+\n}\nexport const MD2_DIALOG_DIRECTIVES: any[] = [\n"
}
] | TypeScript | MIT License | promact/md2 | chore(dialog) update performance and implementations |
530,388 | 16.02.2017 10:50:43 | -19,080 | faad5d25d66f4e7b846f0710199b291bd7517a45 | fix(dialog) overlay issues and removed onCancel event | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/README.md",
"new_path": "src/lib/dialog/README.md",
"diff": "@@ -21,7 +21,6 @@ Dialog allow the user to display content in popup.\n| --- | --- | --- |\n| `onOpen` | `Event` | Fired when open the dialog |\n| `onClose` | `Event` | Fired when close the dialog |\n-| `onCancel` | `Event` | Fired when cancel the dialog |\n### Examples\nA dialog would have the following markup.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -50,6 +50,7 @@ export class Md2DialogFooter { }\n},\nanimations: [zoomInContent],\nencapsulation: ViewEncapsulation.None,\n+ exportAs: 'md2Dialog'\n})\nexport class Md2Dialog implements OnDestroy {\n@@ -61,17 +62,13 @@ export class Md2Dialog implements OnDestroy {\n@Output() onOpen: EventEmitter<Md2Dialog> = new EventEmitter<Md2Dialog>();\n@Output() onClose: EventEmitter<any> = new EventEmitter<any>();\n- @Output() onCancel: EventEmitter<any> = new EventEmitter<any>();\n/** The portal to send the dialog content through */\n@ViewChild(Md2DialogPortal) _portal: Md2DialogPortal;\n@Input('title') dialogTitle: string;\n-\n- ngOnDestroy(): any {\n- return this.close();\n- }\n+ ngOnDestroy() { this.destroyPanel(); }\n/** Show the dialog */\nshow(): void {\n@@ -95,17 +92,7 @@ export class Md2Dialog implements OnDestroy {\nthis._overlayRef.detach();\nthis._backdropSubscription.unsubscribe();\n}\n-\n- //if (!this._overlayRef) {\n- // return;\n- //}\n- //this._panelOpen = false;\n- //this._overlayRef.detach();\n- //this._overlayRef.dispose();\n- //this._overlayRef = null;\n- //if (cancel) {\n- // this.onCancel.emit(result);\n- //}\n+ this.destroyPanel();\n}\n/** Removes the panel from the DOM. */\n"
}
] | TypeScript | MIT License | promact/md2 | fix(dialog) overlay issues and removed onCancel event |
530,388 | 16.02.2017 10:56:04 | -19,080 | 1d7ee3c4891f69a035b93172e99aa2107e1fc7ae | fix(dialog) overlay service | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -92,7 +92,6 @@ export class Md2Dialog implements OnDestroy {\nthis._overlayRef.detach();\nthis._backdropSubscription.unsubscribe();\n}\n- this.destroyPanel();\n}\n/** Removes the panel from the DOM. */\n"
}
] | TypeScript | MIT License | promact/md2 | fix(dialog) overlay service |
530,388 | 16.02.2017 12:03:30 | -19,080 | e125991c7c1d62640d9cda78b88010b10a51233b | chore(datepicker, toast) update providers and depricated `forRoot()` | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -1147,12 +1147,13 @@ export const MD2_DATEPICKER_DIRECTIVES = [Md2Datepicker];\nimports: [CommonModule, OverlayModule, PortalModule],\nexports: MD2_DATEPICKER_DIRECTIVES,\ndeclarations: MD2_DATEPICKER_DIRECTIVES,\n+ providers: [Md2DateUtil, DateLocale]\n})\nexport class Md2DatepickerModule {\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2DatepickerModule,\n- providers: [Md2DateUtil, DateLocale]\n+ providers: []\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/toast/toast.ts",
"new_path": "src/lib/toast/toast.ts",
"diff": "@@ -189,13 +189,14 @@ export const MD2_TOAST_DIRECTIVES: any[] = [Md2ToastComponent];\nimports: [CommonModule],\nexports: MD2_TOAST_DIRECTIVES,\ndeclarations: MD2_TOAST_DIRECTIVES,\n- entryComponents: MD2_TOAST_DIRECTIVES\n+ entryComponents: MD2_TOAST_DIRECTIVES,\n+ providers: [Md2Toast, Md2ToastConfig, OVERLAY_PROVIDERS]\n})\nexport class Md2ToastModule {\nstatic forRoot(): ModuleWithProviders {\nreturn {\nngModule: Md2ToastModule,\n- providers: [Md2Toast, Md2ToastConfig, OVERLAY_PROVIDERS]\n+ providers: []\n};\n}\n}\n"
}
] | TypeScript | MIT License | promact/md2 | chore(datepicker, toast) update providers and depricated `forRoot()` |
530,388 | 16.02.2017 14:27:37 | -19,080 | 9ae5829006b4b4c1c4b125eccd6d3ca022aa06cd | chore(dialog) update promise in open/close methods | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.ts",
"new_path": "src/lib/dialog/dialog.ts",
"diff": "@@ -70,28 +70,26 @@ export class Md2Dialog implements OnDestroy {\nngOnDestroy() { this.destroyPanel(); }\n- /** Show the dialog */\n- show(): void {\n- this.open();\n- }\n-\n/** Open the dialog */\n- open(): void {\n- if (!this._panelOpen) {\n+ open(): Promise<Md2Dialog> {\n+ if (this._panelOpen) {\n+ return Promise.resolve<Md2Dialog>(this);\n+ }\nthis._createOverlay();\nthis._overlayRef.attach(this._portal);\nthis._subscribeToBackdrop();\nthis._panelOpen = true;\n- }\n+ return Promise.resolve<Md2Dialog>(this);\n}\n/** Close the dialog */\n- close(result: any = true, cancel: boolean = false): void {\n+ close(): Promise<Md2Dialog> {\nthis._panelOpen = false;\nif (this._overlayRef) {\nthis._overlayRef.detach();\nthis._backdropSubscription.unsubscribe();\n}\n+ return Promise.resolve<Md2Dialog>(this);\n}\n/** Removes the panel from the DOM. */\n"
}
] | TypeScript | MIT License | promact/md2 | chore(dialog) update promise in open/close methods |
530,399 | 17.02.2017 13:32:56 | -10,800 | e7d3d599031c4b4d17dd1c86552464d28cd9a4c7 | Sorting issue | [
{
"change_type": "MODIFY",
"old_path": "src/lib/data-table/data-table.ts",
"new_path": "src/lib/data-table/data-table.ts",
"diff": "@@ -125,6 +125,7 @@ export class Md2DataTable implements DoCheck {\n}\nif (this.isDataChanged) {\nthis.fillData();\n+ this.diff.diff(this.md2Data);\nthis.isDataChanged = false;\n}\n}\n@@ -192,14 +193,14 @@ export class Md2DataTable implements DoCheck {\nprivate fillData() {\nlet offset = (this.activePage - 1) * this.rowsPerPage;\nlet data = this.md2Data;\n+ let sortInt = this.sortOrder === 'desc' ? -1 : 1;\nif (this.sortBy) {\ndata = data.sort((a: any, b: any) => {\nlet x = this.caseInsensitiveIteratee(a);\nlet y = this.caseInsensitiveIteratee(b);\n- return (x > y) ? 1 : (y > x) ? -1 : 0;\n+ return ((x > y) ? 1 : (y > x) ? -1 : 0) * sortInt;\n});\n}\n- if (this.sortOrder === 'desc') { data.reverse(); }\nthis.data = data.slice(offset, offset + this.rowsPerPage);\n}\n"
}
] | TypeScript | MIT License | promact/md2 | #73 Sorting issue |
530,388 | 17.02.2017 18:44:28 | -19,080 | dbe1051affa9f227ac5f283fb3bbe11f971b7980 | fix(dialog) demo | [
{
"change_type": "MODIFY",
"old_path": "src/demo-app/dialog/dialog-demo.html",
"new_path": "src/demo-app/dialog/dialog-demo.html",
"diff": "<button button (click)=\"close(alert)\">Got it</button>\n</md2-dialog-footer>\n</md2-dialog>\n- <button button=\"primary\" (click)=\"show(alert)\">Alert Dialog</button>\n+ <button button=\"primary\" (click)=\"open(alert)\">Alert Dialog</button>\n<md2-dialog #confirm>\n<md2-dialog-title>Would you like to delete your debt?</md2-dialog-title>\nAll of the banks have agreed to forgive you your debts.\n<button button (click)=\"close(confirm)\">Cancel</button>\n</md2-dialog-footer>\n</md2-dialog>\n- <button button=\"primary\" (click)=\"confirm.show()\">\n+ <button button=\"primary\" (click)=\"confirm.open()\">\nConfirm Dialog\n</button>\n<md2-dialog #custom1 [title]=\"dialogHeader\">\n</md2-dialog-footer>\n</md2-dialog>\n<md2-dialog #custom [title]=\"dialogHeader\">\n- <button button=\"primary\" flex=\"auto\" (click)=\"custom1.show()\">\n+ <button button=\"primary\" flex=\"auto\" (click)=\"custom1.open()\">\nCustom Dialog\n</button>\n<input type=\"text\" class=\"md2-input\" [(ngModel)]=\"dialogHeader\" />\ndecorations at weddings, public celebrations, and religious ceremonies.\n</p>\n</md2-dialog>\n- <button button=\"primary\" (click)=\"custom.show()\">\n+ <button button=\"primary\" (click)=\"custom.open()\">\nCustom Dialog\n</button>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/demo-app/dialog/dialog-demo.ts",
"new_path": "src/demo-app/dialog/dialog-demo.ts",
"diff": "@@ -9,20 +9,20 @@ export class DialogDemo {\ndialogHeader: string = 'Lorum Ipsum';\nlaunchDialog(dialog: any) {\n- dialog.show();\n+ dialog.open();\n}\n- show(dialog: any) {\n- dialog.show();\n+ open(dialog: any) {\n+ dialog.open();\n}\nclose(dialog: any) {\ndialog.close();\n}\n- showAlert(event: Event) { }\n- showConfirm(event: Event) { }\n- showPrompt(event: Event) { }\n- showAdvanced(event: Event) { }\n- showTabDialog(event: Event) { }\n+ openAlert(event: Event) { }\n+ openConfirm(event: Event) { }\n+ openPrompt(event: Event) { }\n+ openAdvanced(event: Event) { }\n+ openTabDialog(event: Event) { }\n}\n"
}
] | TypeScript | MIT License | promact/md2 | fix(dialog) demo |
530,388 | 18.02.2017 15:18:43 | -19,080 | 3892edf032bd49a6bbbb91893c1899135b2499c1 | chore(dialog) single backdrop overlay for multi level dialogs | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.scss",
"new_path": "src/lib/dialog/dialog.scss",
"diff": "@@ -137,6 +137,10 @@ md2-dialog-footer {\n.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\nopacity: 0.48;\n+\n+ & ~ .cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\n+ opacity: 0;\n+ }\n}\n.cdk-overlay-dark-backdrop {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(dialog) single backdrop overlay for multi level dialogs |
530,388 | 18.02.2017 15:31:07 | -19,080 | 9b67e761e14f1de898355607d8fc9e82c2d6fb26 | chore(dialog) undo multi dialog overlay prevention for bad behavior | [
{
"change_type": "MODIFY",
"old_path": "src/lib/dialog/dialog.scss",
"new_path": "src/lib/dialog/dialog.scss",
"diff": "@@ -137,10 +137,6 @@ md2-dialog-footer {\n.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\nopacity: 0.48;\n-\n- & ~ .cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\n- opacity: 0;\n- }\n}\n.cdk-overlay-dark-backdrop {\n"
}
] | TypeScript | MIT License | promact/md2 | chore(dialog) undo multi dialog overlay prevention for bad behavior |
530,388 | 20.02.2017 16:35:59 | -19,080 | f1fc576fc85621c1a7c0ab2ac29e85337680edd1 | fix(select) subscription issue for unit testing | [
{
"change_type": "MODIFY",
"old_path": "src/lib/select/select.ts",
"new_path": "src/lib/select/select.ts",
"diff": "@@ -263,9 +263,13 @@ export class Md2Select implements AfterContentInit, ControlValueAccessor, OnDest\nngOnDestroy() {\nthis._dropSubscriptions();\n+ if (this._changeSubscription) {\nthis._changeSubscription.unsubscribe();\n+ }\n+ if (this._tabSubscription) {\nthis._tabSubscription.unsubscribe();\n}\n+ }\n/** Toggles the overlay panel open or closed. */\ntoggle(): void {\n"
}
] | TypeScript | MIT License | promact/md2 | fix(select) subscription issue for unit testing |
530,396 | 21.02.2017 11:13:44 | -19,080 | 9cc45c8d899a54fd47cace02dd37c8be93838031 | Fix (Chips) set function for adding new chip on input blur | [
{
"change_type": "MODIFY",
"old_path": "src/lib/chips/chips.ts",
"new_path": "src/lib/chips/chips.ts",
"diff": "@@ -64,7 +64,6 @@ export const MD2_CHIPS_CONTROL_VALUE_ACCESSOR: any = {\nexport class Md2Chips implements ControlValueAccessor, AfterContentInit {\n@Input() tabindex: number = 0;\n- @Input() addOnBlur: boolean = true;\n@Input() addOnComma: boolean = true;\n@Input() addOnEnter: boolean = true;\n@Input() addOnPaste: boolean = true;\n@@ -226,6 +225,7 @@ export class Md2Chips implements ControlValueAccessor, AfterContentInit {\n}\ninputBlurred(event: Event): void {\nthis.inputFocused = false;\n+ this.addNewChip(this.inputValue);\n}\ninputFocus(event: Event): void {\n"
}
] | TypeScript | MIT License | promact/md2 | Fix (Chips) set function for adding new chip on input blur |
530,396 | 22.02.2017 11:58:46 | -19,080 | bef75174485d1c638e5af6629a044a83f0875989 | Fix (Color picker) set default color for invalid color | [
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/colorpicker.html",
"new_path": "src/lib/colorpicker/colorpicker.html",
"diff": "<input [text] (newValue)=\"setColorFromString($event)\" [style.color]=\"fontColor\" [value]=\"hexText\" />\n</div>\n<div [style.color]=\"fontColor\">\n- <div class=\"type-policy\" [class.active]=\"format==0\" (click)=\"formatPolicy(0)\">HEX</div>\n- <div class=\"type-policy\" [class.active]=\"format==1\" (click)=\"formatPolicy(1)\">RGBA</div>\n- <div class=\"type-policy\" [class.active]=\"format==2\" (click)=\"formatPolicy(2)\">HSLA</div>\n+ <div class=\"type-policy\" [style.background]=\"backAreaColor\" [class.active]=\"format==0\" (click)=\"formatPolicy(0)\">HEX</div>\n+ <div class=\"type-policy\" [style.background]=\"backAreaColor\" [class.active]=\"format==1\" (click)=\"formatPolicy(1)\">RGBA</div>\n+ <div class=\"type-policy\" [style.background]=\"backAreaColor\" [class.active]=\"format==2\" (click)=\"formatPolicy(2)\">HSLA</div>\n</div>\n</div>\n<div class=\"input-color-content\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/colorpicker.scss",
"new_path": "src/lib/colorpicker/colorpicker.scss",
"diff": "$black: black;\n$primary: #106cc8 !default;\n-.md2-colorpicker-wrapper { width: 270px; height: 345px; border-radius: 2px; background-color: #fff; z-index: 10; box-shadow: 0 2px 6px rgba($black, 0.4); transform: scale(0); transform-origin: left top; transition: 150ms; user-select: none;\n- &.active { transform: scale(1); }\n+.md2-colorpicker-wrapper {\n+ width: 270px;\n+ height: 345px;\n+ border-radius: 2px;\n+ background-color: #fff;\n+ z-index: 10;\n+ box-shadow: 0 2px 6px rgba($black, 0.4);\n+ transform: scale(0);\n+ transform-origin: left top;\n+ transition: 150ms;\n+ user-select: none;\n+\n+ &.active {\n+ transform: scale(1);\n+ }\n+}\n+\n+.md2-colorpicker-disabled {\n+ pointer-events: none;\n+ cursor: default;\n+\n+ .color-picker-selector .color-text {\n+ color: rgba(0, 0, 0, 0.38);\n+ border-color: transparent;\n+ background-image: linear-gradient(to right, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0.38) 33%, transparent 0%);\n+ background-position: bottom -1px left 0;\n+ background-size: 4px 1px;\n+ background-repeat: repeat-x;\n+ }\n+}\n+\n+.color-picker-selector {\n+ display: block;\n+ padding: 18px 0 18px 32px;\n+ white-space: nowrap;\n+ cursor: pointer;\n+\n+ .color-div {\n+ content: '';\n+ width: 24px;\n+ height: 24px;\n+ overflow: hidden;\n+ background-color: #fff;\n+ background-image: -webkit-linear-gradient(45deg, #ddd 25%, transparent 0, transparent 75%, #ddd 0, #ddd), -webkit-linear-gradient(45deg, #ddd 25%, transparent 0, transparent 75%, #ddd 0, #ddd);\n+ background-image: linear-gradient(45deg, #ddd 25%, transparent 0, transparent 75%, #ddd 0, #ddd), linear-gradient(45deg, #ddd 25%, transparent 0, transparent 75%, #ddd 0, #ddd);\n+ background-size: 8px 8px;\n+ background-position: 0 0, 4px 4px;\n+ position: absolute;\n+ top: 21px;\n+ left: 0;\n+ border: 2px solid #fafafa;\n+ display: block;\n+ fill: currentColor;\n+ cursor: pointer;\n+ border-radius: 50%;\n+ vertical-align: middle;\n+ box-shadow: 0 1px 1px 0 rgba($black, 0.2), 0 1px 1px 1px rgba($black, 0.14), 0 1px 1px 1px rgba($black, 0.12);\n+\n+ .color-fill {\n+ width: 100%;\n+ height: 100%;\n+ }\n+ }\n+\n+ .color-text {\n+ cursor: pointer;\n+ position: relative;\n+ display: block;\n+ min-width: 150px;\n+ height: 30px;\n+ padding: 2px 26px 1px 2px;\n+ margin: 0;\n+ line-height: 26px;\n+ color: rgba(0, 0, 0, 0.87);\n+ vertical-align: middle;\n+ box-sizing: border-box;\n+ border-bottom: 1px solid rgba(0, 0, 0, 0.12);\n+ }\n+}\n+\n+md2-colorpicker {\n+ position: relative;\n+ display: block;\n+ max-width: 175px;\n+ outline: none;\n+ -webkit-backface-visibility: hidden;\n+ backface-visibility: hidden;\n}\n-.md2-colorpicker-disabled { pointer-events: none; cursor: default;\n- .color-picker-selector .color-text { color: rgba(0, 0, 0, 0.38); border-color: transparent; background-image: linear-gradient(to right, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0.38) 33%, transparent 0%); background-position: bottom -1px left 0; background-size: 4px 1px; background-repeat: repeat-x; }\n+\n+.md2-color-picker {\n+ position: relative;\n+ display: block;\n+ outline: none;\n+ backface-visibility: hidden;\n+\n+ * {\n+ box-sizing: border-box;\n+ }\n+\n+ .input-color-content {\n+ width: 250px;\n+ position: relative;\n+ margin: 10px auto;\n+ }\n+\n+ i {\n+ cursor: default;\n+ position: relative;\n+ }\n+\n+ input {\n+ font-size: 15px;\n}\n-.color-picker-selector { display: block; padding: 18px 0 18px 32px; white-space: nowrap; cursor: pointer;\n- .color-div { content: ''; width: 24px; height: 24px; overflow: hidden; background-color: #fff; background-image: -webkit-linear-gradient(45deg,#ddd 25%,transparent 0,transparent 75%,#ddd 0,#ddd),-webkit-linear-gradient(45deg,#ddd 25%,transparent 0,transparent 75%,#ddd 0,#ddd); background-image: linear-gradient(45deg,#ddd 25%,transparent 0,transparent 75%,#ddd 0,#ddd),linear-gradient(45deg,#ddd 25%,transparent 0,transparent 75%,#ddd 0,#ddd); background-size: 8px 8px; background-position: 0 0,4px 4px; position: absolute; top: 21px; left: 0; border: 2px solid #fafafa; display: block; fill: currentColor; cursor: pointer; border-radius: 50%; vertical-align: middle; box-shadow: 0 1px 1px 0 rgba($black, 0.2), 0 1px 1px 1px rgba($black, 0.14), 0 1px 1px 1px rgba($black, 0.12);\n- .color-fill { width: 100%; height: 100%; }\n+\n+ div.cursor-sv {\n+ cursor: default;\n+ position: relative;\n+ border-radius: 50%;\n+ width: 15px;\n+ height: 15px;\n+ border: #ddd solid 1px;\n+ }\n+\n+ div.cursor {\n+ cursor: crosshair;\n+ position: relative;\n+ border-radius: 50%;\n+ width: 13px;\n+ height: 13px;\n+ box-shadow: 0 0 2px 0 rgba($black, 0.5), inset 0 0 2px 0 rgba($black, 0.5);\n+ border: 2px solid #fff;\n+ }\n+\n+ div.color-picker-marker {\n+ cursor: crosshair;\n+ position: relative;\n+ border: 2px solid #fff;\n+ box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.5);\n+ height: 100%;\n+ width: 5px;\n+ border-bottom: 0;\n+ border-top: 0;\n}\n- .color-text { position: relative; display: block; min-width: 150px; height: 30px; padding: 2px 26px 1px 2px; margin: 0; line-height: 26px; color: rgba(0, 0, 0, 0.87); vertical-align: middle; box-sizing: border-box; border-bottom: 1px solid rgba(0, 0, 0, 0.12); }\n+\n+ .saturation-lightness {\n+ width: 100%;\n+ height: 130px;\n+ border: none;\n+ overflow: hidden;\n+ background-image: linear-gradient(to top, #000, rgba(0, 0, 0, 0)), linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\n+ -ms-filter: 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)';\n+ filter: progid:dximagetransform.microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000');\n}\n-md2-colorpicker { position: relative; display: block; max-width: 175px; outline: none; -webkit-backface-visibility: hidden; backface-visibility: hidden; }\n-.md2-color-picker { position: relative; display: block; outline: none; backface-visibility: hidden;\n- * { box-sizing: border-box; }\n- .input-color-content { width: 250px; position: relative; margin: 10px auto; }\n- i { cursor: default; position: relative; }\n- input { font-size: 15px; }\n- div.cursor-sv { cursor: default; position: relative; border-radius: 50%; width: 15px; height: 15px; border: #ddd solid 1px; }\n- div.cursor { cursor: crosshair; position: relative; border-radius: 50%; width: 13px; height: 13px; box-shadow: 0 0 2px 0 rgba($black, 0.5), inset 0 0 2px 0 rgba($black, 0.5); border: 2px solid #fff; }\n- div.color-picker-marker { cursor: crosshair; position: relative; border: 2px solid #fff; box-shadow: 0 0 2px 0 rgba(0,0,0,.5); height: 100%; width: 5px; border-bottom: 0; border-top: 0; }\n- .saturation-lightness { width: 100%; height: 130px; border: none; overflow: hidden; background-image: linear-gradient(to top,#000,rgba(0,0,0,0)),linear-gradient(to right,#fff,rgba(255,255,255,0)); -ms-filter: \"progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)\"; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000'); }\n- .saturation-lightness:hover { cursor: crosshair; }\n- .hue { width: 100%; height: 30px; border: none; margin: 10px 0; background: -webkit-linear-gradient(left, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%); }\n- .alpha { border: 1px solid rgb(239, 239, 239); width: 100%; height: 30px; border: none; background-image: linear-gradient(to left, transparent, transparent), linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); }\n- .selected-color { width: 100%; height: 65px; padding-top: 10px; position: relative; }\n+\n+ .saturation-lightness:hover {\n+ cursor: crosshair;\n}\n-.hex-text { width: 100%;\n- input { width: 100%; border: 0; padding: 4px; text-align: center; background: transparent; outline: none; font-size: 15px; }\n- div { text-align: center; float: left; clear: left; width: 160px; margin-top: 4px; }\n+ .hue {\n+ width: 100%;\n+ height: 30px;\n+ border: none;\n+ margin: 10px 0;\n+ background: -webkit-linear-gradient(left, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);\n+ }\n+\n+ .alpha {\n+ border: 1px solid rgb(239, 239, 239);\n+ width: 100%;\n+ height: 30px;\n+ background-image: linear-gradient(to left, transparent, transparent), linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\n+ }\n+\n+ .selected-color {\n+ width: 100%;\n+ height: 65px;\n+ padding-top: 10px;\n+ position: relative;\n+ }\n+}\n+\n+.hex-text {\n+ width: 100%;\n+\n+ input {\n+ width: 100%;\n+ border: 0;\n+ padding: 4px;\n+ text-align: center;\n+ background: transparent;\n+ outline: none;\n+ font-size: 15px;\n+ }\n+\n+ div {\n+ text-align: center;\n+ float: left;\n+ clear: left;\n+ width: 160px;\n+ margin-top: 4px;\n+ }\n}\n.hsla-text,\n-.rgba-text { text-align: center; }\n+.rgba-text {\n+ text-align: center;\n+}\n.hsla-text input,\n-.rgba-text input { width: 50px; border: 0; padding: 4px 0; background: transparent; text-align: center; }\n+.rgba-text input {\n+ width: 50px;\n+ border: 0;\n+ padding: 4px 0;\n+ background: transparent;\n+ text-align: center;\n+}\n.hsla-text div,\n-.rgba-text div { text-align: center; display: block; }\n+.rgba-text div {\n+ text-align: center;\n+ display: block;\n+}\n.hsla-text label,\n-.rgba-text label { text-align: center; display: inline-block; font-size: 15px; }\n-.md2-color-picker-actions { text-align: right;\n- .md2-button { display: inline-block; min-width: 64px; margin: 4px 8px 8px 0; padding: 0 12px; font-size: 14px; color: $primary; line-height: 36px; text-align: center; text-transform: uppercase; border-radius: 2px; cursor: pointer; box-sizing: border-box; transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1);\n- &:hover { background: darken(white, 8); }\n+.rgba-text label {\n+ text-align: center;\n+ display: inline-block;\n+ font-size: 15px;\n}\n+\n+.md2-color-picker-actions {\n+ text-align: right;\n+\n+ .md2-button {\n+ display: inline-block;\n+ min-width: 64px;\n+ margin: 4px 8px 8px 0;\n+ padding: 0 12px;\n+ font-size: 14px;\n+ color: $primary;\n+ line-height: 36px;\n+ text-align: center;\n+ text-transform: uppercase;\n+ border-radius: 2px;\n+ cursor: pointer;\n+ box-sizing: border-box;\n+ transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1);\n+\n+ &:hover {\n+ background: darken(white, 8);\n}\n+ }\n+}\n+\n.hsla-text div:nth-child(5),\n-.rgba-text div:nth-child(5) { clear: left; }\n+.rgba-text div:nth-child(5) {\n+ clear: left;\n+}\n-.type-policy { width: 33.3%; text-align: center; font-size: 14px; display: inline-block; float: left; padding: 2px; margin-top: 6px; cursor: pointer; background: rgba(255,255,255,0.4); }\n-.type-policy.active { background: rgba(255,255,255,0.2); }\n-.cdk-overlay-container, .cdk-global-overlay-wrapper { pointer-events: none; top: 0; left: 0; height: 100%; width: 100%; }\n+.type-policy {\n+ width: 33.3%;\n+ text-align: center;\n+ font-size: 14px;\n+ display: inline-block;\n+ float: left;\n+ padding: 2px;\n+ margin-top: 6px;\n+ cursor: pointer;\n+ background: rgba(255, 255, 255, 0.4);\n+}\n-.cdk-overlay-container { position: fixed; z-index: 1000; }\n+.type-policy.active {\n+ background: rgba(153, 153, 153, 0.2) !important;\n+}\n-.cdk-global-overlay-wrapper { display: flex; position: absolute; z-index: 1000; }\n+.cdk-overlay-container, .cdk-global-overlay-wrapper {\n+ pointer-events: none;\n+ top: 0;\n+ left: 0;\n+ height: 100%;\n+ width: 100%;\n+}\n-.cdk-overlay-pane { position: absolute; pointer-events: auto; box-sizing: border-box; z-index: 1000; }\n+.cdk-overlay-container {\n+ position: fixed;\n+ z-index: 1000;\n+}\n-.cdk-overlay-backdrop { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1000; pointer-events: auto; transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1); opacity: 0; }\n+.cdk-global-overlay-wrapper {\n+ display: flex;\n+ position: absolute;\n+ z-index: 1000;\n+}\n+\n+.cdk-overlay-pane {\n+ position: absolute;\n+ pointer-events: auto;\n+ box-sizing: border-box;\n+ z-index: 1000;\n+}\n-.cdk-overlay-backdrop.cdk-overlay-backdrop-showing { opacity: 0.48; }\n+.cdk-overlay-backdrop {\n+ position: absolute;\n+ top: 0;\n+ bottom: 0;\n+ left: 0;\n+ right: 0;\n+ z-index: 1000;\n+ pointer-events: auto;\n+ transition: opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1);\n+ opacity: 0;\n+}\n-.cdk-overlay-dark-backdrop { background: rgba(black, 0.6); }\n+.cdk-overlay-backdrop.cdk-overlay-backdrop-showing {\n+ opacity: 0.48;\n+}\n+\n+.cdk-overlay-dark-backdrop {\n+ background: rgba(black, 0.6);\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/colorpicker/colorpicker.ts",
"new_path": "src/lib/colorpicker/colorpicker.ts",
"diff": "@@ -199,6 +199,7 @@ export class Md2Colorpicker implements OnDestroy, ControlValueAccessor {\nalphaColor: string;\nhexText: string;\nformat: number;\n+ backColor: boolean = true;\nprivate _overlayRef: OverlayRef;\nprivate _backdropSubscription: Subscription;\n@@ -218,6 +219,7 @@ export class Md2Colorpicker implements OnDestroy, ControlValueAccessor {\n/** The placeholder displayed in the trigger of the select. */\nprivate _placeholder: string = 'daa';\nprivate fontColor: string;\n+ private backAreaColor: string;\n_onChange = (value: any) => { };\n_onTouched = () => { };\n@@ -303,6 +305,7 @@ export class Md2Colorpicker implements OnDestroy, ControlValueAccessor {\n} else {\nthis.hsva = this.service.stringToHsva(this._defalutColor);\n}\n+\nthis.sliderDim = new SliderDimension(245, 250, 130, 245);\nthis.slider = new SliderPosition(0, 0, 0, 0);\nif (this.cFormat === 'rgb') {\n@@ -450,6 +453,7 @@ export class Md2Colorpicker implements OnDestroy, ControlValueAccessor {\nsetColorFromString(value: string) {\nif (!this.isValidColor(value)) {\nvalue = '#000000';\n+ this.backColor = false;\n}\nlet hsva = this.service.stringToHsva(value);\nif (hsva !== null) {\n@@ -480,12 +484,19 @@ export class Md2Colorpicker implements OnDestroy, ControlValueAccessor {\nthis.hslaText = new Hsla(Math.round((hsla.h) * 360), Math.round(hsla.s * 100),\nMath.round(hsla.l * 100), Math.round(hsla.a * 100) / 100);\nthis.rgbaText = new Rgba(rgba.r, rgba.g, rgba.b, Math.round(rgba.a * 100) / 100);\n+ if (this.backColor) {\nthis.hexText = this.service.hexText(rgba);\n+ }\n+ this.backColor = true;\nlet colorCode = Math.round((this.rgbaText.r * 299 + this.rgbaText.g * 587 +\nthis.rgbaText.b * 114) / 1000);\nif (colorCode >= 128 || this.hsva.a < 0.35) {\nthis.fontColor = 'black';\n- } else { this.fontColor = 'white'; }\n+ this.backAreaColor = 'rgba(0,0,0,.4)';\n+ } else {\n+ this.fontColor = 'white';\n+ this.backAreaColor = 'rgba(255,255,255,.4)';\n+ }\nif (this.format === 0 && this.hsva.a < 1) {\nthis.format++;\n"
}
] | TypeScript | MIT License | promact/md2 | Fix (Color picker) set default color for invalid color |
530,395 | 22.02.2017 18:01:20 | 10,800 | d0c6413d18af24d524b569feb10e25b331031104 | datepicker: do not set a max-width for datepicker and let the user defines it's width
Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/demo-app/datepicker/datepicker-demo.html",
"new_path": "src/demo-app/datepicker/datepicker-demo.html",
"diff": "format=\"DD/MM/YYYY\"\n(change)=\"handleChange($event)\">\n</md2-datepicker>\n+ </div>\n+ <div>\n<md2-datepicker [(ngModel)]=\"date\"\ntype=\"date\"\nplaceholder=\"Date\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -10,8 +10,8 @@ $md2-datepicker-calendar-height: 300px !default;\nmd2-datepicker {\nposition: relative;\n- display: block;\n- max-width: 200px;\n+ display: inline-block;\n+ min-width: 175px;\noutline: none;\nbackface-visibility: hidden;\n"
}
] | TypeScript | MIT License | promact/md2 | datepicker: do not set a max-width for datepicker and let the user defines it's width
Fixes #104 |
530,395 | 22.02.2017 19:27:51 | 10,800 | 5682ead840f4d58ba543354a88f39db31d157373 | datepicker: placeholder should keep the floating state when the dialog is opened
Fixes | [
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.scss",
"new_path": "src/lib/datepicker/datepicker.scss",
"diff": "@@ -103,7 +103,7 @@ md2-datepicker {\ntransform: translate3d(0, 6px, 0) scale(0.75);\n}\n- md2-datepicker:focus & {\n+ md2-datepicker:focus &, md2-datepicker.md2-datepicker-opened & {\ncolor: $primary;\ntransform: translate3d(0, 6px, 0) scale(0.75);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/lib/datepicker/datepicker.ts",
"new_path": "src/lib/datepicker/datepicker.ts",
"diff": "@@ -89,6 +89,7 @@ let nextId = 0;\n'role': 'datepicker',\n'[id]': 'id',\n'[class.md2-datepicker-disabled]': 'disabled',\n+ '[class.md2-datepicker-opened]': 'panelOpen',\n'[attr.tabindex]': 'disabled ? -1 : tabindex',\n'[attr.aria-label]': 'placeholder',\n'[attr.aria-required]': 'required.toString()',\n"
}
] | TypeScript | MIT License | promact/md2 | datepicker: placeholder should keep the floating state when the dialog is opened
Fixes #107 |