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

fix: show only use: true vars properties #4964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ const createDashboardVarsSchema = async (dashboardId: string) => {
const updateDashboardVarsSchema = async (dashboardId: string) => {
try {
const _originalKey = state.targetVariable?.key;
const _use = state.targetVariable?.use || false;
if (!_originalKey) return;
const _newVarsSchemaProperties = cloneDeep(dashboardDetailGetters.dashboardVarsSchemaProperties);
delete _newVarsSchemaProperties[_originalKey];
_newVarsSchemaProperties[state.dashboardGlobalVariable.key] = {
...state.dashboardGlobalVariable,
use: _use,
use: state.targetVariable?.use || false,
created_by: state.targetVariable?.created_by,
};
const _vars = cloneDeep(dashboardDetailGetters.dashboardInfo?.vars || {});
delete _vars[_originalKey];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ onClickOutside(containerRef, hideContextMenu);
const toggleUseDashboardVarsSchema = debounce(async (dashboardId: string, variableKey: string) => {
try {
const _dashboardVarsSchemaProperties: Record<string, DashboardGlobalVariable> = cloneDeep(dashboardDetailGetters.dashboardVarsSchemaProperties);
const _use = !_dashboardVarsSchemaProperties[variableKey].use;
const _vars = cloneDeep(dashboardDetailGetters.dashboardInfo?.vars || {});
if (!_use) {
delete _vars[variableKey];
}
await dashboardStore.updateDashboard(dashboardId, {
dashboard_id: dashboardId,
vars_schema: {
Expand All @@ -100,6 +105,7 @@ const toggleUseDashboardVarsSchema = debounce(async (dashboardId: string, variab
},
},
},
vars: _vars,
});
showSuccessMessage(i18n.t('DASHBOARDS.DETAIL.VARIABLES.ALT_S_UPDATE_DASHBOARD_VARS_SCHEMA'), '');
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ const state = reactive({
}),
newGlobalVariables: computed<DashboardGlobalVariable[]>(() => {
const properties = dashboardDetailGetters.dashboardVarsSchemaProperties as Record<string, DashboardGlobalVariable>;
const _usedProperties: DashboardGlobalVariable[] = Object.values(properties).filter((d) => d.use);
const _presetKeys: string[] = Object.keys(DOMAIN_DASHBOARD_VARS_SCHEMA_PRESET.properties);
const _presetItems = Object.values(properties).filter((d) => _presetKeys.includes(d.key));
const _customItems = Object.values(properties).filter((d) => !_presetKeys.includes(d.key));
const _presetItems = _usedProperties.filter((d) => _presetKeys.includes(d.key));
const _customItems = _usedProperties.filter((d) => !_presetKeys.includes(d.key));
return [
...orderBy(_presetItems, 'name', 'asc'),
...orderBy(_customItems, 'name', 'asc'),
Expand Down
Loading