How to use the @webiny/app-admin/hooks/useSnackbar.useSnackbar function in @webiny/app-admin

To help you get started, we’ve selected a few @webiny/app-admin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / app-page-builder / src / admin / plugins / pageDetails / utils / usePublishRevisionHandler.js View on Github external
export function usePublishRevisionHandler({ page }) {
    const client = useApolloClient();
    const { showSnackbar } = useSnackbar();

    const publishRevision = async revision => {
        const { data: res } = await client.mutate({
            mutation: PUBLISH_REVISION,
            variables: { id: revision.id },
            refetchQueries: ["PbListPages"],
            update: (cache, { data }) => {
                // Don't do anything if there was an error during publishing!
                if (data.pageBuilder.publishRevision.error) {
                    return;
                }

                const getPageQuery = GET_PAGE();

                // Update revisions
                const pageFromCache = cache.readQuery({
github webiny / webiny-js / packages / app-admin / src / components / FileManager / FileDetails / Name.js View on Github external
function Name({ file }: *) {
    const [editing, setEdit] = useState(false);
    const name = file.name || "";

    const { showSnackbar } = useSnackbar();
    const client = useApolloClient();

    const { queryParams } = useFileManager();

    if (editing) {
        return (
            <form name=""> {
                    setEdit(false);
                    await client.mutate({
                        mutation: UPDATE_FILE,
                        variables: {
                            id: file.id,</form>
github webiny / webiny-js / packages / app-admin / src / components / FileManager / FileDetails.js View on Github external
const { file, uploadFile, validateFiles } = props;
    const filePlugin = getFileTypePlugin(file);
    const actions = get(filePlugin, "fileDetails.actions") || [];

    const { hideFileDetails } = useFileManager();

    useHotkeys({
        zIndex: 55,
        disabled: !file,
        keys: {
            esc: hideFileDetails
        }
    });

    const [deleteFile] = useMutation(DELETE_FILE, { refetchQueries: ["ListFiles"] });
    const { showSnackbar } = useSnackbar();

    const fileDeleteConfirmationProps = {
        title: t`Delete file`,
        message: file &amp;&amp; (
            <span>
                {t`You're about to delete file {name}. Are you sure you want to continue?`({
                    name: file.name
                })}
            </span>
        )
    };

    return (
        
            {file &amp;&amp; (
                <div dir="ltr"></div>
github webiny / webiny-js / packages / app-page-builder / src / admin / plugins / pageDetails / pageRevisions / useRevisionHandlers.js View on Github external
export function useRevisionHandlers({ rev }) {
    const { showSnackbar } = useSnackbar();
    const { history } = useReactRouter();
    const client = useApolloClient();
    const { page } = usePageDetails();
    const { publishRevision } = usePublishRevisionHandler({ page });

    const createRevision = useCallback(async () => {
        const { data: res } = await client.mutate({
            mutation: CREATE_REVISION_FORM,
            variables: { revision: rev.id },
            refetchQueries: ["PbListPages"],
            awaitRefetchQueries: true
        });
        const { data, error } = res.pageBuilder.revision;

        if (error) {
            return showSnackbar(error.message);
github webiny / webiny-js / packages / app-admin / src / components / FileManager / FileManagerView.js View on Github external
const {
        selected,
        toggleSelected,
        dragging,
        setDragging,
        uploading,
        setUploading,
        showFileDetails,
        showingFileDetails,
        queryParams,
        setQueryParams,
        hasPreviouslyUploadedFiles,
        setHasPreviouslyUploadedFiles
    } = useFileManager();

    const { showSnackbar } = useSnackbar();

    const searchOnChange = useCallback(debounce(search => setQueryParams({ search }), 500), []);

    const toggleTag = useCallback(async ({ tag, queryParams }) => {
        const finalTags = Array.isArray(queryParams.tags) ? [...queryParams.tags] : [];

        if (finalTags.includes(tag)) {
            finalTags.splice(finalTags.indexOf(tag), 1);
        } else {
            finalTags.push(tag);
        }

        setQueryParams({ ...queryParams, tags: finalTags });
    }, []);

    const refreshOnScroll = useCallback(
github webiny / webiny-js / packages / app-admin / src / components / FileManager / FileDetails / Tags.js View on Github external
function Tags({ file }) {
    const client = useApolloClient();

    const [editing, setEdit] = useState(false);
    const [saving, setSaving] = useState(false);
    const initialTags = Array.isArray(file.tags) ? [...file.tags] : [];
    const [currentTags, setCurrentTags] = useState(initialTags);
    const { showSnackbar } = useSnackbar();

    const { queryParams } = useFileManager();

    if (editing) {
        return (
            &lt;&gt;
                 {
                            setSaving(true);
                            client
                                .mutate({
                                    mutation: UPDATE_FILE,
                                    variables: {

@webiny/app-admin

A collection of plugins that together form a complete admin interface, customizable and extensible with Webiny apps and plugins.

MIT
Latest version published 2 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages