mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-22 07:52:43 +00:00
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
3 changed files with 14 additions and 3 deletions
|
@ -588,6 +588,7 @@ export default class EditEvent extends Vue {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
this.handleError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ export default class EditEvent extends Vue {
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.saving = false;
|
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;
|
: 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.
|
* Put in cache the updated or created event.
|
||||||
* If the event is not a draft anymore, also put in cache the participation
|
* 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(
|
def update_event(
|
||||||
_parent,
|
_parent,
|
||||||
%{event_id: event_id} = args,
|
%{event_id: event_id} = args,
|
||||||
%{context: %{current_user: user}} = _resolution
|
%{context: %{current_user: %User{} = user}} = _resolution
|
||||||
) do
|
) do
|
||||||
# See https://github.com/absinthe-graphql/absinthe/issues/490
|
# See https://github.com/absinthe-graphql/absinthe/issues/490
|
||||||
with args <- Map.put(args, :options, args[:options] || %{}),
|
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"
|
assert hd(json_response(res, 200)["errors"])["message"] == "Event not found"
|
||||||
end
|
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,
|
conn: conn,
|
||||||
actor: _actor,
|
actor: _actor,
|
||||||
user: user
|
user: user
|
||||||
|
|
Loading…
Reference in a new issue