-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up productAreas route * Fix bug * Conditionally add avatars * Componentize project document * Remove old code * Update thumbnail.scss * Add avatar-loading logic * Update template to use TileMedium * Design tweaks * Improve disabled link * Component-ize toggle * Update subscription list * Fix broken tests * Update route nesting * Tests and improved Algolia requests * Show folder icon if ProductColors is disabled * Cleanup * Switch from `facetFilters` → `filters` * Revert AlgoliaService changes * Revert change * Remove unused imports
- Loading branch information
Showing
23 changed files
with
394 additions
and
40 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,82 @@ | ||
<div class="mb-24 w-full"> | ||
{{! Avatar }} | ||
<Product::Avatar | ||
@product={{@productArea}} | ||
@size="xl" | ||
class="mx-auto mt-0.5" | ||
/> | ||
|
||
<div class="text-center"> | ||
{{! Name }} | ||
<h1 class="mt-5 text-display-600"> | ||
{{@productArea}} | ||
</h1> | ||
|
||
{{! Subscription button }} | ||
<Product::SubscriptionToggle | ||
@product={{@productArea}} | ||
@hasTooltip={{true}} | ||
class="mt-6" | ||
/> | ||
|
||
<div class="relative mt-12 text-center"> | ||
{{! Horizontal line behind doc count}} | ||
<div | ||
class="-translate-y-1.2 absolute left-0 top-1/2 h-px w-full bg-color-border-faint" | ||
aria-hidden="true" | ||
/> | ||
{{#if @docs.length}} | ||
{{! Doc count }} | ||
<h3 | ||
data-test-documents-header | ||
class="hermes-h4 relative inline-flex bg-color-page-primary px-6" | ||
> | ||
{{@nbHits}} | ||
Documents | ||
</h3> | ||
{{/if}} | ||
</div> | ||
</div> | ||
|
||
<div class="relative mx-auto mt-7 max-w-3xl"> | ||
{{#if @docs.length}} | ||
{{! Doc list }} | ||
<ol class="divided-list"> | ||
{{#each @docs as |doc|}} | ||
<li data-test-product-area-document class="group relative"> | ||
<Doc::TileMedium @doc={{doc}} /> | ||
</li> | ||
{{/each}} | ||
</ol> | ||
{{#if this.seeMoreButtonIsShown}} | ||
<div class="mt-7"> | ||
<Hds::Button | ||
data-test-see-more-button | ||
@route="authenticated.documents" | ||
@icon="arrow-right" | ||
@iconPosition="trailing" | ||
@query={{hash | ||
product=(array @productArea) | ||
status=(array) | ||
docType=(array) | ||
owners=(array) | ||
page=2 | ||
}} | ||
@color="secondary" | ||
@isFullWidth={{true}} | ||
@text="See more {{@productArea}} documents" | ||
/> | ||
</div> | ||
{{/if}} | ||
{{else}} | ||
<div | ||
class="mt-24 grid h-56 place-items-center text-center text-display-300 text-color-foreground-disabled" | ||
data-test-product-area-empty-state | ||
> | ||
No documents found | ||
</div> | ||
{{/if}} | ||
|
||
</div> | ||
|
||
</div> |
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,23 @@ | ||
import Component from "@glimmer/component"; | ||
import { HITS_PER_PAGE } from "hermes/services/algolia"; | ||
import { HermesDocument } from "hermes/types/document"; | ||
|
||
interface ProductAreaIndexComponentSignature { | ||
Args: { | ||
productArea: string; | ||
docs: HermesDocument[]; | ||
nbHits: number; | ||
}; | ||
} | ||
|
||
export default class ProductAreaIndexComponent extends Component<ProductAreaIndexComponentSignature> { | ||
protected get seeMoreButtonIsShown() { | ||
return this.args.nbHits > HITS_PER_PAGE; | ||
} | ||
} | ||
|
||
declare module "@glint/environment-ember-loose/registry" { | ||
export default interface Registry { | ||
ProductArea: typeof ProductAreaIndexComponent; | ||
} | ||
} |
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
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
10 changes: 10 additions & 0 deletions
10
web/app/controllers/authenticated/product-areas/product-area.ts
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 @@ | ||
import Controller from "@ember/controller"; | ||
import AuthenticatedProductAreasProductAreaRoute from "hermes/routes/authenticated/product-areas/product-area"; | ||
import { ModelFrom } from "hermes/types/route-models"; | ||
|
||
export default class AuthenticatedProductAreasProductAreaController extends Controller { | ||
queryParams = ["product"]; | ||
product = []; | ||
|
||
declare model: ModelFrom<AuthenticatedProductAreasProductAreaRoute>; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Route from "@ember/routing/route"; | ||
import RouterService from "@ember/routing/router-service"; | ||
import Transition from "@ember/routing/transition"; | ||
import { inject as service } from "@ember/service"; | ||
import HermesFlashMessagesService from "hermes/services/flash-messages"; | ||
|
||
export default class AuthenticatedProductAreasRoute extends Route { | ||
@service declare flashMessages: HermesFlashMessagesService; | ||
@service declare router: RouterService; | ||
|
||
beforeModel(transition: Transition) { | ||
// @ts-ignore - `intent` not defined in `Transition` type | ||
const transitionTo = transition.intent.url ?? transition.to.name; | ||
if ( | ||
transitionTo === "/product-areas" || | ||
transitionTo === "/product-areas/" || | ||
transitionTo === "authenticated.product-areas" || | ||
transitionTo === "authenticated.product-areas.index" | ||
) { | ||
this.flashMessages.critical("The URL must specify a product area", { | ||
title: "Invalid URL", | ||
}); | ||
|
||
this.router.transitionTo("authenticated.dashboard"); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
web/app/routes/authenticated/product-areas/product-area.ts
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,57 @@ | ||
import Route from "@ember/routing/route"; | ||
import RouterService from "@ember/routing/router-service"; | ||
import { inject as service } from "@ember/service"; | ||
import { dasherize } from "@ember/string"; | ||
import AlgoliaService from "hermes/services/algolia"; | ||
import AuthenticatedUserService from "hermes/services/authenticated-user"; | ||
import ConfigService from "hermes/services/config"; | ||
import HermesFlashMessagesService from "hermes/services/flash-messages"; | ||
import ProductAreasService from "hermes/services/product-areas"; | ||
import { HermesDocument } from "hermes/types/document"; | ||
import { SearchResponse } from "instantsearch.js"; | ||
|
||
export default class AuthenticatedProductAreasProductAreaRoute extends Route { | ||
@service("config") declare configSvc: ConfigService; | ||
@service declare router: RouterService; | ||
@service declare algolia: AlgoliaService; | ||
@service declare authenticatedUser: AuthenticatedUserService; | ||
@service declare flashMessages: HermesFlashMessagesService; | ||
@service declare productAreas: ProductAreasService; | ||
|
||
async model(params: { product_area_id: string }) { | ||
const searchIndex = | ||
this.configSvc.config.algolia_docs_index_name + "_createdTime_desc"; | ||
|
||
if (this.authenticatedUser.subscriptions) { | ||
void this.authenticatedUser.fetchSubscriptions.perform(); | ||
} else { | ||
await this.authenticatedUser.fetchSubscriptions.perform(); | ||
} | ||
|
||
let productArea = Object.keys(this.productAreas.index).find((product) => { | ||
return dasherize(product) === params.product_area_id; | ||
}); | ||
|
||
if (!productArea) { | ||
this.flashMessages.critical( | ||
`"${params.product_area_id}" is not a valid product area.`, | ||
{ | ||
title: "Product area not found", | ||
}, | ||
); | ||
this.router.transitionTo("authenticated.dashboard"); | ||
} else { | ||
const searchResponse = (await this.algolia.getDocResults.perform( | ||
searchIndex, | ||
{ | ||
filters: `product:"${productArea}"`, | ||
}, | ||
)) as SearchResponse<unknown>; | ||
|
||
const docs = searchResponse.hits as HermesDocument[]; | ||
const { nbHits } = searchResponse; | ||
|
||
return { docs, productArea, nbHits }; | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,5 +21,9 @@ | |
|
||
a { | ||
@apply pointer-events-auto; | ||
|
||
&[disabled] { | ||
@apply pointer-events-none; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{{outlet}} |
7 changes: 7 additions & 0 deletions
7
web/app/templates/authenticated/product-areas/product-area.hbs
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,7 @@ | ||
{{page-title this.model.productArea}} | ||
|
||
<ProductArea | ||
@productArea={{this.model.productArea}} | ||
@nbHits={{this.model.nbHits}} | ||
@docs={{this.model.docs}} | ||
/> |
Oops, something went wrong.