Skip to content

Commit

Permalink
Switch to new tenant after loading a copied long URL (opensearch-proj…
Browse files Browse the repository at this point in the history
…ect#1450)

* Replace legacy template with index template (opensearch-project#1359)

Signed-off-by: Chang Liu <lc12251109@gmail.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* added loginEndPointWithPath (opensearch-project#1358)

* added loginEndPointWithPath
Signed-off-by: Mattijs Vanhaverbeke <mattijs-v@live.be>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Add release notes for 1.3.9 (opensearch-project#1379)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* No blank backend role before adding a new one in Create User page (opensearch-project#1384)

* Add last backend role empty check

Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

* Add backend role empty check

Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

* Add strict comparison

Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

* Fix lint errors

Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

* Add tests for backend role panel

Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

* Fix lint errors

Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>

---------

Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>
Co-authored-by: nursaadat <SNursultan@dar.kz>
Co-authored-by: Saadat Nursultan <nursultan.saadat@gmail.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Fix script for Windows (opensearch-project#1393)

* Fix script for Windows

Signed-off-by: nurbqq <nurbakhyt.sembayev@gmail.com>
Signed-off-by: nurbqq <106753054+nurbq@users.noreply.github.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding new actions for ppl and datasource apis (opensearch-project#1395)

* Adding new actions for ppl and datasource apis

Signed-off-by: vamsi-amazon <reddyvam@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Fix "Get started" image is not adaptive to the browser window size. (opensearch-project#1396)

* Fixed get-started page image not adapting to the browser window size

Signed-off-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>

* Update fix by applying suggested changes

Signed-off-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>

* Update unit tests snapshot

Signed-off-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>

---------

Signed-off-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Split up a value into multiple cookie payloads (opensearch-project#1352)

* PoC for splitting up a value into multiple cookie payloads

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* Cookie splitting for OpenId and SAML

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* Changes after review comments

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* WIP: First unit tests

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* More unit tests

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* Fix for multi auth, request argument was missing

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* Fixed linting errors

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

* Added one additional cookie for the SAML integration tests

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>

---------

Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Dynamic tenancy configurations (opensearch-project#1394)

* Dynamic multitenancy feature.

Signed-off-by: Abhi Kalra <abhivka@amazon.com>

* Dynamic multitenancy feature -PR feedback

Signed-off-by: Abhi Kalra <abhivka@amazon.com>

---------

Signed-off-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Abhi Kalra <abhivka@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Add release notes for 2.7.0 (opensearch-project#1407)

* Add release notes for 2.7.0

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removes tiny.amazon.com links (opensearch-project#1420)

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Fixing dynamic tenancy changes for issues 1412 (opensearch-project#1419)

* Fixing dynamic tenancy changes for opensearchdasbhoard.yaml

Signed-off-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Change the testuser's password in some integration test cases into a stronger password (opensearch-project#1428)

* Change the testuser's password into a stronger password

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Increment version to 3.0.0.0 (opensearch-project#1414)

Signed-off-by: opensearch-ci-bot <opensearch-infra@amazon.com>
Co-authored-by: opensearch-ci-bot <opensearch-infra@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adds the newly created admin api permissions to the static dropdown list (opensearch-project#1426)

* Adds the newly created admin api permissions to the static dropdown of permissions displayed when creating/modifying a role

---------

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Update account-nav-button.tsx

Fix added to set the window.location to the pathname, rather than just reload & clear lastURL as it would be from the previous tenant.

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Update account-nav-button.tsx

Adding comments to explain changes

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* add new cluster permissions constants for lron (opensearch-project#1444)

Signed-off-by: zhichao-aws <zhichaog@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* removing whitespace due to linting fix

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests for account-nav-button wip

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* put commented code to original state

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Skip flaky SAML test as it awaits a fix (opensearch-project#1453)

Signed-off-by: Craig Perkins <craig5008@gmail.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Use version from package.json for integration tests (opensearch-project#1463)

* Use version from package.json for integration tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adds 2.8 release notes (opensearch-project#1464)

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Co-authored-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests to jest test for tenant switch. Putting test in correct folder and renaming function.
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* handle switch calling correct function

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* checking for session storage
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* adding window to make sessionStorage more explicit

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Moved the test into account-nav-button.test.tsx

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing additional files.

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Declared session storage as a constant

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Update account-nav-button.tsx

Fix added to set the window.location to the pathname, rather than just reload & clear lastURL as it would be from the previous tenant.

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Update account-nav-button.tsx

Adding comments to explain changes

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* removing whitespace due to linting fix

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests for account-nav-button wip

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* put commented code to original state

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests to jest test for tenant switch. Putting test in correct folder and renaming function.
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* handle switch calling correct function

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing additional files.

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Fix unwanted changes

Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Update account-nav-button.tsx

Fix added to set the window.location to the pathname, rather than just reload & clear lastURL as it would be from the previous tenant.

Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests for account-nav-button wip

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests to jest test for tenant switch. Putting test in correct folder and renaming function.
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* checking for session storage
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Declared session storage as a constant

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests for account-nav-button wip

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Adding tests to jest test for tenant switch. Putting test in correct folder and renaming function.
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Moved the test into account-nav-button.test.tsx

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Dynamic tenancy configurations (opensearch-project#1394)

* Dynamic multitenancy feature.

Signed-off-by: Abhi Kalra <abhivka@amazon.com>

* Dynamic multitenancy feature -PR feedback

Signed-off-by: Abhi Kalra <abhivka@amazon.com>

---------

Signed-off-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Abhi Kalra <abhivka@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Fixing dynamic tenancy changes for issues 1412 (opensearch-project#1419)

* Fixing dynamic tenancy changes for opensearchdasbhoard.yaml

Signed-off-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing Prerequisite Checks Workflow (opensearch-project#1456)

Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Use version from package.json for integration tests (opensearch-project#1463)

* Use version from package.json for integration tests

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

* Removing unneded file

Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>

---------

Signed-off-by: Chang Liu <lc12251109@gmail.com>
Signed-off-by: leanneeliatra <leanne.laceybyrne@eliatra.com>
Signed-off-by: Ryan Liang <jiallian@amazon.com>
Signed-off-by: nursaadat <SNursultan@dar.kz>
Signed-off-by: Saadat Nursultan <nursultan.saadat@gmail.com>
Signed-off-by: nurbqq <nurbakhyt.sembayev@gmail.com>
Signed-off-by: nurbqq <106753054+nurbq@users.noreply.github.com>
Signed-off-by: vamsi-amazon <reddyvam@amazon.com>
Signed-off-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>
Signed-off-by: Jochen Kressin <jochen.kressin-gh@eliatra.com>
Signed-off-by: Abhi Kalra <abhivka@amazon.com>
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
Signed-off-by: opensearch-ci-bot <opensearch-infra@amazon.com>
Signed-off-by: Leanne Lacey-Byrne <leanne.laceybyrne@eliatra.com>
Signed-off-by: zhichao-aws <zhichaog@amazon.com>
Signed-off-by: Craig Perkins <craig5008@gmail.com>
Signed-off-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Co-authored-by: Chang Liu <lc12251109@gmail.com>
Co-authored-by: mattieserver <3049868+mattieserver@users.noreply.github.com>
Co-authored-by: Ryan Liang <109499885+RyanL1997@users.noreply.github.com>
Co-authored-by: Saadat Nursultan <39532643+nurSaadat@users.noreply.github.com>
Co-authored-by: nursaadat <SNursultan@dar.kz>
Co-authored-by: Saadat Nursultan <nursultan.saadat@gmail.com>
Co-authored-by: Nurbakhyt Sembayev <106753054+nurbq@users.noreply.github.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Co-authored-by: Vamsi Manohar <reddyvam@amazon.com>
Co-authored-by: Sirazh Gabdullin <sirazh.gabdullin@nu.edu.kz>
Co-authored-by: Jochen Kressin <126353411+jochen-kressin@users.noreply.github.com>
Co-authored-by: Abhi Kalra <99718513+abhivka7@users.noreply.github.com>
Co-authored-by: Abhi Kalra <abhivka@amazon.com>
Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: opensearch-ci-bot <opensearch-infra@amazon.com>
Co-authored-by: zhichao-aws <zhichaog@amazon.com>
Co-authored-by: Craig Perkins <cwperx@amazon.com>
Co-authored-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
20 people authored Jun 19, 2023
1 parent 497c7f1 commit 7f4e0f2
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 2 deletions.
23 changes: 22 additions & 1 deletion public/apps/account/account-nav-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function AccountNavButton(props: {
}}
handleSwitchAndClose={() => {
setModal(null);
window.location.reload();
reloadAfterTenantSwitch();
}}
tenant={props.tenant!}
/>
Expand Down Expand Up @@ -186,3 +186,24 @@ export function AccountNavButton(props: {
</EuiHeaderSectionItemButton>
);
}

export function reloadAfterTenantSwitch(): void {
// the below portion is to clear URLs starting with 'lastUrl'
// when switching tenants, the last URLs will be from the old tenancy therefore we need to remove these from sessionStorage.
const lastUrls = [];
const { sessionStorage } = window;

for (let i = 0; i < sessionStorage.length; i++) {
const key = sessionStorage.key(i);
if (key?.startsWith('lastUrl')) {
lastUrls.push(key);
}
}
for (let i = 0; i < lastUrls.length; i++) {
sessionStorage.removeItem(lastUrls[i]);
}

// rather than just reload when we switch tenants, we set the URL to the pathname. i.e. the portion like: '/app/dashboards'
// therefore, the copied URL will now allow tenancy changes.
window.location.href = window.location.pathname;
}
59 changes: 58 additions & 1 deletion public/apps/account/test/account-nav-button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { shallow } from 'enzyme';
import React from 'react';
import { AccountNavButton } from '../account-nav-button';
import { AccountNavButton, reloadAfterTenantSwitch } from '../account-nav-button';
import { getShouldShowTenantPopup, setShouldShowTenantPopup } from '../../../utils/storage-utils';
import { getDashboardsInfo } from '../../../utils/dashboards-info-utils';

Expand Down Expand Up @@ -174,3 +174,60 @@ describe('Account navigation button, multitenancy disabled', () => {
expect(setState).toBeCalledTimes(0);
});
});

describe('Reload window after tenant switch', () => {
const originalLocation = window.location;
const mockSetWindowHref = jest.fn();
let pathname: string = '';
beforeAll(() => {
pathname = '/app/myapp';
Object.defineProperty(window, 'location', {
value: {
get pathname() {
return pathname;
},
get href() {
return '/app/dashboards?security_tenant=admin_tenant';
},
set href(value: string) {
mockSetWindowHref(value);
},
},
});
});

afterAll(() => {
window.location = originalLocation;
});

it('should remove the tenant query parameter before reloading', () => {
pathname = '/app/pathname-only';
reloadAfterTenantSwitch();
expect(mockSetWindowHref).toHaveBeenCalledWith(pathname);
});
});

describe('Clear lastUrls after tenant switch', () => {
afterAll(() => {
jest.clearAllMocks();
});

it('should clear out keys with a lastUrl prefix', () => {
window.sessionStorage.setItem('lastUrl:dashboard', '/dashboard1');
window.sessionStorage.setItem('lastUrl:otherApp', '/otherApp');
window.sessionStorage.setItem('somethingElse:here', '/random');
const mockRemoveItem = jest.spyOn(Object.getPrototypeOf(window.sessionStorage), 'removeItem');
reloadAfterTenantSwitch();
expect(mockRemoveItem).toHaveBeenCalledWith('lastUrl:dashboard');
expect(mockRemoveItem).toHaveBeenCalledWith('lastUrl:otherApp');
expect(mockRemoveItem).toHaveBeenCalledTimes(2);
});

it('should not clear out keys without a lastUrl prefix', () => {
window.sessionStorage.setItem('somethingElse:here', '/random');
const mockRemoveItem = jest.spyOn(Object.getPrototypeOf(window.sessionStorage), 'removeItem');

reloadAfterTenantSwitch();
expect(mockRemoveItem).toHaveBeenCalledTimes(0);
});
});
73 changes: 73 additions & 0 deletions public/apps/account/test/switch-tenants.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright OpenSearch Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

import { reloadAfterTenantSwitch } from '../account-nav-button';

describe('Reload window after tenant switch', () => {
const originalLocation = window.location;
const mockSetWindowHref = jest.fn();
let pathname: string = '';
beforeAll(() => {
pathname = '/app/myapp';
Object.defineProperty(window, 'location', {
value: {
get pathname() {
return pathname;
},
get href() {
return '/app/dashboards?security_tenant=admin_tenant';
},
set href(value: string) {
mockSetWindowHref(value);
},
},
});
});

afterAll(() => {
window.location = originalLocation;
});

it('should remove the tenant query parameter before reloading', () => {
pathname = '/app/pathname-only';
reloadAfterTenantSwitch();
expect(mockSetWindowHref).toHaveBeenCalledWith(pathname);
});
});

describe('Clear lastUrls after tenant switch', () => {
afterAll(() => {
jest.clearAllMocks();
});

it('should clear out keys with a lastUrl prefix', () => {
window.sessionStorage.setItem('lastUrl:dashboard', '/dashboard1');
window.sessionStorage.setItem('lastUrl:otherApp', '/otherApp');
window.sessionStorage.setItem('somethingElse:here', '/random');
const mockRemoveItem = jest.spyOn(Object.getPrototypeOf(window.sessionStorage), 'removeItem');
reloadAfterTenantSwitch();
expect(mockRemoveItem).toHaveBeenCalledWith('lastUrl:dashboard');
expect(mockRemoveItem).toHaveBeenCalledWith('lastUrl:otherApp');
expect(mockRemoveItem).toHaveBeenCalledTimes(2);
});

it('should not clear out keys without a lastUrl prefix', () => {
window.sessionStorage.setItem('somethingElse:here', '/random');
const mockRemoveItem = jest.spyOn(Object.getPrototypeOf(window.sessionStorage), 'removeItem');

reloadAfterTenantSwitch();
expect(mockRemoveItem).toHaveBeenCalledTimes(0);
});
});

0 comments on commit 7f4e0f2

Please sign in to comment.