You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

org_type.go 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. // VisibleType defines the visibility (Organization only)
  6. type VisibleType int
  7. const (
  8. // VisibleTypePublic Visible for everyone
  9. VisibleTypePublic VisibleType = iota
  10. // VisibleTypeLimited Visible for every connected user
  11. VisibleTypeLimited
  12. // VisibleTypePrivate Visible only for organization's members
  13. VisibleTypePrivate
  14. )
  15. // VisibilityModes is a map of org Visibility types
  16. var VisibilityModes = map[string]VisibleType{
  17. "public": VisibleTypePublic,
  18. "limited": VisibleTypeLimited,
  19. "private": VisibleTypePrivate,
  20. }
  21. // IsPublic returns true if VisibleType is public
  22. func (vt VisibleType) IsPublic() bool {
  23. return vt == VisibleTypePublic
  24. }
  25. // IsLimited returns true if VisibleType is limited
  26. func (vt VisibleType) IsLimited() bool {
  27. return vt == VisibleTypeLimited
  28. }
  29. // IsPrivate returns true if VisibleType is private
  30. func (vt VisibleType) IsPrivate() bool {
  31. return vt == VisibleTypePrivate
  32. }
  33. // ExtractKeysFromMapString provides a slice of keys from map
  34. func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) {
  35. for k := range in {
  36. keys = append(keys, k)
  37. }
  38. return
  39. }