Show a proper error message on creating/updating an event
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
9430f1145f
commit
75fc1f125a
|
@ -588,6 +588,7 @@ export default class EditEvent extends Vue {
|
|||
} catch (err) {
|
||||
this.saving = false;
|
||||
console.error(err);
|
||||
this.handleError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,7 +616,7 @@ export default class EditEvent extends Vue {
|
|||
});
|
||||
} catch (err) {
|
||||
this.saving = false;
|
||||
console.error(err);
|
||||
this.handleError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,6 +628,16 @@ export default class EditEvent extends Vue {
|
|||
: this.$i18n.t("The event has been updated")) as string;
|
||||
}
|
||||
|
||||
private handleError(err: any) {
|
||||
console.error(err);
|
||||
|
||||
if (err.graphQLErrors !== undefined) {
|
||||
err.graphQLErrors.forEach(({ message }: { message: string }) => {
|
||||
this.$notifier.error(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in cache the updated or created event.
|
||||
* If the event is not a draft anymore, also put in cache the participation
|
||||
|
|
|
@ -219,7 +219,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Event do
|
|||
def update_event(
|
||||
_parent,
|
||||
%{event_id: event_id} = args,
|
||||
%{context: %{current_user: user}} = _resolution
|
||||
%{context: %{current_user: %User{} = user}} = _resolution
|
||||
) do
|
||||
# See https://github.com/absinthe-graphql/absinthe/issues/490
|
||||
with args <- Map.put(args, :options, args[:options] || %{}),
|
||||
|
|
|
@ -666,7 +666,7 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
|||
assert hd(json_response(res, 200)["errors"])["message"] == "Event not found"
|
||||
end
|
||||
|
||||
test "update_event/3 should check the user is an administrator", %{
|
||||
test "update_event/3 should check the user is the organizer", %{
|
||||
conn: conn,
|
||||
actor: _actor,
|
||||
user: user
|
||||
|
|
Loading…
Reference in a new issue