Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public OnboardingState get() {
@PUT
@Path("/dismiss")
@AuditEvent(type = OnboardingAuditEventTypes.ONBOARDING_DISMISSED)
@Operation(summary = "Update onboarding status")
@Operation(summary = "Dismiss onboarding")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Updated onboarding status"),
@ApiResponse(responseCode = "400", description = "Bad request, illegal status value")
Expand All @@ -78,4 +78,17 @@ public OnboardingState get() {
public void dismiss() {
clusterConfigService.write(new OnboardingState(OnboardingStatus.DISMISSED));
}

@PUT
@Path("/finish")
@AuditEvent(type = OnboardingAuditEventTypes.ONBOARDING_DISMISSED)
@Operation(summary = "Finish onboarding")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Updated onboarding status"),
@ApiResponse(responseCode = "400", description = "Bad request, illegal status value")
})
@RequiresPermissions(RestPermissions.CLUSTER_CONFIG_ENTRY_EDIT)
public void finish() {
clusterConfigService.write(new OnboardingState(OnboardingStatus.FINISHED));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { Onboarding } from '@graylog/server-api';

import { ONBOARDING_ELIGIBILITY_QUERY_KEY } from './useOnboardingEligibility';

// TODO: Replace with a real backend call once the dismiss endpoint exists.
const dismissOnboarding = () => Onboarding.dismiss();

const useDismissOnboarding = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { Onboarding } from '@graylog/server-api';

import { ONBOARDING_ELIGIBILITY_QUERY_KEY } from './useOnboardingEligibility';

const finishOnboarding = () => Onboarding.finish();

const useFinishOnboarding = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: finishOnboarding,
onSuccess: () => queryClient.invalidateQueries({ queryKey: ONBOARDING_ELIGIBILITY_QUERY_KEY }),
});
};

export default useFinishOnboarding;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { Onboarding } from '@graylog/server-api';

export const ONBOARDING_ELIGIBILITY_QUERY_KEY = ['onboarding', 'eligibility'];

// TODO: Replace with a real backend call once the eligibility endpoint exists.
const fetchOnboardingEligibility = () => Onboarding.get();

const useOnboardingEligibility = (enabled: boolean = true) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,24 @@ import { extractErrorMessage } from 'util/extractErrorMessage';
import useDefaultInterval from 'views/hooks/useDefaultIntervalForRefresh';
import useHistory from 'routing/useHistory';
import UserNotification from 'util/UserNotification';
import useFinishOnboarding from 'components/welcome/hooks/useFinishOnboarding';

const CollectorsOnboardingInstancePage = () => {
const { instanceUid } = useParams<{ instanceUid: string }>();
const history = useHistory();

const { data: instance, isLoading, error } = useInstance(instanceUid);
const defaultInterval = useDefaultInterval();
const { mutate: finish } = useFinishOnboarding();

// using useEffect to guard that the default is actually there when we call the navigate
useEffect(() => {
if (instance && defaultInterval) {
finish();
history.push(collectorReceivedMessagesUrl(COLLECTOR_INSTANCE_UID_FIELD, instance.instance_uid, defaultInterval));
UserNotification.success('Collector connected successfully! Showing received messages ...');
}
}, [defaultInterval, instance, history]);
}, [defaultInterval, instance, history, finish]);

const content = () => {
if (isLoading) return <Spinner />;
Expand Down
Loading