Visibility of issue context panel

Can visibility of Issue Context Panel be based on some resolver function?

Hi, you can try pass the context as a parameter when invoking the resolver.

Could you elaborate? I do not mean displaying/hiding content in panel based on context, but hiding the entire panel based on context and functions.

Here is an example of fetching the context from the project and a custom UI app, and passing it to the Resolver.

App.tsx

import React, { useEffect, useState } from 'react';
import { invoke, view } from '@forge/bridge';
import { FullContext } from '@forge/bridge/out/types';

function App() {

    const [data, setData] = useState<any>(null);
    
    const [context, setContext] = useState<FullContext>();

    useEffect(() => {
		view.getContext().then((res) => setContext(res));
	}, [view]);

    useEffect(() => {
        invoke('getIssues', { project: context?.extension?.project }).then(setData);
      }, [context]);
    
    return (
        <div>
            {data ? data.toString(): 'Loading...'}
        </div>
    );
}

export default App;

uiResolver.ts

import Resolver from '@forge/resolver';
import fetchAllIssues from './issues/issueSearch';
import { IIssue } from 'issues/types/issue';
const resolver = new Resolver();

resolver.define('getIssues',async (request) => {
    let issues: IIssue []

    if (!request?.payload?.project){
        console.warn("No projects ")
        return []
    }
    console.info(request)
    const jql = `project in(${request?.payload?.project.key})`
    try{
        issues = await fetchAllIssues(jql)
        return JSON.stringify(issues) ;
    }catch (error){
        console.error('Error fetching issues: ', error)
        return []
    }   
});
export const handler = resolver.getDefinitions();
1 Like

Thank you for your effort and response. This is exactly what I didn’t want to achieve.

1 Like