Skip to content

Commit

Permalink
Hide attributes tab if not an expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
ada-x64 committed Oct 25, 2023
1 parent c064ea7 commit 390125c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ export default function (Module) {
// First, look for a column alias, which is a // style comment
// on the first line of the expression.
let expression_alias;
if (expression.name !== null || expression.name !== undefined) {
if (expression.name && expression.name !== "") {
expression_alias = expression.name;
} else {
let alias_match = expression.match(/^\/\/(?<alias>.+?)\n/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use expression_editor::ExprEditorAttr;
use yew::{function_component, html, Callback, Html, Properties};

use crate::components::viewer::ColumnLocator;
use crate::config::Type;
use crate::custom_events::CustomEvents;
use crate::renderer::Renderer;
use crate::session::Session;
Expand All @@ -29,20 +28,13 @@ pub struct AttributesTabProps {
pub session: Session,
pub renderer: Renderer,
pub custom_events: CustomEvents,
pub maybe_ty: Option<Type>,
}

#[function_component]
pub fn AttributesTab(p: &AttributesTabProps) -> Html {
clone!(p.on_close, p.selected_column, p.session, p.renderer);
html_template! {
<div id="attributes-tab">
if let Some(ty) = p.maybe_ty {
<div id="attributes-type" class="tab-section">
<div class="item_title">{ "Type" }</div>
<div id="attributes-type-name" class="text">{ ty }</div>
</div>
}
<div class="tab-section">
<ExprEditorAttr
{on_close}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ pub fn ColumnSettingsSidebar(p: &ColumnSettingsProps) -> Html {

let title = format!("Editing ‘{column_name}’...");

let mut tabs = vec![ColumnSettingsTab::Attributes];
let mut tabs = vec![];

if !matches!(p.selected_column, ColumnLocator::Expr(None))
&& is_active
&& config.is_some()
&& attrs.is_some()
&& maybe_ty.is_some()
{
tabs.reverse();
tabs.push(ColumnSettingsTab::Style);
tabs.reverse();
}
if matches!(p.selected_column, ColumnLocator::Expr(_)) {
tabs.push(ColumnSettingsTab::Attributes);
}

clone!(
Expand Down Expand Up @@ -121,7 +122,6 @@ pub fn ColumnSettingsSidebar(p: &ColumnSettingsProps) -> Html {

{ selected_column }
{ on_close }
{ maybe_ty }
/>
}
}
Expand Down

0 comments on commit 390125c

Please sign in to comment.