From e1bc27c7b076d260975400cf844589595447f76c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Aug 2020 11:53:24 +0200 Subject: [PATCH] Add group admin profiles And other fixes Signed-off-by: Thomas Citharel --- js/src/common.scss | 24 +- .../Discussion/DiscussionListItem.vue | 11 +- js/src/components/Settings/SettingsMenu.vue | 1 + js/src/graphql/discussion.ts | 3 + js/src/graphql/group.ts | 252 ++++++---- js/src/i18n/en_US.json | 17 +- js/src/i18n/fr_FR.json | 21 +- js/src/mixins/identityEdition.ts | 3 +- js/src/router/settings.ts | 18 + js/src/types/actor/actor.model.ts | 4 +- js/src/types/comment.model.ts | 1 + js/src/types/discussions.ts | 8 + js/src/utils/username.ts | 29 ++ js/src/views/Account/Register.vue | 4 +- .../views/Account/children/EditIdentity.vue | 1 + js/src/views/Admin/AdminGroupProfile.vue | 436 ++++++++++++++++ js/src/views/Admin/AdminProfile.vue | 1 + js/src/views/Admin/AdminUserProfile.vue | 1 + js/src/views/Admin/Dashboard.vue | 1 + js/src/views/Admin/GroupProfiles.vue | 168 +++++++ js/src/views/Admin/Profiles.vue | 1 + js/src/views/Admin/Users.vue | 1 + js/src/views/Discussions/Discussion.vue | 1 + js/src/views/Event/Event.vue | 2 + js/src/views/Group/Create.vue | 101 +++- js/src/views/Group/Group.vue | 2 + js/src/views/Group/GroupList.vue | 8 +- js/src/views/Group/GroupMembers.vue | 2 +- js/src/views/Group/GroupSettings.vue | 40 +- js/src/views/Group/MyGroups.vue | 2 +- js/src/views/Moderation/Logs.vue | 1 + js/src/views/Moderation/Report.vue | 1 + js/src/views/Moderation/ReportList.vue | 2 +- js/src/views/Posts/Edit.vue | 1 + js/src/views/Posts/List.vue | 1 + js/src/views/Posts/Post.vue | 2 + js/src/views/Resources/ResourceFolder.vue | 1 + js/src/views/Search.vue | 13 +- js/src/views/Todos/Todo.vue | 1 + js/src/views/Todos/TodoList.vue | 1 + js/src/views/Todos/TodoLists.vue | 1 + lib/federation/activity_pub/activity_pub.ex | 55 ++- lib/federation/activity_pub/fetcher.ex | 12 + lib/federation/activity_pub/refresher.ex | 57 ++- lib/federation/activity_pub/transmogrifier.ex | 25 +- lib/federation/activity_pub/types/actors.ex | 40 +- lib/federation/activity_pub/types/comments.ex | 20 +- .../activity_pub/types/discussions.ex | 33 +- lib/federation/activity_pub/types/entity.ex | 24 +- lib/federation/activity_pub/types/events.ex | 4 +- lib/federation/activity_pub/types/members.ex | 13 +- lib/federation/activity_pub/types/posts.ex | 3 +- .../activity_pub/types/resources.ex | 3 +- .../activity_pub/types/todo_lists.ex | 7 +- lib/federation/activity_pub/types/todos.ex | 6 +- lib/federation/activity_pub/utils.ex | 4 +- .../activity_stream/converter/comment.ex | 1 + .../activity_stream/converter/discussion.ex | 1 + .../activity_stream/converter/tombstone.ex | 2 +- lib/graphql/api/groups.ex | 2 +- lib/graphql/resolvers/actor.ex | 104 ++++ lib/graphql/resolvers/discussion.ex | 11 +- lib/graphql/resolvers/group.ex | 56 ++- lib/graphql/resolvers/member.ex | 10 +- lib/graphql/resolvers/person.ex | 59 --- lib/graphql/resolvers/post.ex | 6 +- lib/graphql/schema.ex | 1 + lib/graphql/schema/actor.ex | 18 + lib/graphql/schema/actors/group.ex | 12 +- lib/graphql/schema/actors/person.ex | 10 - lib/graphql/schema/discussions/comment.ex | 1 + lib/mobilizon/actors/actors.ex | 242 +++++++-- lib/mobilizon/discussions/discussions.ex | 37 +- lib/mobilizon/posts/posts.ex | 14 +- lib/mobilizon/tombstone.ex | 14 + lib/web/email/group.ex | 83 +++- .../templates/email/group_deletion.html.eex | 51 ++ .../templates/email/group_deletion.text.eex | 5 + ...html.eex => group_member_removal.html.eex} | 0 ...text.eex => group_member_removal.text.eex} | 0 .../templates/email/group_suspension.html.eex | 66 +++ .../templates/email/group_suspension.text.eex | 8 + lib/web/views/activity_pub/actor_view.ex | 2 +- priv/gettext/ar/LC_MESSAGES/default.po | 66 ++- priv/gettext/be/LC_MESSAGES/default.po | 66 ++- priv/gettext/ca/LC_MESSAGES/default.po | 66 ++- priv/gettext/cs/LC_MESSAGES/default.po | 66 ++- priv/gettext/de/LC_MESSAGES/default.po | 66 ++- priv/gettext/default.pot | 62 ++- priv/gettext/en/LC_MESSAGES/default.po | 66 ++- priv/gettext/es/LC_MESSAGES/default.po | 466 ++++++++++-------- priv/gettext/fi/LC_MESSAGES/default.po | 466 ++++++++++-------- priv/gettext/fr/LC_MESSAGES/default.po | 59 ++- priv/gettext/it/LC_MESSAGES/default.po | 66 ++- priv/gettext/ja/LC_MESSAGES/default.po | 66 ++- priv/gettext/nl/LC_MESSAGES/default.po | 66 ++- priv/gettext/oc/LC_MESSAGES/default.po | 66 ++- priv/gettext/pl/LC_MESSAGES/default.po | 66 ++- priv/gettext/pt/LC_MESSAGES/default.po | 66 ++- priv/gettext/pt_BR/LC_MESSAGES/default.po | 66 ++- priv/gettext/ru/LC_MESSAGES/default.po | 66 ++- priv/gettext/sv/LC_MESSAGES/default.po | 66 ++- .../activity_pub/transmogrifier_test.exs | 22 +- test/graphql/resolvers/group_test.exs | 190 +++---- test/graphql/resolvers/member_test.exs | 78 ++- test/graphql/resolvers/person_test.exs | 8 +- test/mobilizon/actors/actors_test.exs | 8 +- 107 files changed, 3514 insertions(+), 1146 deletions(-) create mode 100644 js/src/utils/username.ts create mode 100644 js/src/views/Admin/AdminGroupProfile.vue create mode 100644 js/src/views/Admin/GroupProfiles.vue create mode 100644 lib/graphql/resolvers/actor.ex create mode 100644 lib/web/templates/email/group_deletion.html.eex create mode 100644 lib/web/templates/email/group_deletion.text.eex rename lib/web/templates/email/{group_removal.html.eex => group_member_removal.html.eex} (100%) rename lib/web/templates/email/{group_removal.text.eex => group_member_removal.text.eex} (100%) create mode 100644 lib/web/templates/email/group_suspension.html.eex create mode 100644 lib/web/templates/email/group_suspension.text.eex diff --git a/js/src/common.scss b/js/src/common.scss index db448b2f5..f739115fc 100644 --- a/js/src/common.scss +++ b/js/src/common.scss @@ -1,24 +1,14 @@ +@import "variables.scss"; + a { + color: $violet-2; +} + +a.out, +.content a { text-decoration: underline; text-decoration-color: #ed8d07; text-decoration-thickness: 2px; - - &.navbar-item, - &.dropdown-item, - &.card, - &.button, - &[href="#comments"], - &.router-link-active, - &.comment-link, - &.pagination-link, - &.datepicker-cell, - &.list-item { - text-decoration: none; - } -} - -nav.breadcrumb ul li a { - text-decoration: none; } input.input { diff --git a/js/src/components/Discussion/DiscussionListItem.vue b/js/src/components/Discussion/DiscussionListItem.vue index 280704893..ab6bc2938 100644 --- a/js/src/components/Discussion/DiscussionListItem.vue +++ b/js/src/components/Discussion/DiscussionListItem.vue @@ -15,8 +15,8 @@

{{ discussion.title }}

- - {{ $timeAgo.format(new Date(discussion.updatedAt), "twitter") || $t("Right now") }} + {{ $timeAgo.format(new Date(actualDate), "twitter") || $t("Right now") }}
@@ -46,6 +46,13 @@ export default class DiscussionListItem extends Vue { } return element.innerText; } + + get actualDate() { + if (this.discussion.updatedAt === this.discussion.insertedAt && this.discussion.lastComment) { + return this.discussion.lastComment.publishedAt; + } + return this.discussion.updatedAt; + } } diff --git a/js/src/views/Admin/AdminProfile.vue b/js/src/views/Admin/AdminProfile.vue index 41be242c1..4f04b25fe 100644 --- a/js/src/views/Admin/AdminProfile.vue +++ b/js/src/views/Admin/AdminProfile.vue @@ -139,6 +139,7 @@ const EVENTS_PER_PAGE = 10; apollo: { person: { query: GET_PERSON, + fetchPolicy: "cache-and-network", variables() { return { actorId: this.id, diff --git a/js/src/views/Admin/AdminUserProfile.vue b/js/src/views/Admin/AdminUserProfile.vue index 179af473d..846751cb1 100644 --- a/js/src/views/Admin/AdminUserProfile.vue +++ b/js/src/views/Admin/AdminUserProfile.vue @@ -69,6 +69,7 @@ import { IPerson } from "../../types/actor"; apollo: { user: { query: GET_USER, + fetchPolicy: "cache-and-network", variables() { return { id: this.id, diff --git a/js/src/views/Admin/Dashboard.vue b/js/src/views/Admin/Dashboard.vue index 2d9a4cd2d..18b55838b 100644 --- a/js/src/views/Admin/Dashboard.vue +++ b/js/src/views/Admin/Dashboard.vue @@ -71,6 +71,7 @@ import RouteName from "../../router/name"; apollo: { dashboard: { query: DASHBOARD, + fetchPolicy: "cache-and-network", }, }, metaInfo() { diff --git a/js/src/views/Admin/GroupProfiles.vue b/js/src/views/Admin/GroupProfiles.vue new file mode 100644 index 000000000..da2872422 --- /dev/null +++ b/js/src/views/Admin/GroupProfiles.vue @@ -0,0 +1,168 @@ + + + diff --git a/js/src/views/Admin/Profiles.vue b/js/src/views/Admin/Profiles.vue index 47eb44985..eb96a0536 100644 --- a/js/src/views/Admin/Profiles.vue +++ b/js/src/views/Admin/Profiles.vue @@ -91,6 +91,7 @@ const PROFILES_PER_PAGE = 10; apollo: { persons: { query: LIST_PROFILES, + fetchPolicy: "cache-and-network", variables() { return { preferredUsername: this.preferredUsername, diff --git a/js/src/views/Admin/Users.vue b/js/src/views/Admin/Users.vue index 6d1d06381..89a51af90 100644 --- a/js/src/views/Admin/Users.vue +++ b/js/src/views/Admin/Users.vue @@ -103,6 +103,7 @@ const USERS_PER_PAGE = 10; apollo: { users: { query: LIST_USERS, + fetchPolicy: "cache-and-network", variables() { return { email: this.email, diff --git a/js/src/views/Discussions/Discussion.vue b/js/src/views/Discussions/Discussion.vue index b5ddf54eb..68baaa109 100644 --- a/js/src/views/Discussions/Discussion.vue +++ b/js/src/views/Discussions/Discussion.vue @@ -120,6 +120,7 @@ import { DELETE_COMMENT, UPDATE_COMMENT } from "@/graphql/comment"; apollo: { discussion: { query: GET_DISCUSSION, + fetchPolicy: "cache-and-network", variables() { return { slug: this.slug, diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index f42a7190e..6c09af669 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -578,6 +578,7 @@ import PopoverActorCard from "../../components/Account/PopoverActorCard.vue"; apollo: { event: { query: FETCH_EVENT, + fetchPolicy: "cache-and-network", variables() { return { uuid: this.uuid, @@ -592,6 +593,7 @@ import PopoverActorCard from "../../components/Account/PopoverActorCard.vue"; }, participations: { query: EVENT_PERSON_PARTICIPATION, + fetchPolicy: "cache-and-network", variables() { return { eventId: this.event.id, diff --git a/js/src/views/Group/Create.vue b/js/src/views/Group/Create.vue index a2b7e05c4..f6d1a0e27 100644 --- a/js/src/views/Group/Create.vue +++ b/js/src/views/Group/Create.vue @@ -2,41 +2,64 @@

{{ $t("Create a new group") }}

-
- - - + + {{ value }} + - +
+ +
+ +
+ + +

+ @{{ host }} +

+
+
+

+

+ - +
- Avatar - + {{ $t("Avatar") }} +
- Banner - + {{ $t("Banner") }} +
- -
+ +
diff --git a/js/src/views/Group/Group.vue b/js/src/views/Group/Group.vue index d8a3b912c..bf09a7410 100644 --- a/js/src/views/Group/Group.vue +++ b/js/src/views/Group/Group.vue @@ -304,6 +304,7 @@ import addMinutes from "date-fns/addMinutes"; apollo: { group: { query: FETCH_GROUP, + fetchPolicy: "cache-and-network", variables() { return { name: this.preferredUsername, @@ -312,6 +313,7 @@ import addMinutes from "date-fns/addMinutes"; }, person: { query: PERSON_MEMBERSHIPS, + fetchPolicy: "cache-and-network", variables() { return { id: this.currentActor.id, diff --git a/js/src/views/Group/GroupList.vue b/js/src/views/Group/GroupList.vue index 0e97d1d5d..86b3fadf6 100644 --- a/js/src/views/Group/GroupList.vue +++ b/js/src/views/Group/GroupList.vue @@ -22,11 +22,15 @@ import { LIST_GROUPS } from "@/graphql/group"; import { Group, IGroup } from "@/types/actor"; import GroupMemberCard from "@/components/Group/GroupMemberCard.vue"; import RouteName from "../../router/name"; +import { Paginate } from "@/types/paginate"; @Component({ apollo: { groups: { - query: LIST_GROUPS, + query: { + query: LIST_GROUPS, + fetchPolicy: "network-only", + }, }, }, components: { @@ -34,7 +38,7 @@ import RouteName from "../../router/name"; }, }) export default class GroupList extends Vue { - groups: { elements: IGroup[]; total: number } = { elements: [], total: 0 }; + groups!: Paginate; loading = true; diff --git a/js/src/views/Group/GroupMembers.vue b/js/src/views/Group/GroupMembers.vue index e6fa34c04..2788c4638 100644 --- a/js/src/views/Group/GroupMembers.vue +++ b/js/src/views/Group/GroupMembers.vue @@ -176,7 +176,7 @@ import { IMember, MemberRole } from "../../types/actor/group.model"; apollo: { group: { query: GROUP_MEMBERS, - // fetchPolicy: "network-only", + fetchPolicy: "network-only", variables() { return { name: this.$route.params.preferredUsername, diff --git a/js/src/views/Group/GroupSettings.vue b/js/src/views/Group/GroupSettings.vue index 7e75f6234..deae0d90d 100644 --- a/js/src/views/Group/GroupSettings.vue +++ b/js/src/views/Group/GroupSettings.vue @@ -91,7 +91,10 @@ :value="currentAddress" /> - {{ $t("Update group") }} +
+ {{ $t("Update group") }} + {{ $t("Delete group") }} +
@@ -100,7 +103,7 @@