Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
fix: file template (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
le-yams authored Nov 12, 2023
1 parent e38a8cf commit 08891f4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.github.le_yams"
version = "1.0-SNAPSHOT"
version = "1.0.0-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.le_yams.openfga4intellij;

import com.intellij.ide.fileTemplates.DefaultTemplatePropertiesProvider;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.annotations.NotNull;

import java.util.Properties;

public class OpenFGADefaultTemplatePropertiesProvider implements DefaultTemplatePropertiesProvider {
@Override
public void fillProperties(@NotNull PsiDirectory directory, @NotNull Properties properties) {
properties.put("OPENFGA_MODEL_VERSION", "1.1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,8 @@ protected void buildDialog(@NotNull Project project, @NotNull PsiDirectory direc
@Override
protected PsiFile createFileFromTemplate(String name, FileTemplate template, PsiDirectory dir) {
var project = dir.getProject();
var properties = createProperties(project);
return new CreateFromTemplateDialog(project, dir, template, new AttributesDefaults(name).withFixedName(true), properties)
return new CreateFromTemplateDialog(project, dir, template, new AttributesDefaults(name).withFixedName(true), null)
.create()
.getContainingFile();
}

private Properties createProperties(Project project) {
var properties = FileTemplateManager.getInstance(project).getDefaultProperties();
properties.put("OPENFGA_MODEL_VERSION", "1.1");
return properties;
}
}
12 changes: 3 additions & 9 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<vendor url="https://github.com/le-yams/openfga4intellij">Yann D'Isanto</vendor>


<description><![CDATA[
<a href="https://openfga.dev/">OpenFGA</a> support plugin.<br>
<ul>
Expand Down Expand Up @@ -49,7 +48,9 @@
id="com.github.le_yams.openfga4intellij.settings.OpenFGASettingsConfigurable"
displayName="OpenFGA"/>

<internalFileTemplate name="OpenFGA Authorization Model"/>
<internalFileTemplate name="OpenFGA Authorization Model" />
<defaultTemplatePropertiesProvider
implementation="com.github.le_yams.openfga4intellij.OpenFGADefaultTemplatePropertiesProvider" />
<defaultLiveTemplates file="/liveTemplates/OpenFGA.xml"/>
<liveTemplateContext
id="OPENFGA_CONTEXT"
Expand All @@ -59,13 +60,6 @@

<group id="OpenFGAPopupGroup" popup="true" text="OpenFGA" />

<action
id="OpenFGA.NewAuthorizationModelFile"
icon="com.github.le_yams.openfga4intellij.OpenFGAIcons.FILE"
class="com.github.le_yams.openfga4intellij.actions.NewAuthorizationModelFile">
<add-to-group group-id="NewGroup" anchor="first" />
</action>

<action id="com.github.le_yams.openfga4intellij.actions.DslToJsonAction"
class="com.github.le_yams.openfga4intellij.actions.DslToJsonAction" text="Generate JSON Authorization Model"
description="Generate authorisation model in JSON format">
Expand Down

0 comments on commit 08891f4

Please sign in to comment.