Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve document route performance #335

Merged
merged 39 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d70f15c
Define SessionService exports
jeffdaley Sep 5, 2023
e211441
WIP convert document route to TS
jeffdaley Sep 5, 2023
99a369d
Update modifiedTime
jeffdaley Sep 5, 2023
f509ecd
Remove thumbnail, update Tile modifiedAgo
jeffdaley Sep 5, 2023
eba8e46
Merge branch 'main' into jeffdaley/document-route
jeffdaley Sep 5, 2023
0c7bd3b
Cleanup
jeffdaley Sep 5, 2023
4564022
Fix modifiedTime type
jeffdaley Sep 5, 2023
c1173aa
Update `modifiedAgo` and `timeAgo`
jeffdaley Sep 5, 2023
32961e7
Add tests
jeffdaley Sep 6, 2023
7097b8e
Rework "modifiedTime" calculations
jeffdaley Sep 6, 2023
0287222
Fix sidebar timeAgo; add documentation
jeffdaley Sep 6, 2023
6a37996
Merge branch 'jeffdaley/modified-ago' into jeffdaley/document-route
jeffdaley Sep 6, 2023
9365ad1
Add "Modified" to tile
jeffdaley Sep 6, 2023
1637b68
Remove console.logs
jeffdaley Sep 6, 2023
adb2db1
Update document.ts
jeffdaley Sep 6, 2023
a02f442
Fix incorrect types and test
jeffdaley Sep 8, 2023
2a4b5e6
Merge branch 'jeffdaley/modified-ago' into jeffdaley/document-route
jeffdaley Sep 8, 2023
ed43ee7
Improve loading states
jeffdaley Sep 11, 2023
04b563c
Update/add tests
jeffdaley Sep 11, 2023
fbc7710
Remove console.logs
jeffdaley Sep 11, 2023
f590b6e
Merge branch 'main' into jeffdaley/document-route-performance
jeffdaley Sep 18, 2023
4b0d46b
Merge branch 'main' into jeffdaley/document-route
jeffdaley Sep 18, 2023
f16922d
Add created types
jeffdaley Sep 18, 2023
6712e10
Clarify types
jeffdaley Sep 18, 2023
6385e7c
Merge branch 'jeffdaley/document-route' into jeffdaley/document-route…
jeffdaley Sep 18, 2023
227fc15
Merge branch 'main' into jeffdaley/document-route-performance
jeffdaley Sep 20, 2023
ad8083b
Remove comment
jeffdaley Sep 20, 2023
88a4b10
Move loading to Person component
jeffdaley Sep 29, 2023
b2db980
Change loading affordance
jeffdaley Sep 29, 2023
be7cfcf
Create a `HermesUser` component
jeffdaley Sep 29, 2023
5615447
Add tests
jeffdaley Sep 29, 2023
14540eb
Move test from acceptance to integration
jeffdaley Sep 29, 2023
2c7a52c
Remove kickOff task
jeffdaley Sep 29, 2023
4df59d8
Grammar tweak
jeffdaley Sep 29, 2023
eda07dd
Move getDocType into route
jeffdaley Sep 29, 2023
15e2d9a
Interface tweak
jeffdaley Sep 29, 2023
bb6841b
Convert `test` to `todo`
jeffdaley Sep 29, 2023
59dda06
Update related-resources-test.ts
jeffdaley Sep 29, 2023
cfc18fd
Merge branch 'jeffdaley/highlight-affordance-test' into jeffdaley/doc…
jeffdaley Sep 29, 2023
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
73 changes: 36 additions & 37 deletions web/app/components/custom-editable-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
data-test-custom-string-field
@value={{get @document @field}}
@onChange={{@onChange}}
@loading={{@loading}}
@isSaving={{@isSaving}}
@disabled={{@disabled}}
>
<:default as |F|>
Expand All @@ -27,41 +27,40 @@
</EditableField>

{{else if this.typeIsPeople}}
<EditableField
data-test-custom-people-field
@value={{get @attributes "value"}}
@onChange={{@onChange}}
@loading={{@loading}}
@disabled={{@disabled}}
>
<:default>
{{#if this.people.length}}
<ol>
{{#each this.people as |person|}}
<li class="whitespace-nowrap">
{{#if person.imgURL}}
<img
src="{{person.imgURL}}"
class="h-4 w-4 rounded-full align-middle"
<HermesUsers class="w-full" @emails={{this.emails}} as |h|>
<EditableField
data-test-custom-people-field
@value={{get @attributes "value"}}
@onChange={{@onChange}}
@isSaving={{@isSaving}}
>
<:default>
{{#if h.users.length}}
<ol class="person-list">
{{#each h.users as |user|}}
<li>
<Person
@imageIsLoading={{h.isLoading}}
@imgURL={{user.imgURL}}
@email={{user.email}}
/>
{{/if}}
{{person.email}}
</li>
{{/each}}
</ol>
{{else}}
<CustomEditableFields::EmptyState />
{{/if}}
</:default>
<:editing as |F|>
<Inputs::PeopleSelect
{{autofocus targetChildren=true}}
class="multiselect--narrow"
@selected={{this.people}}
@onChange={{this.updateEmails}}
{{click-outside (fn F.update this.people)}}
data-test-custom-people-field-input
/>
</:editing>
</EditableField>
</li>
{{/each}}
</ol>
{{else}}
<CustomEditableFields::EmptyState />
{{/if}}
</:default>
<:editing as |F|>
<Inputs::PeopleSelect
{{autofocus targetChildren=true}}
class="multiselect--narrow"
@selected={{h.users}}
@onChange={{h.updateUsers}}
{{click-outside (fn F.update h.users)}}
data-test-custom-people-field-input
/>
</:editing>
</EditableField>
</HermesUsers>
{{/if}}
33 changes: 11 additions & 22 deletions web/app/components/custom-editable-field.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import {
CustomEditableField,
HermesDocument,
HermesUser,
} from "hermes/types/document";
import { CustomEditableField, HermesDocument } from "hermes/types/document";

interface CustomEditableFieldComponentSignature {
Args: {
document: HermesDocument;
field: string;
attributes: CustomEditableField;
onChange: (value: any) => void;
loading?: boolean;
isSaving?: boolean;
disabled?: boolean;
};
}

export default class CustomEditableFieldComponent extends Component<CustomEditableFieldComponentSignature> {
@tracked protected emails: string | string[] =
this.args.attributes.value || [];

protected get typeIsString(): boolean {
return this.args.attributes.type === "STRING";
}
Expand All @@ -30,17 +21,15 @@ export default class CustomEditableFieldComponent extends Component<CustomEditab
return this.args.attributes.type === "PEOPLE";
}

protected get people(): HermesUser[] {
let emails = this.emails instanceof Array ? this.emails : [this.emails];
return emails.map((email: string) => {
return { email, imgURL: null };
});
}

@action protected updateEmails(people: HermesUser[]) {
this.emails = people.map((person: HermesUser) => {
return person.email;
});
protected get emails(): string[] {
if (this.args.attributes.value instanceof Array) {
return this.args.attributes.value;
}
if (this.args.attributes.value) {
return [this.args.attributes.value];
} else {
return [];
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions web/app/components/document/index.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="flex flex-1 space-x-px max-h-screen">
<div class="flex max-h-screen flex-1 space-x-px">
<div
class="sidebar shrink-0 {{if this.sidebarIsCollapsed 'collapsed' 'w-72'}}"
>
Expand All @@ -10,20 +10,20 @@
<Document::Sidebar
@profile={{this.authenticatedUser.info}}
@document={{@document}}
@deleteDraft={{perform this.deleteDraft}}
@docType={{@docType}}
@deleteDraft={{perform this.deleteDraft}}
@isCollapsed={{this.sidebarIsCollapsed}}
@toggleCollapsed={{this.toggleSidebarCollapsedState}}
/>
{{/unless}}
</div>

<div class="pt-4 pb-4 pr-4 w-full">
<div class="w-full pt-4 pb-4 pr-4">
<Hds::Card::Container
@level="high"
@hasBorder={{true}}
@overflow="hidden"
class="flex items-center justify-center h-full"
class="flex h-full items-center justify-center"
>
{{#unless @modelIsChanging}}
{{!
Expand Down
9 changes: 6 additions & 3 deletions web/app/components/document/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import FlashMessageService from "ember-cli-flash/services/flash-messages";
import RecentlyViewedDocsService from "hermes/services/recently-viewed-docs";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { HermesDocumentType } from "hermes/types/document-type";

interface DocumentIndexComponentSignature {
document: HermesDocument;
docType: string;
modelIsChanging: boolean;
Args: {
document: HermesDocument;
modelIsChanging: boolean;
docType: Promise<HermesDocumentType>;
};
}

export default class DocumentIndexComponent extends Component<DocumentIndexComponentSignature> {
Expand Down
Loading