Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const DURATION_TO_NB_OF_DAYS_MAP = new Map([
export class CcTokenApiCreationForm extends LitElement {
static get properties() {
return {
apiBridgeHref: { type: String, attribute: 'api-bridge-href' },
apiTokenListHref: { type: String, attribute: 'api-token-list-href' },
state: { type: Object },
};
Expand Down Expand Up @@ -92,6 +93,9 @@ export class CcTokenApiCreationForm extends LitElement {
constructor() {
super();

/** @type {string} Sets the base URL of the API bridge used in the curl example. */
this.apiBridgeHref = 'https://api-bridge.clever-cloud.com';

/** @type {string} URL for the API token list screen */
this.apiTokenListHref = '';

Expand Down Expand Up @@ -394,7 +398,7 @@ export class CcTokenApiCreationForm extends LitElement {
<dt>${i18n('cc-token-api-creation-form.cli.content.use-token')}</dt>
<dd>
<cc-code>
curl -H "Authorization: Bearer &lt;TOKEN&gt;" https://api-bridge.clever-cloud.com/v2/self
curl -H "Authorization: Bearer &lt;TOKEN&gt;" ${new URL('/v2/self', this.apiBridgeHref)}
</cc-code>
</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defineSmartComponent({
const { apiConfig } = context;
const api = new Api(apiConfig);

updateComponent('apiBridgeHref', apiConfig.AUTH_BRIDGE_HOST);
updateComponent('state', { type: 'loading' });

api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ export const dataLoadedWithValidationStep = makeStory(conf, {
],
});

export const withCustomApiBridgeHref = makeStory(conf, {
/** @type {Partial<CcTokenApiCreationForm>[]} */
items: [
{
apiBridgeHref: 'https://custom-api-bridge.example.com',
state: {
type: 'loaded',
activeStep: 'configuration',
isMfaEnabled: true,
values: CcTokenApiCreationForm.DEFAULT_FORM_VALUES,
},
},
],
});

export const dataLoadedWithApiTokenCreated = makeStory(conf, {
/** @type {Partial<CcTokenApiCreationForm>[]} */
items: [
Expand Down
6 changes: 5 additions & 1 deletion src/components/cc-token-api-list/cc-token-api-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { CcPasswordResetEvent, CcTokenRevokeEvent } from '../common.events.js';
export class CcTokenApiList extends LitElement {
static get properties() {
return {
apiBridgeHref: { type: String, attribute: 'api-bridge-href' },
apiTokenCreationHref: { type: String, attribute: 'api-token-creation-href' },
apiTokenUpdateHref: { type: String, attribute: 'api-token-update-href' },
state: { type: Object },
Expand All @@ -53,6 +54,9 @@ export class CcTokenApiList extends LitElement {
constructor() {
super();

/** @type {string} Sets the base URL of the API bridge used in the curl example. */
this.apiBridgeHref = 'https://api-bridge.clever-cloud.com';

/** @type {string|null} Sets the URL leading to the API token creation screen */
this.apiTokenCreationHref = null;

Expand Down Expand Up @@ -207,7 +211,7 @@ export class CcTokenApiList extends LitElement {
<dt>${i18n('cc-token-api-list.cli.content.use-token')}</dt>
<dd>
<cc-code>
curl -H "Authorization: Bearer &lt;TOKEN&gt;" https://api-bridge.clever-cloud.com/v2/self
curl -H "Authorization: Bearer &lt;TOKEN&gt;" ${new URL('/v2/self', this.apiBridgeHref)}
</cc-code>
</dd>
</dl>
Expand Down
2 changes: 2 additions & 0 deletions src/components/cc-token-api-list/cc-token-api-list.smart.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ defineSmartComponent({
const { apiConfig } = context;
const api = new Api(apiConfig);

updateComponent('apiBridgeHref', apiConfig.AUTH_BRIDGE_HOST);

/**
* Updates a single session token
*
Expand Down
14 changes: 14 additions & 0 deletions src/components/cc-token-api-list/cc-token-api-list.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ export const dataLoaded = makeStory(conf, {
],
});

export const withCustomApiBridgeHref = makeStory(conf, {
/** @type {Partial<CcTokenApiList>[]} */
items: [
{
apiBridgeHref: 'https://custom-api-bridge.example.com',
apiTokenUpdateHref,
state: {
type: 'loaded',
apiTokens: baseTokens,
},
},
],
});

export const dataLoadedWithNoPassword = makeStory(conf, {
/** @type {Partial<CcTokenApiList>[]} */
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const SKELETON_VALUES = { name: '', description: '' };
export class CcTokenApiUpdateForm extends LitElement {
static get properties() {
return {
apiBridgeHref: { type: String, attribute: 'api-bridge-href' },
apiTokenListHref: { type: String, attribute: 'api-token-list-href' },
state: { type: Object },
};
Expand All @@ -42,6 +43,9 @@ export class CcTokenApiUpdateForm extends LitElement {
constructor() {
super();

/** @type {string} Sets the base URL of the API bridge used in the curl example. */
this.apiBridgeHref = 'https://api-bridge.clever-cloud.com';

/** @type {string|null} Sets the URL to navigate back to the API token list. */
this.apiTokenListHref = null;

Expand Down Expand Up @@ -102,7 +106,7 @@ export class CcTokenApiUpdateForm extends LitElement {
<dt>${i18n('cc-token-api-update-form.cli.content.use-token')}</dt>
<dd>
<cc-code>
curl -H "Authorization: Bearer &lt;TOKEN&gt;" https://api-bridge.clever-cloud.com/v2/self
curl -H "Authorization: Bearer &lt;TOKEN&gt;" ${new URL('/v2/self', this.apiBridgeHref)}
</cc-code>
</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defineSmartComponent({
const { apiConfig, apiTokenId } = context;
const api = new Api(apiConfig, apiTokenId);

updateComponent('apiBridgeHref', apiConfig.AUTH_BRIDGE_HOST);
updateComponent('state', { type: 'loading' });

api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export const errorWithEmptyName = makeStory(conf, {
},
});

export const withCustomApiBridgeHref = makeStory(conf, {
/** @type {Partial<CcTokenApiUpdateForm>[]} */
items: [
{
apiBridgeHref: 'https://custom-api-bridge.example.com',
apiTokenListHref: CC_TOKEN_API_LIST_STORY_HREF,
state: {
type: 'loaded',
values: baseValues,
},
},
],
});

export const updating = makeStory(conf, {
/** @type {Partial<CcTokenApiUpdateForm>[]} */
items: [
Expand Down