New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@forge/ui-confluence

Package Overview
Dependencies
Maintainers
0
Versions
388
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/ui-confluence

Helpers for interacting with Confluence

  • 14.0.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

forge-ui-confluence

A package of helpers for interacting with Confluence

content-properties

Allows interacting with Confluence content properties.

Note permissions apply to interacting with content properties, for the page being accessed. So it is impacted by the user being used to interact with Confluence (is app or request user).

Example usage:

import Forge, { render, Fragment, Text, Button, useAction, useProductContext } from "@forge/ui";
import { contentProperties } from '@atlasian/forge-ui-confluence';

export type AppState = {
    count: number;
}

const KEY_PREFIX = 'counter';

const App = () => {
    const { contentId, localId } = useProductContext(); 
    const contentProps = contentProperties(contentId, api.asApp().requestConfluence);

    const key = `${KEY_PREFIX}-${localId}`;

    const initialAppState = async (): Promise<AppState> => {
        const countProp = await contentProps.read(key);
        const count: number = countProp && (countProp.value as number) || 0;
        return {
            count,
        };
    }

    const updateCount = async (oldState: AppState, action: string): Promise<AppState> => {
        switch (action) {
            case 'modify':
                await contentProps.modify(key, (prev) => ((prev as number || 0) + 1));
                return initialAppState();
            case 'replace':
                await contentProps.replace(key, oldState.count + 1);
                return initialAppState();
            case 'delete':
                await contentProps.delete(key);
                return initialAppState();
            case 'refresh':
                return initialAppState();
        }
        return oldState;
    }

    const [appState, doAction] = useAction<AppState, string>(updateCount, initialAppState);
    
    return (
        <Fragment>
            <Text>Current value {appState.count}</Text>
            <Button text="Add one (modify)" onClick={() => { doAction('modify'); }} />
            <Button text="Add one (replace)" onClick={() => { doAction('replace'); }} />
            <Button text="Reset data (delete)" onClick={() => { doAction('delete'); }} />
            <Button text="Refresh (read)" onClick={() => { doAction('refresh'); }} />
        </Fragment>
    );
};

export const run = render(<App />);

FAQs

Package last updated on 11 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc