Skip to content

Commit

Permalink
Merge branch 'main' into ICU-14735-boundary-pagination-for-the-aliase…
Browse files Browse the repository at this point in the history
…s-page-in-the-ui
  • Loading branch information
lisbet-alvarez authored Sep 30, 2024
2 parents 53310b0 + 9b33812 commit aa0245a
Show file tree
Hide file tree
Showing 72 changed files with 2,278 additions and 706 deletions.
21 changes: 12 additions & 9 deletions addons/api/addon-test-support/handlers/cache-daemon-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import sinon from 'sinon';
import { typeOf } from '@ember/utils';
import { resourceNames } from 'api/handlers/cache-daemon-handler';
import { singularize } from 'ember-inflector';
import { underscore } from '@ember/string';

/**
* This test helper can be used to help setup your sinon stubs in your tests.
Expand Down Expand Up @@ -69,16 +70,18 @@ export default function setupStubs(hooks) {
.withArgs('searchCacheDaemon')
.onCall(i)
.returns({
[resourceName]: models.map((model) => {
// Use internal serializer to serialize the model correctly
// according to our mirage serializers
const modelData =
this.server.serializerOrRegistry.serialize(model);
[underscore(resourceNames[singularize(resourceName)])]: models.map(
(model) => {
// Use internal serializer to serialize the model correctly
// according to our mirage serializers
const modelData =
this.server.serializerOrRegistry.serialize(model);

// Serialize the data properly to standard JSON as that is what
// we're expecting from the cache daemon response
return JSON.parse(JSON.stringify(modelData));
}),
// Serialize the data properly to standard JSON as that is what
// we're expecting from the cache daemon response
return JSON.parse(JSON.stringify(modelData));
},
),
});
});
};
Expand Down
23 changes: 16 additions & 7 deletions addons/api/addon/handlers/cache-daemon-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { inject as service } from '@ember/service';
import { getOwner, setOwner } from '@ember/application';
import { generateMQLExpression } from '../utils/mql-query';
import { paginateResults } from '../utils/paginate-results';
import { underscore } from '@ember/string';

/**
* Not all types are yet supported by the cache daemon so we'll
Expand Down Expand Up @@ -94,12 +95,14 @@ export default class CacheDaemonHandler {
const sessionData = this.session.data?.authenticated;
const auth_token_id = sessionData?.id;
const token = sessionData?.token;
const resourceName = resourceNames[type];

remainingQuery = {
...remainingQuery,
query: searchQuery,
auth_token_id,
token,
resource: resourceNames[type],
resource: resourceName,
};

let cacheDaemonResults = {};
Expand Down Expand Up @@ -130,18 +133,15 @@ export default class CacheDaemonHandler {
}
} else {
__electronLog?.error(
'Failed to search cache daemon; falling back to search controller',
`Failed to search cache daemon for ${resourceName}. Error:`,
e.message,
);

return fetchControllerData(context, next);
}
}

// Currently returns with a singular top level field with resource name
// e.g. { targets: [...] } or { sessions: [..] }
// So this just unwraps to the array, or undefined
const [results] = Object.values(cacheDaemonResults);
const results = cacheDaemonResults[underscore(resourceName)];
const payload = { items: paginateResults(results, page, pageSize) };

const schema = store.modelFor(type);
Expand All @@ -167,7 +167,16 @@ export default class CacheDaemonHandler {
// This isn't conventional but is better than returning an ArrayProxy
// or EmberArray since the ember store query method asserts it has to be an array
// so we can't just return an object.
records.meta = { totalItems: results?.length ?? 0 };
// Also include whether the results are incomplete or is still refreshing
// as part of the response
records.meta = {
totalItems: results?.length ?? 0,
isLoadIncomplete: cacheDaemonResults.incomplete ?? false,
// Sometimes the refresh status returns an error status if it takes too long but it's still refreshing
isCacheRefreshing:
cacheDaemonResults.refresh_status !== 'not-refreshing',
};

return records;
}
default:
Expand Down
21 changes: 21 additions & 0 deletions addons/api/mirage/scenarios/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@ export default function initializeMockIPC(server, config) {
isClientAgentRunning() {
return false;
}
cacheDaemonStatus() {
return { version: 'Boundary v1.0.0' };
}
getCliVersion() {
return { versionNumber: '1.0.0' };
}
getDesktopVersion() {
return { desktopVersion: '1.0.0' };
}
getLogLevel() {
return 'info';
}
getLogPath() {
return '~/.config/Boundary/logs/desktop-client.log';
}
setLogLevel() {}
clientAgentStatus() {
return { version: '0.0.1-dev', status: 'running' };
}
pauseClientAgent() {}
resumeClientAgent() {}
}

/**
Expand Down
17 changes: 5 additions & 12 deletions addons/core/addon/components/loading-button/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
SPDX-License-Identifier: BUSL-1.1
}}

<Rose::Button
...attributes
@style='inline-link-action'
@iconLeft={{if
this.isLoading
'flight-icons/svg/loading-16'
'flight-icons/svg/reload-16'
}}
class={{if this.isLoading 'loading-button is-loading' 'loading-button'}}
<Hds::Button
@text={{t 'actions.refresh'}}
@color='secondary'
@icon={{if this.isLoading 'loading' 'reload'}}
@disabled={{this.isLoading}}
{{on 'click' this.toggleRefresh}}
>
{{yield}}
</Rose::Button>
/>
23 changes: 14 additions & 9 deletions addons/core/addon/components/toolbar-refresher/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
SPDX-License-Identifier: BUSL-1.1
}}

{{#if this.lastRefreshed}}
<Rose::Toolbar::Info>
{{relative-datetime-live this.lastRefreshed}}
</Rose::Toolbar::Info>
{{/if}}

<LoadingButton @onClick={{this.onClick}}>
{{t 'actions.refresh'}}
</LoadingButton>
<div class='toolbar-refresher'>
{{#if (has-block)}}
{{yield}}
{{else}}
{{#if this.lastRefreshed}}
<Hds::Text::Body @tag='p' @color='faint'>
{{relative-datetime-live this.lastRefreshed}}
</Hds::Text::Body>
{{/if}}
{{/if}}
<LoadingButton @onClick={{this.onClick}}>
{{t 'actions.refresh'}}
</LoadingButton>
</div>
2 changes: 1 addition & 1 deletion addons/core/addon/components/toolbar-refresher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class ToolbarRefresherComponent extends Component {
// =methods

/**
* Executes the click handler argument and trackes the time it completed.
* Executes the click handler argument and tracks the time it completed.
*/
@action
async onClick() {
Expand Down
33 changes: 15 additions & 18 deletions addons/core/addon/styles/addon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
display: flex;
flex-wrap: wrap;
align-items: center;
margin-bottom: 1rem;
gap: 0.5rem;

.filter-tag {
Expand All @@ -27,33 +26,19 @@
margin-top: 3rem;
}

.hds-segmented-group {
> * {
margin-bottom: 1rem;
}

.hds-segmented-group {
.hds-dropdown-toggle-button__text {
white-space: nowrap;
}
}

.hds-table {
margin-bottom: 1rem;
}

.search-filtering-toolbar {
display: flex;

// TODO: Remove these copied styles by migrating to HDS for the toolbar refresher component.
// The original styles assumed we were using the old toolbar component under a "rose-toolbar" class.
.rose-button-inline-link-action {
font-size: 0.8125rem;
line-height: 1.8461538462;
font-weight: 600;
color: var(--stark);
display: inline-block;
vertical-align: middle;
padding: 0.375rem 1rem;
}

> :last-child {
margin-left: auto;
}
Expand All @@ -67,3 +52,15 @@
color: var(--token-color-foreground-primary);
}
}

.toolbar-refresher {
display: flex;
align-items: center;
padding-left: 1rem;
gap: 1rem;

> .hds-text {
white-space: nowrap;
overflow: hidden;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find, click } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | loading-button', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks, 'en-us');

test('it renders', async function (assert) {
await render(hbs`<LoadingButton />`);
assert.ok(find('.loading-button'));
assert.ok(find('.hds-button'));
});

test('it executes a function on refresh button click', async function (assert) {
assert.expect(2);
this.onClick = () => assert.ok(true, 'refresh was clicked');
await render(hbs`<LoadingButton @onClick={{this.onClick}} />`);
assert.ok(find('.loading-button'));
assert.ok(find('.hds-button'));
await click('button');
});
});
4 changes: 4 additions & 0 deletions addons/core/translations/actions/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ back: Back
view: View
retry: Retry
play: Play
pause: Pause
resume: Resume
get-topic-help: Get help for this topic
copy-to-clipboard: Copy to Clipboard
copy-error-detail-to-clipboard: Copy error detail to clipboard
Expand Down Expand Up @@ -60,3 +62,5 @@ yes: Yes
no: No
narrow-results: Narrow results
overflow-options: Overflow Options
show-errors: Show Errors
hide-errors: Hide Errors
28 changes: 28 additions & 0 deletions addons/core/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,31 @@ unsupported-controller:
releases-page: Go to releases page
change-cluster-url: Change cluster URL
error: Unable to download supported version of desktop app. You’ll need to download version 1.7.1 from the releases page
settings:
application: Application
cli: CLI
cache-daemon: Cache Daemon
client-agent:
title: Boundary Client Agent
description: Required to use Transparent Sessions
client: Client
version: Version
color-theme: Color Theme
provider: Provider
hcp: HashiCorp Cloud Platform
self-managed: Self-managed
server:
title: Server
description: Boundary connects you to targets using this server managed by your organization.
logs:
title: Logs
logging-level: Logging level
log-location: Log location
levels:
error: Error
warn: Warn
info: Info
debug: Debug
alerts:
cache-daemon: There may be a problem with the cache daemon
client-agent: There may be a problem with the client agent
1 change: 1 addition & 0 deletions addons/core/translations/resources/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ storage-bucket:
plugin-types:
aws: Amazon S3
minio: MinIO
unknown: Unknown
form:
scope:
label: Scope
Expand Down
11 changes: 11 additions & 0 deletions addons/core/translations/states/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ active-public: Public
recording: Recording
completed: Completed
failed: Failed
installed: Installed
not-running: Not Running
running: Running
paused: Paused
authenticated: Authenticated
unauthenticated: Unauthenticated
loading:
title: Loading all items...
description: All of your {resource} are still loading. Please wait while we finish loading everything on screen.
generic-description: All of your resources are still loading. Please wait while we finish loading everything on screen.
incomplete-loading:
limit: Loaded the first {resultCount} results. Please narrow down your search or filters if the result you're looking for is not shown.
refreshing:
description: Updating cache...
tooltip: Some items may not appear until the cache is finished updating
16 changes: 14 additions & 2 deletions ui/admin/app/routes/scopes/scope/targets/target/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ export default class ScopesScopeTargetsTargetIndexRoute extends Route {
'storage-bucket',
storage_bucket_id,
);
const storage_bucket_name = storageBucket.displayName;
controller.set('storage_bucket_name', storage_bucket_name);
const {
displayName: name,
plugin: { name: pluginName },
isAWS,
isMinIO,
isUnknown,
} = storageBucket;
let icon;
if (isAWS) {
icon = 'aws';
} else if (isMinIO) {
icon = 'cloud-upload';
}
controller.set('storageBucket', { name, pluginName, icon, isUnknown });
}
}
}
4 changes: 1 addition & 3 deletions ui/admin/app/templates/scopes/scope/sessions/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
/>
</S.Generic>
</Hds::SegmentedGroup>
<span>
<ToolbarRefresher @onClick={{this.refresh}} />
</span>
<ToolbarRefresher @onClick={{this.refresh}} />
</div>

<FilterTags @filters={{this.filters}} />
Expand Down
Loading

0 comments on commit aa0245a

Please sign in to comment.