-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nav bar item to show HCP link status and encourage folks to link (#…
…20370) * Convert consul-hcp to a simpler component * update existing test to use envStub helper * An hcp link item for the navbar * A method of linking to HCP * Hook up fetching linking status to the nav-item * Hooking up fetching link status to the hcp link friend * Adding some tests * remove a comment - but also fix padding justify-content * Fix the banner tests * Adding permission tests as well * some more sane formatting * Rename function with its now multipurpose use * Feature change: No more NEW Badge since it breaks padding - instead a linked badge * Removing unused class
- Loading branch information
Showing
12 changed files
with
423 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import BaseAbility from './base'; | ||
|
||
export default class OperatorAbility extends BaseAbility { | ||
resource = 'operator'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
ui/packages/consul-ui/app/helpers/hcp-resource-id-to-link.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import Helper from '@ember/component/helper'; | ||
|
||
/** | ||
* A resourceId Looks like: | ||
* organization/b4432207-bb9c-438e-a160-b98923efa979/project/4b09958c-fa91-43ab-8029-eb28d8cee9d4/hashicorp.consul.global-network-manager.cluster/test-from-api | ||
* organization/${organizationId}/project/${projectId}/hashicorp.consul.global-network-manager.cluster/${clusterName} | ||
* | ||
* A HCP URL looks like: | ||
* https://portal.hcp.dev/services/consul/clusters/self-managed/test-from-api?project_id=4b09958c-fa91-43ab-8029-eb28d8cee9d4 | ||
* ${HCP_PREFIX}/${clusterName}?project_id=${projectId} | ||
*/ | ||
export const HCP_PREFIX = | ||
'https://portal.cloud.hashicorp.com/services/consul/clusters/self-managed'; | ||
export default class hcpResourceIdToLink extends Helper { | ||
// TODO: How can we figure out different HCP environments? | ||
compute([resourceId], hash) { | ||
let url = HCP_PREFIX; | ||
// Array looks like: ["organization", organizationId, "project", projectId, "hashicorp.consul.global-network-manager.cluster", "Cluster Id"] | ||
const [, , , projectId, , clusterName] = resourceId.split('/'); | ||
if (!projectId || !clusterName) { | ||
return ''; | ||
} | ||
|
||
url += `/${clusterName}?project_id=${projectId}`; | ||
return url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
{ | ||
"status": { | ||
"consul.io/hcp/link": { | ||
"conditions": [ | ||
{ | ||
"message": "Successfully linked to cluster 'organization/f53e5646-6529-4698-ae29-d74f8bd22a01/project/6994bb7a-5561-4d5c-8bb0-cf40177e5b77/hashicorp.consul.global-network-manager.cluster/mkam-vm'", | ||
"reason": "SUCCESS", | ||
"state": "STATE_FALSE", | ||
"type": "linked" | ||
} | ||
], | ||
"observedGeneration":"01HMA2VPHVKNF6QR8TD07KDN5K", | ||
"updatedAt":"2024-01-16T21:29:25.923140Z" | ||
} | ||
"data": { | ||
"clientId": "5wZyAPvDFbgDdO3439m8tufwO9hElphu", | ||
"clientSecret": "SWX0XShcp3doc7RF8YCjJ-WATyeMAjFaf1eA0mnzlNHLF4IXbFz6xyjSZvHzAR_i", | ||
"resourceId": "organization/b4432207-bb9c-438e-a160-b98923efa979/project/4b09958c-fa91-43ab-8029-eb28d8cee9d4/hashicorp.consul.global-network-manager.cluster/test-from-api" | ||
}, | ||
"status": { | ||
"consul.io/hcp/link": { | ||
"conditions": [ | ||
{ | ||
"message": "Successfully linked to cluster 'organization/f53e5646-6529-4698-ae29-d74f8bd22a01/project/6994bb7a-5561-4d5c-8bb0-cf40177e5b77/hashicorp.consul.global-network-manager.cluster/mkam-vm'", | ||
"reason": "SUCCESS", | ||
"state": "STATE_FALSE", | ||
"type": "linked" | ||
} | ||
], | ||
"observedGeneration":"01HMA2VPHVKNF6QR8TD07KDN5K", | ||
"updatedAt":"2024-01-16T21:29:25.923140Z" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.