I would like to have a button that opens a link in a new page, but I always get an error on forge deploy command.
I did npm install, the bridge folder and its files are existing in the path where they should.
Error: Bundling failed: ./src/index.jsx
Module not found: Error: Can’t resolve ‘@forge/bridge’ in ‘D:\jiraApps\memoQIntegration\src’
resolve ‘@forge/bridge’ in ‘D:\jiraApps\memoQIntegration\src’
Parsed request is a module
using description file: D:\jiraApps\memoQIntegration\package.json (relative path: ./src)
Field ‘browser’ doesn’t contain a valid alias configuration
resolve as module
D:\jiraApps\memoQIntegration\src\node_modules doesn’t exist or is not a directory
D:\jiraApps\node_modules doesn’t exist or is not a directory
D:\node_modules doesn’t exist or is not a directory
looking for modules in D:\jiraApps\memoQIntegration\node_modules
using description file: D:\jiraApps\memoQIntegration\package.json (relative path: ./node_modules)
Field ‘browser’ doesn’t contain a valid alias configuration
using description file: D:\jiraApps\memoQIntegration\node_modules@forge\bridge\package.json (relative path: .)
no extension
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge is not a file
.ts
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge.ts doesn’t exist
.tsx
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge.tsx doesn’t exist
.js
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge.js doesn’t exist
.jsx
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge.jsx doesn’t exist
.json
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge.json doesn’t exist
as directory
existing directory
using path: D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index
using description file: D:\jiraApps\memoQIntegration\node_modules@forge\bridge\package.json (relative path: ./index)
no extension
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index doesn’t exist
.ts
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index.ts doesn’t exist
.tsx
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index.tsx doesn’t exist
.js
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index.js doesn’t exist
.jsx
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index.jsx doesn’t exist
.json
Field ‘browser’ doesn’t contain a valid alias configuration
D:\jiraApps\memoQIntegration\node_modules@forge\bridge\index.json doesn’t exist
[D:\jiraApps\memoQIntegration\src\node_modules]
[D:\jiraApps\node_modules]
[D:\node_modules]
[D:\jiraApps\memoQIntegration\node_modules@forge\bridge]
[D:\jiraApps\memoQIntegration\node_modules@forge\bridge.ts]
[D:\jiraApps\memoQIntegration\node_modules@forge\bridge.tsx]
[D:\jiraApps\memoQIntegration\node_modules@forge\bridge.js]
@MichalMichalczuk thank you for help, here are the files
Package.json:
{
"name": "forge-ui-starter",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"scripts": {
"lint": "./node_modules/.bin/eslint src/**/* || npm run --silent hook-errors",
"hook-errors": "echo '\\x1b[31mThe build failed because a Forge UI hook is being used incorrectly. Forge UI hooks follow the same rules as React Hooks but have their own API definitions. See the Forge documentation for details on how to use Forge UI hooks.\n' && exit 1"
},
"devDependencies": {
"eslint": "^6.5.1",
"eslint-plugin-react-hooks": "^2.1.2"
},
"dependencies": {
"@forge/api": "^1.1.0",
"@forge/bridge": "^1.4.0",
"@forge/ui": "^0.9.0",
"global": "^4.4.0",
"node-forge": "^0.10.0",
"rm": "^0.1.8"
}
}
@MichalMichalczuk ,
Thank you so much!
May I ask, if there is a simple sample about how to define a button with a custom URL?
The rest of our integration will be done in an aspx external page, I just pass the ID and title in the URL what the button sends.
In stand alone jira it was worked, but as cloud doesn’t accept the jar file I generated, I have to rewrite this simple button.
Then npm i @forge/bridge in your static folder.
And you can use it as below.
(please make sure you have new version of @forge/brige )
import { router } from '@forge/bridge';
import Button from '@atlaskit/button';
// then in your component, to open in new tab
<Button onClick={() => router.open('https://atlassian.com')}>🔗 go to Atlassian.com</Button>
// then in your component, to navigate page
<Button onClick={() => router.navigate('https://atlassian.com')}>🔗 go to Atlassian.com</Button>
Hope that helped
PS You don’t have to use React, in your case it sounds like plain static HTML + a bit of JS is enough.
Just a tiny thing, you must import the button like this:
import Button from ‘@atlaskit/button’;
because the button not exported, I just found a solution by googleing a bit
Thank you so much!
May I have a bit dumb question, but which is my component file, I really went through the sample of custom UI, but I didn’t find out this.?
The App.js?
Hi @MichalMichalczuk ,
I’m using also router functions inside a Confluence Custom UI macro.
I got the experience that a popup first ask for permission when having an external URL (like https://google.com).
Also in the browser console appears: Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
If I confirm this (click Continue) it opens this in a new tab :-), but in the current tab with my macro this looks like this:
Do I something wrong or is there a chance to avoid this?
The prompt with warning is intended, we’d like to inform our users that they will navigate somewhere outside product - to cut out abuses (like some extension send user to page which look like Jira but would like to steal your password )
But - if you’d like to use relative url (and navigate to other page on Jira on Confluence instance) user won’t get prompted with this popup (since they’re not leaving product)
Thank you, but I am not sure I understand, if I use ${issue.key} it will applied as a string.
To give you more understanding, in XML I had the following webitem:
But the issueKey variable still empty, there is a documentation about what holds the context and how to retrieve it’s data? If I open the console, Jira drops a ton of warnings so I can’t track them