mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-11 10:46:52 +00:00

* Releases updated version of datahub-web client UI code * Fix typo in yarn lock * Change yarn lock to match yarn registry directories * Previous commit missed some paths * Even more changes to yarnlock missing in previous commit * Include codegen file for typings * Add files to get parity for datahub-web and current OS datahub-midtier * Add in typo fix from previous commit - change to proper license * Implement proper OS fix for person entity picture url * Workarounds for open source DH issues * Fixes institutional memory api and removes unopensourced tabs for datasets * Fixes search dataset deprecation and user search issue as a result of changes * Remove internal only options in the avatar menu
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import Component from '@glimmer/component';
|
|
import { action, set, setProperties } from '@ember/object';
|
|
import { INachoDropdownOption } from '@nacho-ui/dropdown/types/nacho-dropdown';
|
|
import { IDynamicComponent } from '@datahub/shared/types/dynamic-component';
|
|
import { reads } from '@ember/object/computed';
|
|
import {
|
|
IContentPanelWithToggle,
|
|
IContentPanelWithToggleItem
|
|
} from '@datahub/data-models/types/entity/rendering/page-components';
|
|
|
|
/**
|
|
* Args required for content-panel-with-toogle
|
|
*/
|
|
export interface IEntityPageContentContentPanelWithToggleArgs {
|
|
// Options will be wrapped into this options object
|
|
options: IContentPanelWithToggle['options'];
|
|
}
|
|
|
|
/**
|
|
* Content panel that will have a toggle to switch between contents
|
|
*
|
|
* This component accept a dropdown with label to show in the toggle. Also it
|
|
* contains a content component that will be rendered once the option is selected.
|
|
* A toolbar component can be passed along with the content component if needed.
|
|
*
|
|
* Comunication between both will be done using a state (redux like). Child will trigger
|
|
* onStateChanged once they require to change the state. This new state will be propagated
|
|
* to other children. Make sure state is not mutated, so every state change results in a new
|
|
* state object.
|
|
*/
|
|
export default class EntityPageContentContentPanelWithToggle<State> extends Component<
|
|
IEntityPageContentContentPanelWithToggleArgs
|
|
> {
|
|
/**
|
|
* Dropdown option selected
|
|
*/
|
|
optionSelected: INachoDropdownOption<IContentPanelWithToggleItem> = this.args.options.dropDownItems[0];
|
|
|
|
/**
|
|
* Current shared state
|
|
*/
|
|
state?: State;
|
|
|
|
/**
|
|
* Shared state before current
|
|
*/
|
|
lastState?: State;
|
|
|
|
/**
|
|
* Alias for content component
|
|
*/
|
|
@reads('optionSelected.value.contentComponent')
|
|
contentComponent!: IDynamicComponent;
|
|
|
|
/**
|
|
* Alias for toobar component
|
|
*/
|
|
@reads('optionSelected.value.toolbarComponent')
|
|
toolbarComponent?: IDynamicComponent;
|
|
|
|
/**
|
|
* Handle when dropdown option is selected
|
|
* @param option Option to be selected
|
|
*/
|
|
@action
|
|
onSelect(option: INachoDropdownOption<IContentPanelWithToggleItem>): void {
|
|
set(this, 'optionSelected', option);
|
|
}
|
|
|
|
/**
|
|
* Handle when state is changed
|
|
* @param state New state
|
|
*/
|
|
@action
|
|
onStateChanged(state: State): void {
|
|
setProperties(this, {
|
|
lastState: this.state,
|
|
state: state
|
|
});
|
|
}
|
|
}
|