Skip to content

Commit

Permalink
Merge release-6.x into master (#7692)
Browse files Browse the repository at this point in the history
* RG-2293 Get rid of side effects in setState updater function of Select component (#7574)

* 6.0.50

* RG-2462 switch sidebar and main background in dark theme (#7565)

(cherry picked from commit 647dd76)

* 6.0.51

* Support passing theme down via React Context (#7592)

* 6.0.52

* RG-2420 chore: undeprecate "Badge" in 6.x version

* Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]

* 6.0.53

* JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554 (#7637)

* RG-2473 don't unmount react root because it can be reused later (#7656)

minor: log auth error

* 6.0.54

* Revert "JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554"

This reverts commit 9192646.

* 6.0.55

* Put page reload in timeout for USER_CHANGED event to let all other events to be called. JT-83975 related

* 6.0.56

* Chore: add example with dialog with close button inside

* Revert "RG-2420 chore: undeprecate "Badge" in 6.x version"

This reverts commit 580369f.

---------

Co-authored-by: Veniamin Krol <[email protected]>
Co-authored-by: JetBrains Ring UI Automation <[email protected]>
  • Loading branch information
3 people authored Sep 4, 2024
1 parent 13cb4ab commit 835b07b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/auth/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,26 @@ describe('Auth', () => {
});

it('should perform redirect on userChange by default', () => {
const clock = sandbox.useFakeTimers({toFake: ['setTimeout']});
sandbox.stub(Auth.prototype, '_redirectCurrentPage');

const auth = new Auth({serverUri: ''});
auth.listeners.trigger(USER_CHANGED_EVENT);
clock.tick(0);

Auth.prototype._redirectCurrentPage.should.have.been.called;
});

it('should not perform redirect on userChange when reloadOnUserChange is false', () => {
const clock = sandbox.useFakeTimers({toFake: ['setTimeout']});
sandbox.stub(Auth.prototype, '_redirectCurrentPage');

const auth = new Auth({
reloadOnUserChange: false,
serverUri: ''
});
auth.listeners.trigger(USER_CHANGED_EVENT);
clock.tick(0);

Auth.prototype._redirectCurrentPage.should.not.been.called;
});
Expand Down Expand Up @@ -561,12 +565,6 @@ describe('Auth', () => {
'token'.should.be.equal(accessToken);
});

it('should reload page if user change was applied', () => {
auth.user = {id: 'initUser'} as AuthUser;
auth.listeners.trigger(USER_CHANGED_EVENT);
Auth.prototype._redirectCurrentPage.should.have.been.calledWith(window.location.href);
});

it('should redirect current page if get token in iframe fails', async () => {
auth.config.embeddedLogin = false;
if (auth._backgroundFlow != null) {
Expand Down
5 changes: 4 additions & 1 deletion src/auth/auth__core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ export default class Auth implements HTTPAuth {
}

if (this.config.reloadOnUserChange) {
this.addListener(USER_CHANGED_EVENT, () => this._reloadCurrentPage());
this.addListener(USER_CHANGED_EVENT, () => {
// Timeout is needed to ensure all other listeners triggered before stopping current page
setTimeout(() => this._reloadCurrentPage());
});
}

this.addListener(LOGOUT_POSTPONED_EVENT, () => this._setPostponed(true));
Expand Down
56 changes: 56 additions & 0 deletions src/dialog/dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,62 @@ basic.parameters = {
</style>`
};


export const withCloseButtonInside: StoryFn<Args> = ({onAction}) => {
class DialogDemo extends Component {
state = {
show: true,
text: ''
};

doAction = () => {
onAction(`${this.state.text} performed`);
this.setState({show: false});
};

cancelDialog = () => {
this.setState({show: false});
};

render() {
const {show, text} = this.state;
return (
<Dialog
label="Dialog"
show={show}
onCloseAttempt={this.cancelDialog}
trapFocus
showCloseButton
closeButtonInside
>
<Header>Dialog title</Header>
<Content>
<Input
label="Enter action name"
value={text}
onChange={e => this.setState({text: e.target.value})}
/>
</Content>
<Panel>
<Button primary onClick={this.doAction}>
OK
</Button>
<Button onClick={this.cancelDialog}>Cancel</Button>
</Panel>
</Dialog>
);
}
}
return <DialogDemo/>;
};

withCloseButtonInside.storyName = 'with close button inside';
withCloseButtonInside.argTypes = {onAction: {}};

withCloseButtonInside.parameters = {
screenshots: {skip: true}
};

export const native: StoryFn<Args> = ({onAction}) => {
class DialogDemo extends Component {
state = {
Expand Down

0 comments on commit 835b07b

Please sign in to comment.